diff --git a/pkg/services/forwarder/ports.go b/pkg/services/forwarder/ports.go index 6b92a005..a1de5401 100644 --- a/pkg/services/forwarder/ports.go +++ b/pkg/services/forwarder/ports.go @@ -25,11 +25,13 @@ import ( "gvisor.dev/gvisor/pkg/tcpip/stack" ) +type ProxyKey string + type PortsForwarder struct { stack *stack.Stack proxiesLock sync.Mutex - proxies map[string]proxy + proxies map[ProxyKey]proxy } type proxy struct { @@ -61,7 +63,7 @@ func (w CloseWrapper) Close() error { func NewPortsForwarder(s *stack.Stack) *PortsForwarder { return &PortsForwarder{ stack: s, - proxies: make(map[string]proxy), + proxies: make(map[ProxyKey]proxy), } } @@ -256,8 +258,8 @@ func (f *PortsForwarder) Expose(protocol types.TransportProtocol, local, remote return nil } -func key(protocol types.TransportProtocol, local string) string { - return fmt.Sprintf("%s/%s", protocol, local) +func key(protocol types.TransportProtocol, local string) ProxyKey { + return ProxyKey(fmt.Sprintf("%s/%s", protocol, local)) } func (f *PortsForwarder) Unexpose(protocol types.TransportProtocol, local string) error {