| 139 | } |
| 140 | |
| 141 | static bool IsLocal(const struct wireaddr *addr) |
| 142 | { |
| 143 | // IPv4 loopback |
| 144 | if (IsIPv4(addr) && (GetByte(addr, 3) == 127 || GetByte(addr, 3) == 0)) |
| 145 | return true; |
| 146 | |
| 147 | // IPv6 loopback (::1/128) |
| 148 | static const unsigned char pchLocal[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}; |
| 149 | if (IsIPv6(addr) && RawEq(addr, pchLocal, sizeof(pchLocal))) |
| 150 | return true; |
| 151 | |
| 152 | return false; |
| 153 | } |
| 154 | |
| 155 | static bool IsInternal(const struct wireaddr *addr) |
| 156 | { |