|
@@ -151,7 +151,7 @@ func (pm *PortMapper) MapRange(container net.Addr, hostIP net.IP, hostPortStart,
|
|
|
}
|
|
|
|
|
|
containerIP, containerPort := getIPAndPort(m.container)
|
|
|
- if hostIP.To4() != nil || hostIP.To16() != nil {
|
|
|
+ if pm.checkIP(hostIP) {
|
|
|
if err := pm.AppendForwardingTableEntry(m.proto, hostIP, allocatedHostPort, containerIP.String(), containerPort); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
@@ -160,7 +160,7 @@ func (pm *PortMapper) MapRange(container net.Addr, hostIP net.IP, hostPortStart,
|
|
|
cleanup := func() error {
|
|
|
// need to undo the iptables rules before we return
|
|
|
m.userlandProxy.Stop()
|
|
|
- if hostIP.To4() != nil || hostIP.To16() != nil {
|
|
|
+ if pm.checkIP(hostIP) {
|
|
|
pm.DeleteForwardingTableEntry(m.proto, hostIP, allocatedHostPort, containerIP.String(), containerPort)
|
|
|
if err := pm.Allocator.ReleasePort(hostIP, m.proto, allocatedHostPort); err != nil {
|
|
|
return err
|