setStatus handles the status callback from the wireguard engine to learn about new endpoints (e.g. discovered by STUN). u.L MUST NOT be held
(s *wgengine.Status, err error)
| 170 | // setStatus handles the status callback from the wireguard engine to learn about new endpoints |
| 171 | // (e.g. discovered by STUN). u.L MUST NOT be held |
| 172 | func (u *nodeUpdater) setStatus(s *wgengine.Status, err error) { |
| 173 | u.logger.Debug(context.Background(), "wireguard status", slog.F("status", s), slog.Error(err)) |
| 174 | if err != nil { |
| 175 | return |
| 176 | } |
| 177 | u.L.Lock() |
| 178 | defer u.L.Unlock() |
| 179 | if s.AsOf.Before(u.lastStatus) { |
| 180 | // Don't process outdated status! |
| 181 | return |
| 182 | } |
| 183 | u.lastStatus = s.AsOf |
| 184 | endpoints := make([]string, len(s.LocalAddrs)) |
| 185 | for i, ep := range s.LocalAddrs { |
| 186 | endpoints[i] = ep.Addr.String() |
| 187 | } |
| 188 | if slices.Equal(endpoints, u.endpoints) { |
| 189 | // No need to update the node if nothing changed! |
| 190 | return |
| 191 | } |
| 192 | u.endpoints = endpoints |
| 193 | u.dirty = true |
| 194 | u.Broadcast() |
| 195 | } |
| 196 | |
| 197 | // setAddresses sets the local addresses for the node. u.L MUST NOT be held. |
| 198 | func (u *nodeUpdater) setAddresses(ips []netip.Prefix) { |