Multiplex TCP only if custom domain or subdomain is configured

This commit is contained in:
Guy Lewin 2020-02-16 21:49:22 +02:00
parent 3e6f825a9d
commit b7020e3f3c
2 changed files with 3 additions and 3 deletions

View File

@ -580,8 +580,8 @@ func (cfg *TcpProxyConf) CheckForCli() (err error) {
}
func (cfg *TcpProxyConf) CheckForSvr(serverCfg ServerCommonConf) (err error) {
if len(cfg.CustomDomains) == 0 && cfg.SubDomain == "" && serverCfg.VhostTcpPort != 0 {
return fmt.Errorf("type [tcp] not support when vhost_http_port is on but no custom domain or subdomain configured")
if (len(cfg.CustomDomains) > 0 || cfg.SubDomain != "") && serverCfg.VhostTcpPort == 0 {
return fmt.Errorf("custom domain or subdomain can't be configured on type [tcp] without vhost_http_port")
}
return
}

View File

@ -46,7 +46,7 @@ func (pxy *TcpProxy) Run() (remoteAddr string, err error) {
pxy.listeners = append(pxy.listeners, l)
xl.Info("tcp proxy listen port [%d] in group [%s]", pxy.cfg.RemotePort, pxy.cfg.Group)
} else {
if pxy.serverCfg.VhostTcpPort > 0 {
if pxy.serverCfg.VhostTcpPort > 0 && (len(pxy.cfg.CustomDomains) > 0 || pxy.cfg.SubDomain != "") {
pxy.realPort = pxy.serverCfg.VhostTcpPort
routeConfig := &vhost.VhostRouteConfig{}
for _, domain := range pxy.cfg.CustomDomains {