Skip to content

Commit 83b6134

Browse files
authored
Merge pull request #1742 from stgraber/main
Fix link parsing failure on non-ethernet devices
2 parents ce475ac + cb1db1f commit 83b6134

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

internal/server/ip/link.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type jsonLink struct {
3636
AllMulticast int `json:"allmulti"`
3737
Master string `json:"master"`
3838
Up string `json:"operstate"`
39+
Type string `json:"link_type"`
3940
Info struct {
4041
Kind string `json:"info_kind"`
4142
} `json:"linkinfo"`
@@ -104,7 +105,7 @@ func LinkFromName(name string) (*Link, error) {
104105
var links []jsonLink
105106
err = json.Unmarshal([]byte(out), &links)
106107
if err != nil {
107-
return nil, fmt.Errorf("failed to decode JSON link representation: %w", err)
108+
return nil, fmt.Errorf("Failed to decode JSON link representation: %w", err)
108109
}
109110

110111
jl := &links[0]
@@ -117,7 +118,7 @@ func LinkFromName(name string) (*Link, error) {
117118
Master: jl.Master,
118119
}
119120

120-
if jl.Address != "" {
121+
if jl.Type == "ether" && jl.Address != "" {
121122
l.Address, err = net.ParseMAC(jl.Address)
122123
if err != nil {
123124
return nil, err

0 commit comments

Comments
 (0)