mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 12:42:34 +02:00
fix docker port discovery
This commit is contained in:
parent
c789c69c86
commit
fdab026a3b
2 changed files with 6 additions and 6 deletions
BIN
bin/go-proxy
BIN
bin/go-proxy
Binary file not shown.
|
@ -61,10 +61,10 @@ func (p *Provider) getContainerProxyConfigs(container types.Container, clientIP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if config.Port == "" {
|
if config.Port == "" {
|
||||||
config.Port = fmt.Sprintf("%d", selectPort(container))
|
config.Port = fmt.Sprintf("%d", selectPort(&container))
|
||||||
}
|
}
|
||||||
if config.Port == "0" {
|
if config.Port == "0" {
|
||||||
l.Debugf("no ports exposed, ignored")
|
l.Infof("no ports exposed, ignored")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if config.Scheme == "" {
|
if config.Scheme == "" {
|
||||||
|
@ -193,14 +193,14 @@ func (p *Provider) getDockerProxyConfigs() (ProxyConfigSlice, error) {
|
||||||
func getPublicPort(p types.Port) uint16 { return p.PublicPort }
|
func getPublicPort(p types.Port) uint16 { return p.PublicPort }
|
||||||
func getPrivatePort(p types.Port) uint16 { return p.PrivatePort }
|
func getPrivatePort(p types.Port) uint16 { return p.PrivatePort }
|
||||||
|
|
||||||
func selectPort(c types.Container) uint16 {
|
func selectPort(c *types.Container) uint16 {
|
||||||
if c.HostConfig.NetworkMode == "host" {
|
if c.HostConfig.NetworkMode == "host" {
|
||||||
return selectPortInternal(c, getPrivatePort)
|
|
||||||
}
|
|
||||||
return selectPortInternal(c, getPublicPort)
|
return selectPortInternal(c, getPublicPort)
|
||||||
}
|
}
|
||||||
|
return selectPortInternal(c, getPrivatePort)
|
||||||
|
}
|
||||||
|
|
||||||
func selectPortInternal(c types.Container, getPort func(types.Port) uint16) uint16 {
|
func selectPortInternal(c *types.Container, getPort func(types.Port) uint16) uint16 {
|
||||||
for _, p := range c.Ports {
|
for _, p := range c.Ports {
|
||||||
if port := getPort(p); port != 0 {
|
if port := getPort(p); port != 0 {
|
||||||
return port
|
return port
|
||||||
|
|
Loading…
Add table
Reference in a new issue