Allow multiple sub sections for tcp/udp server (Random Port)

This commit is contained in:
Tim David Saxen 2018-11-29 09:57:42 +01:00 committed by GitHub
parent 40c7b4cbe5
commit b5faaa8c8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -371,10 +371,12 @@ func (ctl *Control) RegisterProxy(pxyMsg *msg.NewProxy, token string) (remoteAdd
if ctl.section != "common" {
// Sub sections only allow tcp/udp
if pxyMsg.ProxyType == consts.TcpProxy || pxyMsg.ProxyType == consts.UdpProxy {
if pxyMsg.RemotePort != 0 { // Random port
if _, ok := g.GlbServerSubSectionMap[ctl.section].AllowPorts[pxyMsg.RemotePort]; !ok {
err = fmt.Errorf("port %d number does not belong to section/token", pxyMsg.RemotePort)
return
}
}
} else {
err = fmt.Errorf("proxy type '%s' only allowed with common token", pxyMsg.ProxyType)
return
@ -382,12 +384,14 @@ func (ctl *Control) RegisterProxy(pxyMsg *msg.NewProxy, token string) (remoteAdd
} else {
// Only TCP and UDP have RemotePort parameter
if pxyMsg.ProxyType == consts.TcpProxy || pxyMsg.ProxyType == consts.UdpProxy {
if pxyMsg.RemotePort != 0 { // Random port
if _, ok := g.GlbServerSubSectionMap[ctl.section].AllowPorts[pxyMsg.RemotePort]; !ok {
err = fmt.Errorf("port %d number does not belong to section/token", pxyMsg.RemotePort)
return
}
}
}
}
// Check ports used number in each client
if g.GlbServerCfg.MaxPortsPerClient > 0 {