mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-24 03:15:36 +00:00
proxy: libproxy: add a case for VsockAddr
types
The `NewProxy` function already knows how to deal with `net.UDPAddr` and `net.TCPAddr`, this patch adds similar support for `vsock.VsockAddr`. Signed-off-by: David Scott <dave.scott@docker.com>
This commit is contained in:
parent
2f80e98e7f
commit
403ce4e696
@ -5,6 +5,7 @@ package libproxy
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"vsock"
|
||||
)
|
||||
|
||||
// Proxy defines the behavior of a proxy. It forwards traffic back and forth
|
||||
@ -37,6 +38,12 @@ func NewProxy(frontendAddr, backendAddr net.Addr) (Proxy, error) {
|
||||
return nil, err
|
||||
}
|
||||
return NewTCPProxy(listener, backendAddr.(*net.TCPAddr))
|
||||
case *vsock.VsockAddr:
|
||||
listener, err := vsock.Listen(frontendAddr.(vsock.VsockAddr).Port)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return NewTCPProxy(listener, backendAddr.(*net.TCPAddr))
|
||||
default:
|
||||
panic(fmt.Errorf("Unsupported protocol"))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user