- Allow to swap `github.com/vishvananda/netlink` - Allow to add build tags for each platform - One step closer to development on non-Linux platforms
29 lines
531 B
Go
29 lines
531 B
Go
package wireguard
|
|
|
|
import (
|
|
"fmt"
|
|
"net/netip"
|
|
|
|
"github.com/qdm12/gluetun/internal/netlink"
|
|
)
|
|
|
|
// TODO add IPv6 route if IPv6 is supported
|
|
|
|
func (w *Wireguard) addRoute(link netlink.Link, dst netip.Prefix,
|
|
firewallMark int) (err error) {
|
|
route := netlink.Route{
|
|
LinkIndex: link.Index,
|
|
Dst: dst,
|
|
Table: firewallMark,
|
|
}
|
|
|
|
err = w.netlink.RouteAdd(route)
|
|
if err != nil {
|
|
return fmt.Errorf(
|
|
"adding route for link %s, destination %s and table %d: %w",
|
|
link.Name, dst, firewallMark, err)
|
|
}
|
|
|
|
return err
|
|
}
|