MCPcopy
hub / github.com/syncthing/syncthing / validGateway

Method validGateway

lib/nat/structs.go:102–107  ·  view source on GitHub ↗

Checks if the mappings local IP address matches the IP address of the gateway For example, if we are explicitly listening on 192.168.0.12, there is no point trying to acquire a mapping on a gateway to which the local IP is 10.0.0.1. Fallback to true if any of the IPs is not there.

(ip net.IP)

Source from the content-addressed store, hash-verified

100// point trying to acquire a mapping on a gateway to which the local IP is
101// 10.0.0.1. Fallback to true if any of the IPs is not there.
102func (m *Mapping) validGateway(ip net.IP) bool {
103 if m.address.IP == nil || ip == nil || m.address.IP.IsUnspecified() || ip.IsUnspecified() {
104 return true
105 }
106 return m.address.IP.Equal(ip)
107}
108
109// Address is essentially net.TCPAddr yet is more general, and has a few helper
110// methods which reduce boilerplate code.

Callers 3

TestMappingValidGatewayFunction · 0.95
verifyExistingLockedMethod · 0.80
acquireNewLockedMethod · 0.80

Calls 1

EqualMethod · 0.45

Tested by 1

TestMappingValidGatewayFunction · 0.76