diff --git a/cmd/veil-proxy/main.go b/cmd/veil-proxy/main.go index 39f881f..3cddc76 100644 --- a/cmd/veil-proxy/main.go +++ b/cmd/veil-proxy/main.go @@ -89,8 +89,8 @@ func acceptLoop(ln net.Listener) { var wg sync.WaitGroup wg.Add(2) - go proxy.VsockToTun(vm, tunDev, ch, &wg) - go proxy.TunToVsock(tunDev, vm, ch, &wg) + go proxy.VSOCKToTun(vm, tunDev, ch, &wg) + go proxy.TunToVSOCK(tunDev, vm, ch, &wg) wg.Wait() } } diff --git a/internal/net/nat/nat.go b/internal/net/nat/nat.go index ac182d5..2adfbfe 100644 --- a/internal/net/nat/nat.go +++ b/internal/net/nat/nat.go @@ -1,8 +1,9 @@ package nat import ( - "github.com/Amnesic-Systems/veil/internal/net/tun" "github.com/coreos/go-iptables/iptables" + + "github.com/Amnesic-Systems/veil/internal/net/tun" ) // Enable enables our iptables NAT rules, which connect the enclave to the diff --git a/internal/net/proxy/proxy.go b/internal/net/proxy/proxy.go index b77b562..e129d62 100644 --- a/internal/net/proxy/proxy.go +++ b/internal/net/proxy/proxy.go @@ -11,11 +11,16 @@ import ( const lenBufSize = 2 -// TunToVsock forwards network packets from the tun device to our +// TunToVSOCK forwards network packets from the tun device to our // TCP-over-VSOCK connection. The function keeps on forwarding packets until we // encounter an error or EOF. Errors (including EOF) are written to the given // channel. -func TunToVsock(from io.ReadCloser, to io.WriteCloser, ch chan error, wg *sync.WaitGroup) { +func TunToVSOCK( + from io.ReadCloser, + to io.WriteCloser, + ch chan error, + wg *sync.WaitGroup, +) { defer to.Close() defer wg.Done() var ( @@ -43,11 +48,16 @@ func TunToVsock(from io.ReadCloser, to io.WriteCloser, ch chan error, wg *sync.W ch <- fmt.Errorf("stopped tun-to-vsock forwarding: %w", err) } -// VsockToTun forwards network packets from our TCP-over-VSOCK connection to +// VSOCKToTun forwards network packets from our TCP-over-VSOCK connection to // the tun interface. The function keeps on forwarding packets until we // encounter an error or EOF. Errors (including EOF) are written to the given // channel. -func VsockToTun(from io.ReadCloser, to io.WriteCloser, ch chan error, wg *sync.WaitGroup) { +func VSOCKToTun( + from io.ReadCloser, + to io.WriteCloser, + ch chan error, + wg *sync.WaitGroup, +) { defer to.Close() defer wg.Done() var ( diff --git a/internal/net/proxy/proxy_test.go b/internal/net/proxy/proxy_test.go index 6cf3e52..531a25b 100644 --- a/internal/net/proxy/proxy_test.go +++ b/internal/net/proxy/proxy_test.go @@ -38,8 +38,8 @@ func TestNettest(t *testing.T) { ch = make(chan error) ) wg.Add(2) - go TunToVsock(in, fwd1, ch, &wg) - go VsockToTun(fwd2, out, ch, &wg) + go TunToVSOCK(in, fwd1, ch, &wg) + go VSOCKToTun(fwd2, out, ch, &wg) return in, out, func() {}, nil } nettest.TestConn(t, nettest.MakePipe(mkPipe)) @@ -69,8 +69,8 @@ func TestAToB(t *testing.T) { assertEq(t, err, nil) wg.Add(2) - go TunToVsock(io.NopCloser(bytes.NewReader(sendBuf)), conn1, ch, &wg) - go VsockToTun(conn2, recvBuf, ch, &wg) + go TunToVSOCK(io.NopCloser(bytes.NewReader(sendBuf)), conn1, ch, &wg) + go VSOCKToTun(conn2, recvBuf, ch, &wg) wg.Wait() assertEq(t, bytes.Equal( diff --git a/internal/tunnel/vsock.go b/internal/tunnel/vsock.go index 2ad6c80..cabde55 100644 --- a/internal/tunnel/vsock.go +++ b/internal/tunnel/vsock.go @@ -88,8 +88,8 @@ func setupTunnel( // Spawn goroutines that forward traffic and wait for them to finish. wg.Add(2) defer wg.Wait() - go proxy.VsockToTun(conn, tun, errCh, &wg) - go proxy.TunToVsock(tun, conn, errCh, &wg) + go proxy.VSOCKToTun(conn, tun, errCh, &wg) + go proxy.TunToVSOCK(tun, conn, errCh, &wg) log.Println("Started goroutines to forward traffic.") // Reset the backoff interval.