diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2022-02-19 10:10:05 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2022-03-18 22:07:58 +0100 |
commit | 7a1d26354e521e329c8940265be00303b36810e4 (patch) | |
tree | 45458417976391c5cb78aeb4a2092c7d5d8db40a | |
parent | 00653537dbf45bb4ab8375459f0cd428314594c2 (diff) |
WIP nat + conntrack logger
-rw-r--r-- | tunnel/tools/libwg-go/api-android.go | 4 | ||||
-rw-r--r-- | tunnel/tools/libwg-go/conntrack.go | 5 | ||||
-rw-r--r-- | tunnel/tools/libwg-go/nat-tun.go | 5 |
3 files changed, 10 insertions, 4 deletions
diff --git a/tunnel/tools/libwg-go/api-android.go b/tunnel/tools/libwg-go/api-android.go index 2dc5f53b..9dca58ca 100644 --- a/tunnel/tools/libwg-go/api-android.go +++ b/tunnel/tools/libwg-go/api-android.go @@ -82,10 +82,10 @@ func wgTurnOn(interfaceName string, tunFd int32, settings string) int32 { nativeTun, name, err := CreateUnmonitoredTUNFromFD(int(tunFd)) - ct := NewConntrack() + ct := NewConntrack(logger) service.http_proxy.SetConntrack(ct) - tun, err := NewNatTun(nativeTun, ct) + tun, err := NewNatTun(nativeTun, ct, logger) if err != nil { unix.Close(int(tunFd)) logger.Errorf("CreateUnmonitoredTUNFromFD: %v", err) diff --git a/tunnel/tools/libwg-go/conntrack.go b/tunnel/tools/libwg-go/conntrack.go index 788b1b80..17289a6f 100644 --- a/tunnel/tools/libwg-go/conntrack.go +++ b/tunnel/tools/libwg-go/conntrack.go @@ -4,6 +4,7 @@ import ( "sync" "golang.zx2c4.com/go118/netip" + "golang.zx2c4.com/wireguard/device" ) type connection struct { @@ -21,12 +22,14 @@ func Connection(src, dst netip.AddrPort) connection { type Conntrack struct { connections map[connection]connection connectionsMutex sync.RWMutex + l *device.Logger } -func NewConntrack() *Conntrack { +func NewConntrack(logger *device.Logger) *Conntrack { return &Conntrack{ connections: make(map[connection]connection), connectionsMutex: sync.RWMutex{}, + l: logger, } } diff --git a/tunnel/tools/libwg-go/nat-tun.go b/tunnel/tools/libwg-go/nat-tun.go index 529921d3..75181ba0 100644 --- a/tunnel/tools/libwg-go/nat-tun.go +++ b/tunnel/tools/libwg-go/nat-tun.go @@ -14,6 +14,7 @@ import ( "golang.zx2c4.com/go118/netip" + "golang.zx2c4.com/wireguard/device" "golang.zx2c4.com/wireguard/tun" ) @@ -32,13 +33,15 @@ type natTun struct { conntrack *Conntrack tun tun.Device translations []natEntry + l *device.Logger } -func NewNatTun(t tun.Device, ct *Conntrack) (dev *natTun, err error) { +func NewNatTun(t tun.Device, ct *Conntrack, logger *device.Logger) (dev *natTun, err error) { dev = &natTun{ conntrack: ct, tun: t, translations: make([]natEntry, 4), + l: logger, } err = nil |