1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Refactor portmapper to remove ALL global state

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2015-03-30 17:31:21 -07:00
parent 43a50b0618
commit 62522c9853
2 changed files with 2 additions and 10 deletions

View file

@ -18,14 +18,7 @@ type mapping struct {
container net.Addr
}
var (
NewProxy = NewProxyCommand
DefaultPortMapper = NewWithPortAllocator(portallocator.DefaultPortAllocator)
SetIptablesChain = DefaultPortMapper.SetIptablesChain
Map = DefaultPortMapper.Map
Unmap = DefaultPortMapper.Unmap
)
var NewProxy = NewProxyCommand
var (
ErrUnknownBackendAddressType = errors.New("unknown container address type not supported")

View file

@ -4,7 +4,6 @@ import (
"net"
"testing"
"github.com/docker/docker/daemon/networkdriver/portallocator"
"github.com/docker/docker/pkg/iptables"
)
@ -126,7 +125,7 @@ func TestMapAllPortsSingleInterface(t *testing.T) {
}()
for i := 0; i < 10; i++ {
start, end := portallocator.PortRange()
start, end := pm.allocator.Begin, pm.allocator.End
for i := start; i < end; i++ {
if host, err = pm.Map(srcAddr1, dstIp1, 0); err != nil {
t.Fatal(err)