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)
| 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. |
| 102 | func (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. |