style: remove some naked returns

This commit is contained in:
Guy Lewin 2020-03-03 17:02:15 -05:00
parent 2cc839b311
commit 045d5102d8

View File

@ -33,10 +33,10 @@ type TcpMuxProxy struct {
func (pxy *TcpMuxProxy) Run() (remoteAddr string, err error) { func (pxy *TcpMuxProxy) Run() (remoteAddr string, err error) {
xl := pxy.xl xl := pxy.xl
routeConfig := &vhost.VhostRouteConfig{}
switch pxy.cfg.Multiplexer { switch pxy.cfg.Multiplexer {
case consts.HttpConnectTcpMultiplexer: case consts.HttpConnectTcpMultiplexer:
routeConfig := &vhost.VhostRouteConfig{}
defer func() { defer func() {
if err != nil { if err != nil {
pxy.Close() pxy.Close()
@ -49,10 +49,9 @@ func (pxy *TcpMuxProxy) Run() (remoteAddr string, err error) {
} }
routeConfig.Domain = domain routeConfig.Domain = domain
l, errRet := pxy.rc.TcpMuxHttpConnectMuxer.Listen(pxy.ctx, routeConfig) l, err := pxy.rc.TcpMuxHttpConnectMuxer.Listen(pxy.ctx, routeConfig)
if errRet != nil { if err != nil {
err = errRet return remoteAddr, err
return
} }
xl.Info("tcpmux httpconnect multiplexer listens for host [%s]", routeConfig.Domain) xl.Info("tcpmux httpconnect multiplexer listens for host [%s]", routeConfig.Domain)
pxy.listeners = append(pxy.listeners, l) pxy.listeners = append(pxy.listeners, l)
@ -61,10 +60,9 @@ func (pxy *TcpMuxProxy) Run() (remoteAddr string, err error) {
if pxy.cfg.SubDomain != "" { if pxy.cfg.SubDomain != "" {
routeConfig.Domain = pxy.cfg.SubDomain + "." + pxy.serverCfg.SubDomainHost routeConfig.Domain = pxy.cfg.SubDomain + "." + pxy.serverCfg.SubDomainHost
l, errRet := pxy.rc.TcpMuxHttpConnectMuxer.Listen(pxy.ctx, routeConfig) l, err := pxy.rc.TcpMuxHttpConnectMuxer.Listen(pxy.ctx, routeConfig)
if errRet != nil { if err != nil {
err = errRet return remoteAddr, err
return
} }
xl.Info("tcpmux httpconnect multiplexer listens for host [%s]", routeConfig.Domain) xl.Info("tcpmux httpconnect multiplexer listens for host [%s]", routeConfig.Domain)
pxy.listeners = append(pxy.listeners, l) pxy.listeners = append(pxy.listeners, l)
@ -73,7 +71,7 @@ func (pxy *TcpMuxProxy) Run() (remoteAddr string, err error) {
pxy.startListenHandler(pxy, HandleUserTcpConnection) pxy.startListenHandler(pxy, HandleUserTcpConnection)
remoteAddr = strings.Join(addrs, ",") remoteAddr = strings.Join(addrs, ",")
return return remoteAddr, err
default: default:
} }
return "", fmt.Errorf("unknown multiplexer [%s]", pxy.cfg.Multiplexer) return "", fmt.Errorf("unknown multiplexer [%s]", pxy.cfg.Multiplexer)