| 286 | } |
| 287 | |
| 288 | void InitIPGroups(CScheduler *scheduler) { |
| 289 | { |
| 290 | LOCK(*cs_groups); |
| 291 | groups.clear(); |
| 292 | } |
| 293 | |
| 294 | // If scheduler is NULL then we're in unit tests. |
| 295 | if (scheduler) { |
| 296 | // Don't use in regtest mode to avoid excessive and useless HTTP requests, don't use if the user disabled. |
| 297 | if (GetBoolArg("-disableipprio", false) || Params().NetworkIDString() == "regtest" || !fListen) |
| 298 | return; |
| 299 | // If we have a proxy, then we are most likely not reachable from the internet, so don't use. |
| 300 | proxyType dummy; |
| 301 | if (GetProxy(NET_IPV4, dummy) || GetProxy(NET_IPV6, dummy) || GetProxy(NET_TOR, dummy)) |
| 302 | return; |
| 303 | } |
| 304 | |
| 305 | InitTorIPGroups(scheduler); |
| 306 | InitIPGroupsFromCommandLine(); |
| 307 | if (scheduler) |
| 308 | scheduler->scheduleEvery(&InitIPGroupsFromCommandLine, GetArg("-poll-ip-sources-seconds", DEFAULT_IP_PRIO_SRC_POLL_INTERVAL)); |
| 309 | |
| 310 | // Future ideas: |
| 311 | // - Load IP ranges from URLs to let node admin deprioritise ranges that seem to be jamming. |
| 312 | // - Dialback on connect to see if an IP is listening/responding to port 8333: if so, more likely |
| 313 | // to be a valuable peer than an attacker, so bump priority. |
| 314 | // - Raise priority of a connection as it does valuable things like relaying data to us. |
| 315 | // - Design a protocol to let user wallets gain priority by proving ownership of coin age, as they tend to have |
| 316 | // short lived connections and roam around different IPs, but we still want to serve them ahead of long term |
| 317 | // idling connections. |
| 318 | } |
| 319 | |
| 320 | IPGroupSlot::IPGroupSlot(const std::string& groupName) : |
| 321 | groupName(groupName), groupCS(cs_groups) |