peerByIP returns the public key of the peer that outbound packets addressed to dst should be sent to (see [wgengine.Engine.SetPeerByIPPacketFunc]).
(dst netip.Addr)
| 1039 | // addressed to dst should be sent to (see |
| 1040 | // [wgengine.Engine.SetPeerByIPPacketFunc]). |
| 1041 | func (b *locoBackend) peerByIP(dst netip.Addr) (_ key.NodePublic, ok bool) { |
| 1042 | if !b.serverPub.IsZero() { |
| 1043 | // We're the client; all traffic goes to the server. |
| 1044 | return b.serverPub, true |
| 1045 | } |
| 1046 | b.mu.Lock() |
| 1047 | defer b.mu.Unlock() |
| 1048 | for k := range b.clients { |
| 1049 | if tcAddrForKey(k) == dst { |
| 1050 | return k, true |
| 1051 | } |
| 1052 | } |
| 1053 | return key.NodePublic{}, false |
| 1054 | } |
| 1055 | |
| 1056 | // peerForIP is the [wgengine.Engine.SetPeerForIPFunc] callback, |
| 1057 | // mapping a tailcat IPv6 address to its node in the network map. The |
no test coverage detected