mirror of
https://github.com/sigcn/pg.git
synced 2025-10-19 11:04:37 +08:00
netlink: move func AddRoute/DelRoute
This commit is contained in:
@@ -3,6 +3,7 @@ package netlink
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"net"
|
||||
"slices"
|
||||
|
||||
"github.com/vishvananda/netlink"
|
||||
@@ -43,3 +44,17 @@ func RouteSubscribe(ctx context.Context, ch chan<- RouteUpdate) error {
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
func AddRoute(_ string, to *net.IPNet, via net.IP) error {
|
||||
return netlink.RouteAdd(&netlink.Route{
|
||||
Dst: to,
|
||||
Gw: via,
|
||||
})
|
||||
}
|
||||
|
||||
func DelRoute(_ string, to *net.IPNet, via net.IP) error {
|
||||
return netlink.RouteDel(&netlink.Route{
|
||||
Dst: to,
|
||||
Gw: via,
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user