Skip to content

Commit ad99b84

Browse files
committed
arednlink: maybe ***
1 parent 321d468 commit ad99b84

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

cmd/arednlink.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ var (
2828

2929
func runArednlink(cmd *cobra.Command, _ []string) error {
3030
config := config.GetConfig(cmd)
31-
routes := xsync.NewMapOf[string, string]()
31+
rts := xsync.NewMapOf[string, string]()
32+
routes := &rts
3233
services := xsync.NewMapOf[string, string]()
3334
hosts := xsync.NewMapOf[string, string]()
3435
broadcastChan := make(chan arednlink.Message, 1024)

internal/arednlink/connection.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type Connection struct {
2020
broadcastChan chan Message
2121
hosts *xsync.MapOf[string, string]
2222
services *xsync.MapOf[string, string]
23-
routes **xsync.MapOf[string, string]
23+
routes ***xsync.MapOf[string, string]
2424
iface string
2525
}
2626

@@ -30,7 +30,7 @@ func HandleConnection(
3030
broadcastChan chan Message,
3131
hosts *xsync.MapOf[string, string],
3232
services *xsync.MapOf[string, string],
33-
routes **xsync.MapOf[string, string],
33+
routes ***xsync.MapOf[string, string],
3434
) {
3535
// conn.RemoteAddr().String() should be in the format [fe80::ac1e:2c4%wgc32]:38428
3636
// where wgc32 is the interface name
@@ -205,8 +205,8 @@ func (c *Connection) start() {
205205
}
206206

207207
func (c *Connection) validNextHop(cmd Command, srcIP net.IP) bool {
208-
route, hasRoute := (*c.routes).Load(srcIP.String())
209-
slog.Info("routes", "routes", c.routes)
208+
route, hasRoute := (**c.routes).Load(srcIP.String())
209+
slog.Info("routes", "routes", *c.routes)
210210
slog.Info("arednlink: valid next hop", "command", cmd, "source", srcIP, "route", route, "hasRoute", hasRoute, "myiface", c.iface, "myip", net.ParseIP(c.config.NodeIP))
211211
if srcIP != nil && !srcIP.Equal(net.ParseIP(c.config.NodeIP)) && (cmd == CommandSync || (hasRoute && route == c.iface)) {
212212
return true

internal/arednlink/pollers/poller.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type Manager struct {
2121
ctx context.Context
2222
cancel context.CancelFunc
2323
wg sync.WaitGroup
24-
routes **xsync.MapOf[string, string]
24+
routes ***xsync.MapOf[string, string]
2525
hosts *xsync.MapOf[string, string]
2626
services *xsync.MapOf[string, string]
2727
config *config.Config
@@ -31,7 +31,7 @@ type Manager struct {
3131
func NewManager(
3232
ctx context.Context,
3333
config *config.Config,
34-
routes **xsync.MapOf[string, string],
34+
routes ***xsync.MapOf[string, string],
3535
hosts *xsync.MapOf[string, string],
3636
services *xsync.MapOf[string, string],
3737
broadcastChan chan arednlink.Message,

internal/arednlink/pollers/route.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const (
1717
)
1818

1919
type RoutePoller struct {
20-
routes **xsync.MapOf[string, string]
20+
routes ***xsync.MapOf[string, string]
2121
hosts *xsync.MapOf[string, string]
2222
services *xsync.MapOf[string, string]
2323
config *config.Config
@@ -32,7 +32,7 @@ type Route struct {
3232

3333
func NewRoutePoller(
3434
config *config.Config,
35-
routes **xsync.MapOf[string, string],
35+
routes ***xsync.MapOf[string, string],
3636
hosts *xsync.MapOf[string, string],
3737
services *xsync.MapOf[string, string],
3838
broadcastChan chan arednlink.Message,
@@ -78,7 +78,7 @@ func (p *RoutePoller) Poll() error {
7878
}
7979
}
8080

81-
oldRoutes := *p.routes
81+
oldRoutes := **p.routes
8282
newRoutes := xsync.NewMapOf[string, []net.IP]()
8383
hostRoutes := xsync.NewMapOf[string, string]()
8484
for _, route := range routes {
@@ -142,8 +142,9 @@ func (p *RoutePoller) Poll() error {
142142
newRoutes.Store(route.OutboundIface, existingIPs)
143143
}
144144
}
145-
slog.Info("RoutePoller: re-pointing routes", "oldRoutes", p.routes, "newRoutes", &hostRoutes)
146-
p.routes = &hostRoutes
145+
rts := &hostRoutes
146+
slog.Info("RoutePoller: re-pointing routes", "oldRoutes", *p.routes, "newRoutes", rts)
147+
p.routes = &rts
147148

148149
oldRoutes.Range(func(ip string, _ string) bool {
149150
p.hosts.Delete(ip)

internal/arednlink/server.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ type Server struct {
2424
hosts *xsync.MapOf[string, string]
2525
services *xsync.MapOf[string, string]
2626
broadcastChan chan Message
27-
routes **xsync.MapOf[string, string]
27+
routes ***xsync.MapOf[string, string]
2828
}
2929

3030
func NewServer(
3131
config *config.Config,
32-
routes **xsync.MapOf[string, string],
32+
routes ***xsync.MapOf[string, string],
3333
hosts *xsync.MapOf[string, string],
3434
services *xsync.MapOf[string, string],
3535
broadcastChan chan Message,

0 commit comments

Comments
 (0)