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

Function LoadIPDataFromWeb

src/ipgroups.cpp:138–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138static CIPGroup *LoadIPDataFromWeb(const string &url, const string &groupname, int priority) {
139 try {
140 std::unique_ptr<CurlWrapper> curlWrapper = MakeCurl();
141 curl_easy_setopt(curlWrapper->getHandle(), CURLOPT_SSL_CTX_FUNCTION, &ssl_context_setup);
142
143 // This will block until the download is done.
144 std::string res = curlWrapper->fetchURL(url);
145 LogPrintf("IP list download succeeded from %s\n", url.c_str());
146
147 vector<CSubNet> subnets = ParseIPData(res);
148 if (subnets.size() > 0) {
149 CIPGroup *ipGroup = new CIPGroup;
150 ipGroup->header.name = groupname;
151 ipGroup->header.priority = priority;
152 ipGroup->subnets.assign(subnets.begin(), subnets.end());
153 return ipGroup;
154 }
155 }
156 catch (const curl_error& e) {
157 LogPrintf("Failed to download IP priority data from %s: %s\n",
158 e.url.c_str(), e.what());
159 }
160 return NULL;
161}
162
163static CIPGroup *LoadTorIPsFromWeb() {
164 string ourip = "255.255.255.255";

Callers 1

LoadTorIPsFromWebFunction · 0.85

Calls 7

MakeCurlFunction · 0.85
ParseIPDataFunction · 0.85
getHandleMethod · 0.45
fetchURLMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected