From 9abf7c809ab2c29a73d240220aba49cd32e4525c Mon Sep 17 00:00:00 2001 From: Simone Margaritelli Date: Thu, 8 Aug 2024 16:42:52 +0200 Subject: [PATCH] fix: if interface name has not been provided, avoid default to a tun interface --- network/lan_test.go | 1 + network/net.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/network/lan_test.go b/network/lan_test.go index 20a9cab9..43c989b2 100644 --- a/network/lan_test.go +++ b/network/lan_test.go @@ -25,6 +25,7 @@ func TestNewLAN(t *testing.T) { if err != nil { t.Error("no iface found", err) } + gateway, err := FindGateway(iface) if err != nil { t.Error("no gateway found", err) diff --git a/network/net.go b/network/net.go index afa14822..d6d599c8 100644 --- a/network/net.go +++ b/network/net.go @@ -256,6 +256,11 @@ func FindInterface(name string) (*Endpoint, error) { // return the first one with a valid ipv4 // address that does not loop back for _, iface := range ifaces { + // if name has not been provided, avoid default to a tun interface + if strings.Contains(iface.Name, "tun") { + continue + } + addrs, err := iface.Addrs() if err != nil { fmt.Printf("wtf of the day: %s", err)