From 984acfadb83956aee141db0a3e40dff332329fb1 Mon Sep 17 00:00:00 2001 From: Igor Bukanov Date: Mon, 16 Sep 2024 23:52:24 +0200 Subject: [PATCH] Unix socket support The new Brave BAT payments service uses viproxy to expose the service in the nitro enclave. For local testing outside AWS we plan to simulate Nitro by using a container that does not have an IP network but rather uses Unix sockets to communicate to the outside world. To cover that add support for directing the traffic into a unix socket. For symmetry also allow to listen on UNIX sockets. --- viproxy.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/viproxy.go b/viproxy.go index 62bb687..7c420ef 100644 --- a/viproxy.go +++ b/viproxy.go @@ -56,6 +56,8 @@ func dial(addr net.Addr) (net.Conn, error) { conn, err = vsock.Dial(a.ContextID, a.Port, nil) case *net.TCPAddr: conn, err = net.DialTCP("tcp", nil, a) + case *net.UnixAddr: + conn, err = net.DialUnix(addr.Network(), nil, a) } if err != nil { return nil, err @@ -73,6 +75,8 @@ func listen(addr net.Addr) (net.Listener, error) { ln, err = vsock.ListenContextID(a.ContextID, a.Port, nil) case *net.TCPAddr: ln, err = net.ListenTCP(a.Network(), a) + case *net.UnixAddr: + ln, err = net.ListenUnix(addr.Network(), a) } if err != nil { return nil, err