MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / InitIPGroups

Function InitIPGroups

src/ipgroups.cpp:288–318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286}
287
288void 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
320IPGroupSlot::IPGroupSlot(const std::string& groupName) :
321 groupName(groupName), groupCS(cs_groups)

Callers 2

StartNodeFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 9

GetBoolArgFunction · 0.85
GetProxyFunction · 0.85
InitTorIPGroupsFunction · 0.85
GetArgFunction · 0.85
NetworkIDStringMethod · 0.80
scheduleEveryMethod · 0.80
ParamsClass · 0.70
clearMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68