MCPcopy Create free account
hub / github.com/PasarGuard/node / peerIPAllowedOnInterface

Function peerIPAllowedOnInterface

backend/wireguard/user_common.go:190–211  ·  view source on GitHub ↗
(peerNet *net.IPNet, ifaceNets []*net.IPNet)

Source from the content-addressed store, hash-verified

188}
189
190func peerIPAllowedOnInterface(peerNet *net.IPNet, ifaceNets []*net.IPNet) bool {
191 if len(ifaceNets) == 0 {
192 return true
193 }
194 for _, pool := range ifaceNets {
195 if pool == nil || peerNet == nil {
196 continue
197 }
198 if len(peerNet.IP) != len(pool.IP) {
199 continue
200 }
201 if !pool.Contains(peerNet.IP) {
202 continue
203 }
204 pPeer, _ := peerNet.Mask.Size()
205 pPool, _ := pool.Mask.Size()
206 if pPeer >= pPool {
207 return true
208 }
209 }
210 return false
211}
212
213func (wg *WireGuard) collectDesiredPeers(users []*common.User) (map[string]*DesiredPeer, error) {
214 desiredPeers := make(map[string]*DesiredPeer)

Callers 2

collectDesiredPeersMethod · 0.85

Calls

no outgoing calls

Tested by 1