fix: if interface name has not been provided, avoid default to a tun interface

This commit is contained in:
Simone Margaritelli 2024-08-08 16:42:52 +02:00
parent 7beb27cfca
commit 9abf7c809a
2 changed files with 6 additions and 0 deletions

View file

@ -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)

View file

@ -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)