Allow multiple publishing on multiple interfaces on same port.

Fixes the issue where you cannot have multiple ip addresses on the same port for a server.
This commit is contained in:
Tortle 2020-12-01 20:43:40 +01:00 committed by GitHub
parent ba0a1a651e
commit 4a7510d36f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,15 +38,26 @@ func (a *Allocations) Bindings() nat.PortMap {
continue continue
} }
binding := []nat.PortBinding{ binding := nat.PortBinding{
{ HostIP: ip,
HostIP: ip, HostPort: strconv.Itoa(port),
HostPort: strconv.Itoa(port),
},
} }
out[nat.Port(fmt.Sprintf("%d/tcp", port))] = binding tcpPort, ok := out[nat.Port(fmt.Sprintf("%d/tcp", port))]
out[nat.Port(fmt.Sprintf("%d/udp", port))] = binding
if !ok {
out[nat.Port(fmt.Sprintf("%d/tcp", port))] = []nat.PortBinding{binding}
} else {
out[nat.Port(fmt.Sprintf("%d/tcp", port))] = append(tcpPort, binding)
}
udpPort, ok := out[nat.Port(fmt.Sprintf("%d/udp", port))]
if !ok {
out[nat.Port(fmt.Sprintf("%d/udp", port))] = []nat.PortBinding{binding}
} else {
out[nat.Port(fmt.Sprintf("%d/udp", port))] = append(udpPort, binding)
}
} }
} }