From 7f5782cde59f2ea29dd28237c34f7a4bf55ea562 Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Mon, 26 Apr 2021 09:56:38 +0200 Subject: [PATCH] fix: add default interface --- pkg/config/config.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/config/config.go b/pkg/config/config.go index 8733099..1a6187a 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -71,6 +71,14 @@ func Read(cnfFile string) (*types.Config, error) { return nil, fmt.Errorf("failed to decode json: %w", err) } + if len(cnf.Ifaces) <= 0 { + defaultInterface, err := getDefaultInterfaceByIP() + if err != nil { + return nil, err + } + cnf.Ifaces = []string{defaultInterface.Name} + } + for _, iface := range cnf.Ifaces { if _, err := net.InterfaceByName(iface); err != nil { return nil, fmt.Errorf("unknown interface: %v", iface)