From 0f1d9a979cdc9d8a94f5eb0e6d96d6e952c51498 Mon Sep 17 00:00:00 2001 From: Owen Date: Fri, 7 Aug 2026 15:07:00 -0400 Subject: [PATCH] parse the serverIP without cidr correctly --- olm/connect.go | 2 +- olm/exitnode.go | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/olm/connect.go b/olm/connect.go index 5f81324..38f0483 100644 --- a/olm/connect.go +++ b/olm/connect.go @@ -176,7 +176,7 @@ func (o *Olm) handleConnect(msg websocket.WSMessage) { logger.Error("Failed to o.tunnelConfigure interface: %v", err) } - if network.AddRoutes([]string{wgData.UtilitySubnet}, o.tunnelConfig.InterfaceName); err != nil { // also route the utility subnet + if err := network.AddRoutes([]string{wgData.UtilitySubnet}, o.tunnelConfig.InterfaceName); err != nil { // also route the utility subnet logger.Error("Failed to add route for utility subnet: %v", err) } diff --git a/olm/exitnode.go b/olm/exitnode.go index 86f84fb..fb0699a 100644 --- a/olm/exitnode.go +++ b/olm/exitnode.go @@ -99,7 +99,14 @@ persistent_keepalive_interval=%d`, util.FixKey(cfg.PublicKey), allowedIP, resolv logger.Warn("Failed to add secondary address %s for exit node: %v", tunnelIP, err) } - if err := network.AddRouteForServerIP(cfg.ServerIP, interfaceName); err != nil { + // ServerIP arrives as a bare IP with no CIDR suffix, but AddRouteForServerIP + // parses it as a CIDR on darwin (to explicitly route the subnet up the tunnel, + // since unlike Linux, adding the address to the interface does not implicitly + // create a route for it) - without a mask that parse fails and the route (and + // its corresponding NetworkSettings entry, which is what surfaces it via the + // API) is silently never added. + serverIPForRoute := strings.Split(cfg.ServerIP, "/")[0] + "/32" + if err := network.AddRouteForServerIP(serverIPForRoute, interfaceName); err != nil { logger.Warn("Failed to add route for exit node server IP: %v", err) } @@ -163,7 +170,8 @@ func (o *Olm) removeExitNodePeerLocked() error { } interfaceName := o.tunnelConfig.InterfaceName - if err := network.RemoveRouteForServerIP(cfg.ServerIP, interfaceName); err != nil { + serverIPForRoute := strings.Split(cfg.ServerIP, "/")[0] + "/32" + if err := network.RemoveRouteForServerIP(serverIPForRoute, interfaceName); err != nil { logger.Warn("Failed to remove route for exit node server IP: %v", err) }