netlink: fix RouteUpdate on win and linux

This commit is contained in:
rkonfj
2024-07-19 19:33:29 +08:00
parent 25222d4b99
commit 3fa897e06e
2 changed files with 8 additions and 8 deletions

View File

@@ -3,6 +3,7 @@ package netlink
import (
"context"
"log/slog"
"slices"
"github.com/vishvananda/netlink"
)
@@ -29,14 +30,13 @@ func RouteSubscribe(ctx context.Context, ch chan<- RouteUpdate) error {
Dst: e.Dst,
Via: e.Gw,
}
if e.Type == 24 {
ru.Type = 1
} else if e.Type == 25 {
ru.Type = 2
} else {
if !slices.Contains([]uint16{24, 25}, e.Type) {
slog.Debug("DropUnsupportRouteEvent")
continue
}
if e.Type == 24 {
ru.New = true
}
ch <- ru
}
}