Allow multiple sub sections for tcp/udp server (Random Port)
This commit is contained in:
parent
40c7b4cbe5
commit
b5faaa8c8f
@ -371,9 +371,11 @@ func (ctl *Control) RegisterProxy(pxyMsg *msg.NewProxy, token string) (remoteAdd
|
|||||||
if ctl.section != "common" {
|
if ctl.section != "common" {
|
||||||
// Sub sections only allow tcp/udp
|
// Sub sections only allow tcp/udp
|
||||||
if pxyMsg.ProxyType == consts.TcpProxy || pxyMsg.ProxyType == consts.UdpProxy {
|
if pxyMsg.ProxyType == consts.TcpProxy || pxyMsg.ProxyType == consts.UdpProxy {
|
||||||
if _, ok := g.GlbServerSubSectionMap[ctl.section].AllowPorts[pxyMsg.RemotePort]; !ok {
|
if pxyMsg.RemotePort != 0 { // Random port
|
||||||
err = fmt.Errorf("port %d number does not belong to section/token", pxyMsg.RemotePort)
|
if _, ok := g.GlbServerSubSectionMap[ctl.section].AllowPorts[pxyMsg.RemotePort]; !ok {
|
||||||
return
|
err = fmt.Errorf("port %d number does not belong to section/token", pxyMsg.RemotePort)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
err = fmt.Errorf("proxy type '%s' only allowed with common token", pxyMsg.ProxyType)
|
err = fmt.Errorf("proxy type '%s' only allowed with common token", pxyMsg.ProxyType)
|
||||||
@ -382,9 +384,11 @@ func (ctl *Control) RegisterProxy(pxyMsg *msg.NewProxy, token string) (remoteAdd
|
|||||||
} else {
|
} else {
|
||||||
// Only TCP and UDP have RemotePort parameter
|
// Only TCP and UDP have RemotePort parameter
|
||||||
if pxyMsg.ProxyType == consts.TcpProxy || pxyMsg.ProxyType == consts.UdpProxy {
|
if pxyMsg.ProxyType == consts.TcpProxy || pxyMsg.ProxyType == consts.UdpProxy {
|
||||||
if _, ok := g.GlbServerSubSectionMap[ctl.section].AllowPorts[pxyMsg.RemotePort]; !ok {
|
if pxyMsg.RemotePort != 0 { // Random port
|
||||||
err = fmt.Errorf("port %d number does not belong to section/token", pxyMsg.RemotePort)
|
if _, ok := g.GlbServerSubSectionMap[ctl.section].AllowPorts[pxyMsg.RemotePort]; !ok {
|
||||||
return
|
err = fmt.Errorf("port %d number does not belong to section/token", pxyMsg.RemotePort)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user