Fix gateway & FIx prefix check

This commit is contained in:
世界 2024-10-26 14:54:08 +08:00
parent 07278fb470
commit 10f73346a0
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
8 changed files with 111 additions and 45 deletions

View file

@ -245,11 +245,12 @@ func configure(tunFd int, ifIndex int, name string, options Options) error {
if err != nil {
return err
}
gateway4, gateway6 := options.Inet4GatewayAddr(), options.Inet6GatewayAddr()
for _, routeRange := range routeRanges {
if routeRange.Addr().Is4() {
err = addRoute(routeRange, options.Inet4Address[0].Addr())
err = addRoute(routeRange, gateway4)
} else {
err = addRoute(routeRange, options.Inet6Address[0].Addr())
err = addRoute(routeRange, gateway6)
}
if err != nil {
return E.Cause(err, "add route: ", routeRange)