Skip to content

Commit

Permalink
Merge pull request #326 from vvhuang-ll/fix/default-interface-detection
Browse files Browse the repository at this point in the history
Fix: Enhance default interface detection logic
  • Loading branch information
Lyt99 authored Dec 11, 2024
2 parents bc19a8b + 80d4412 commit 0caffc7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/skoop/netstack/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ func LookupDefaultIfaceName(ifaces []Interface) string {
}
}

// find first interfaces matched enp[0-9]+s[0-9]+.*
regex := regexp.MustCompile("^enp[0-9]+s[0-9]+.*$")
// find first interfaces matched (enp[0-9]+s[0-9]+.*|eth[0-9]+|ens[0-9]+)$")
regex := regexp.MustCompile("^(enp[0-9]+s[0-9]+.*|eth[0-9]+|ens[0-9]+)$")
filtered := lo.Filter(ifaces, func(i Interface, _ int) bool {
return regex.MatchString(i.Name)
})
Expand Down
4 changes: 4 additions & 0 deletions pkg/skoop/netstack/link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ func TestLookupDefaultIfaceName(t *testing.T) {
ifaces: []string{"wg0", "ipvs0", "cni0", "aaenp1s1"},
expected: "",
},
{
ifaces: []string{"ens160", "cali85f094c216c", "vxlan.calico", "calie92c3084733"},
expected: "ens160",
},
}

for _, c := range testcases {
Expand Down

0 comments on commit 0caffc7

Please sign in to comment.