chore: use gofumpt for code formatting
This commit is contained in:
@@ -9,9 +9,7 @@ import (
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrRouteDefaultNotFound = errors.New("default route not found")
|
||||
)
|
||||
var ErrRouteDefaultNotFound = errors.New("default route not found")
|
||||
|
||||
type DefaultRoute struct {
|
||||
NetInterface string
|
||||
|
||||
@@ -4,6 +4,4 @@ import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrLinkDefaultNotFound = errors.New("default link not found")
|
||||
)
|
||||
var ErrLinkDefaultNotFound = errors.New("default link not found")
|
||||
|
||||
@@ -14,9 +14,7 @@ func ipIsPrivate(ip netip.Addr) bool {
|
||||
ip.IsLinkLocalUnicast() || ip.IsLinkLocalMulticast()
|
||||
}
|
||||
|
||||
var (
|
||||
errInterfaceIPNotFound = errors.New("IP address not found for interface")
|
||||
)
|
||||
var errInterfaceIPNotFound = errors.New("IP address not found for interface")
|
||||
|
||||
func ipMatchesFamily(ip netip.Addr, family int) bool {
|
||||
return (family == netlink.FamilyV4 && ip.Is4()) ||
|
||||
|
||||
@@ -22,7 +22,8 @@ func (r *Routing) SetOutboundRoutes(outboundSubnets []netip.Prefix) error {
|
||||
}
|
||||
|
||||
func (r *Routing) setOutboundRoutes(outboundSubnets []netip.Prefix,
|
||||
defaultRoutes []DefaultRoute) (err error) {
|
||||
defaultRoutes []DefaultRoute,
|
||||
) (err error) {
|
||||
r.stateMutex.Lock()
|
||||
defer r.stateMutex.Unlock()
|
||||
|
||||
@@ -47,7 +48,8 @@ func (r *Routing) setOutboundRoutes(outboundSubnets []netip.Prefix,
|
||||
}
|
||||
|
||||
func (r *Routing) removeOutboundSubnets(subnets []netip.Prefix,
|
||||
defaultRoutes []DefaultRoute) (warnings []string) {
|
||||
defaultRoutes []DefaultRoute,
|
||||
) (warnings []string) {
|
||||
for i, subNet := range subnets {
|
||||
for _, defaultRoute := range defaultRoutes {
|
||||
err := r.deleteRouteVia(subNet, defaultRoute.Gateway, defaultRoute.NetInterface, outboundTable)
|
||||
@@ -73,7 +75,8 @@ func (r *Routing) removeOutboundSubnets(subnets []netip.Prefix,
|
||||
}
|
||||
|
||||
func (r *Routing) addOutboundSubnets(subnets []netip.Prefix,
|
||||
defaultRoutes []DefaultRoute) (err error) {
|
||||
defaultRoutes []DefaultRoute,
|
||||
) (err error) {
|
||||
for i, subnet := range subnets {
|
||||
subnetIsIPv6 := subnet.Addr().Is6()
|
||||
subnetRouteAdded := false
|
||||
|
||||
@@ -9,7 +9,8 @@ import (
|
||||
)
|
||||
|
||||
func (r *Routing) addRouteVia(destination netip.Prefix, gateway netip.Addr,
|
||||
iface string, table int) error {
|
||||
iface string, table int,
|
||||
) error {
|
||||
destinationStr := destination.String()
|
||||
r.logger.Info("adding route for " + destinationStr)
|
||||
r.logger.Debug("ip route replace " + destinationStr +
|
||||
@@ -37,7 +38,8 @@ func (r *Routing) addRouteVia(destination netip.Prefix, gateway netip.Addr,
|
||||
}
|
||||
|
||||
func (r *Routing) deleteRouteVia(destination netip.Prefix, gateway netip.Addr,
|
||||
iface string, table int) (err error) {
|
||||
iface string, table int,
|
||||
) (err error) {
|
||||
destinationStr := destination.String()
|
||||
r.logger.Info("deleting route for " + destinationStr)
|
||||
r.logger.Debug("ip route delete " + destinationStr +
|
||||
|
||||
@@ -60,7 +60,8 @@ func (r *Routing) deleteIPRule(src, dst netip.Prefix, table, priority int) error
|
||||
}
|
||||
|
||||
func ruleDbgMsg(add bool, src, dst netip.Prefix,
|
||||
table, priority int) (debugMessage string) {
|
||||
table, priority int,
|
||||
) (debugMessage string) {
|
||||
debugMessage = "ip rule"
|
||||
|
||||
if add {
|
||||
|
||||
@@ -17,7 +17,8 @@ func makeNetipPrefix(n byte) netip.Prefix {
|
||||
}
|
||||
|
||||
func makeIPRule(src, dst netip.Prefix,
|
||||
table, priority int) netlink.Rule {
|
||||
table, priority int,
|
||||
) netlink.Rule {
|
||||
rule := netlink.NewRule()
|
||||
rule.Src = src
|
||||
rule.Dst = dst
|
||||
|
||||
Reference in New Issue
Block a user