tree checksum vpatch file split hunks

all signers: mod6

antecedents: bitcoin-v0_5_3_1-rev_bump.7 bitcoin-v0_5_3_1-static_makefile_v002.8 genesis asciilifeform_dns_thermonyukyoolar_kleansing

press order:

genesismod6
bitcoin-asciilifeform.1mod6
rm_rf_upnpmod6
bitcoin-asciilifeform.3-turdmeister-alert-snipmod6
bitcoin-asciilifeform.2-https_snipsnipmod6
bitcoin-v0_5_3_1-static_makefile_v002.8mod6
bitcoin-asciilifeform.4-goodbye-win32mod6
bitcoin-v0_5_3_1-rev_bump.7mod6
asciilifeform_dnsseed_snipsnipmod6
asciilifeform_zap_hardcoded_seedsmod6
asciilifeform_zap_showmyip_crudmod6
asciilifeform_dns_thermonyukyoolar_kleansingmod6
asciilifeform_ver_now_5_4_and_irc_is_gone_and_now_must_give_ipmod6

patch:

- 2A962F65FD9A55BFD5DB5ED17A95D57EC009905436EB550BCDA1C6A024935F1C88B62D509A4C5AC3DDDA00970412BFBA71AAE29F389C191AF22C2F1DCF758C07
+ 4A6FD3869DB3A39835EDD505281AD25B8F0FEAFD30B035369C730E1AFADCD17FE3F1F49C8DA4B3F59D97DAABCA37C9B544F57E8E484A43811A8DCA044726BF45
bitcoin/src/init.cpp
(162 . 9)(162 . 9)
5 " -proxy=<ip:port> \t " + _("Connect through socks4 proxy\n") +
6 " -port=<port> \t\t " + _("Listen for connections on <port> (default: 8333 or testnet: 18333)\n") +
7 " -maxconnections=<n>\t " + _("Maintain at most <n> connections to peers (default: 125)\n") +
8 " -myip=<ip> \t " + _("Set this node's external IP address.\n") +
9 " -addnode=<ip> \t " + _("Add a node to connect to\n") +
10 " -connect=<ip> \t\t " + _("Connect only to the specified node\n") +
11 " -noirc \t " + _("Don't find peers using internet relay chat\n") +
12 " -nolisten \t " + _("Don't accept connections from outside\n") +
13 " -banscore=<n> \t " + _("Threshold for disconnecting misbehaving peers (default: 100)\n") +
14 " -bantime=<n> \t " + _("Number of seconds to keep misbehaving peers from reconnecting (default: 86400)\n") +
(412 . 7)(412 . 6)
16 // Use SoftSetArg here so user can override any of these if they wish.
17 // Note: the GetBoolArg() calls for all of these must happen later.
18 SoftSetArg("-nolisten", true);
19 SoftSetArg("-noirc", true);
20 }
21
22 fNoListen = GetBoolArg("-nolisten");
- A2D021C40268E8DFADD89CE84F19A0FAE780599823CFF27D0AFEEFD7E842F4E1828B18D2BCF97497BA510EFBDFB927041A4FD4DCCF9E83DCAD04C73439AD1565
+
bitcoin/src/irc.cpp
(1 . 436)(0 . 0)
27 // Copyright (c) 2009-2010 Satoshi Nakamoto
28 // Copyright (c) 2009-2012 The Bitcoin developers
29 // Distributed under the MIT/X11 software license, see the accompanying
30 // file license.txt or http://www.opensource.org/licenses/mit-license.php.
31
32 #include "headers.h"
33 #include "irc.h"
34 #include "net.h"
35 #include "strlcpy.h"
36
37 using namespace std;
38 using namespace boost;
39
40 int nGotIRCAddresses = 0;
41 bool fGotExternalIP = false;
42
43 void ThreadIRCSeed2(void* parg);
44
45
46
47
48 #pragma pack(push, 1)
49 struct ircaddr
50 {
51 int ip;
52 short port;
53 };
54 #pragma pack(pop)
55
56 string EncodeAddress(const CAddress& addr)
57 {
58 struct ircaddr tmp;
59 tmp.ip = addr.ip;
60 tmp.port = addr.port;
61
62 vector<unsigned char> vch(UBEGIN(tmp), UEND(tmp));
63 return string("u") + EncodeBase58Check(vch);
64 }
65
66 bool DecodeAddress(string str, CAddress& addr)
67 {
68 vector<unsigned char> vch;
69 if (!DecodeBase58Check(str.substr(1), vch))
70 return false;
71
72 struct ircaddr tmp;
73 if (vch.size() != sizeof(tmp))
74 return false;
75 memcpy(&tmp, &vch[0], sizeof(tmp));
76
77 addr = CAddress(tmp.ip, ntohs(tmp.port), NODE_NETWORK);
78 return true;
79 }
80
81
82
83
84
85
86 static bool Send(SOCKET hSocket, const char* pszSend)
87 {
88 if (strstr(pszSend, "PONG") != pszSend)
89 printf("IRC SENDING: %s\n", pszSend);
90 const char* psz = pszSend;
91 const char* pszEnd = psz + strlen(psz);
92 while (psz < pszEnd)
93 {
94 int ret = send(hSocket, psz, pszEnd - psz, MSG_NOSIGNAL);
95 if (ret < 0)
96 return false;
97 psz += ret;
98 }
99 return true;
100 }
101
102 bool RecvLine(SOCKET hSocket, string& strLine)
103 {
104 strLine = "";
105 loop
106 {
107 char c;
108 int nBytes = recv(hSocket, &c, 1, 0);
109 if (nBytes > 0)
110 {
111 if (c == '\n')
112 continue;
113 if (c == '\r')
114 return true;
115 strLine += c;
116 if (strLine.size() >= 9000)
117 return true;
118 }
119 else if (nBytes <= 0)
120 {
121 if (fShutdown)
122 return false;
123 if (nBytes < 0)
124 {
125 int nErr = WSAGetLastError();
126 if (nErr == WSAEMSGSIZE)
127 continue;
128 if (nErr == WSAEWOULDBLOCK || nErr == WSAEINTR || nErr == WSAEINPROGRESS)
129 {
130 Sleep(10);
131 continue;
132 }
133 }
134 if (!strLine.empty())
135 return true;
136 if (nBytes == 0)
137 {
138 // socket closed
139 printf("socket closed\n");
140 return false;
141 }
142 else
143 {
144 // socket error
145 int nErr = WSAGetLastError();
146 printf("recv failed: %d\n", nErr);
147 return false;
148 }
149 }
150 }
151 }
152
153 bool RecvLineIRC(SOCKET hSocket, string& strLine)
154 {
155 loop
156 {
157 bool fRet = RecvLine(hSocket, strLine);
158 if (fRet)
159 {
160 if (fShutdown)
161 return false;
162 vector<string> vWords;
163 ParseString(strLine, ' ', vWords);
164 if (vWords.size() >= 1 && vWords[0] == "PING")
165 {
166 strLine[1] = 'O';
167 strLine += '\r';
168 Send(hSocket, strLine.c_str());
169 continue;
170 }
171 }
172 return fRet;
173 }
174 }
175
176 int RecvUntil(SOCKET hSocket, const char* psz1, const char* psz2=NULL, const char* psz3=NULL, const char* psz4=NULL)
177 {
178 loop
179 {
180 string strLine;
181 strLine.reserve(10000);
182 if (!RecvLineIRC(hSocket, strLine))
183 return 0;
184 printf("IRC %s\n", strLine.c_str());
185 if (psz1 && strLine.find(psz1) != -1)
186 return 1;
187 if (psz2 && strLine.find(psz2) != -1)
188 return 2;
189 if (psz3 && strLine.find(psz3) != -1)
190 return 3;
191 if (psz4 && strLine.find(psz4) != -1)
192 return 4;
193 }
194 }
195
196 bool Wait(int nSeconds)
197 {
198 if (fShutdown)
199 return false;
200 printf("IRC waiting %d seconds to reconnect\n", nSeconds);
201 for (int i = 0; i < nSeconds; i++)
202 {
203 if (fShutdown)
204 return false;
205 Sleep(1000);
206 }
207 return true;
208 }
209
210 bool RecvCodeLine(SOCKET hSocket, const char* psz1, string& strRet)
211 {
212 strRet.clear();
213 loop
214 {
215 string strLine;
216 if (!RecvLineIRC(hSocket, strLine))
217 return false;
218
219 vector<string> vWords;
220 ParseString(strLine, ' ', vWords);
221 if (vWords.size() < 2)
222 continue;
223
224 if (vWords[1] == psz1)
225 {
226 printf("IRC %s\n", strLine.c_str());
227 strRet = strLine;
228 return true;
229 }
230 }
231 }
232
233 bool GetIPFromIRC(SOCKET hSocket, string strMyName, unsigned int& ipRet)
234 {
235 Send(hSocket, strprintf("USERHOST %s\r", strMyName.c_str()).c_str());
236
237 string strLine;
238 if (!RecvCodeLine(hSocket, "302", strLine))
239 return false;
240
241 vector<string> vWords;
242 ParseString(strLine, ' ', vWords);
243 if (vWords.size() < 4)
244 return false;
245
246 string str = vWords[3];
247 if (str.rfind("@") == string::npos)
248 return false;
249 string strHost = str.substr(str.rfind("@")+1);
250
251 // Hybrid IRC used by lfnet always returns IP when you userhost yourself,
252 // but in case another IRC is ever used this should work.
253 printf("GetIPFromIRC() got userhost %s\n", strHost.c_str());
254 if (fUseProxy)
255 return false;
256 CAddress addr(strHost, 0, true);
257 if (!addr.IsValid())
258 return false;
259 ipRet = addr.ip;
260
261 return true;
262 }
263
264
265
266 void ThreadIRCSeed(void* parg)
267 {
268 IMPLEMENT_RANDOMIZE_STACK(ThreadIRCSeed(parg));
269 try
270 {
271 ThreadIRCSeed2(parg);
272 }
273 catch (std::exception& e) {
274 PrintExceptionContinue(&e, "ThreadIRCSeed()");
275 } catch (...) {
276 PrintExceptionContinue(NULL, "ThreadIRCSeed()");
277 }
278 printf("ThreadIRCSeed exiting\n");
279 }
280
281 void ThreadIRCSeed2(void* parg)
282 {
283 /* Dont advertise on IRC if we don't allow incoming connections */
284 if (mapArgs.count("-connect") || fNoListen)
285 return;
286
287 if (GetBoolArg("-noirc"))
288 return;
289 printf("ThreadIRCSeed started\n");
290 int nErrorWait = 10;
291 int nRetryWait = 10;
292 bool fNameInUse = false;
293
294 while (!fShutdown)
295 {
296 CAddress addrConnect("92.243.23.21", 6667); // irc.lfnet.org
297
298 SOCKET hSocket;
299 if (!ConnectSocket(addrConnect, hSocket))
300 {
301 printf("IRC connect failed\n");
302 nErrorWait = nErrorWait * 11 / 10;
303 if (Wait(nErrorWait += 60))
304 continue;
305 else
306 return;
307 }
308
309 if (!RecvUntil(hSocket, "Found your hostname", "using your IP address instead", "Couldn't look up your hostname", "ignoring hostname"))
310 {
311 closesocket(hSocket);
312 hSocket = INVALID_SOCKET;
313 nErrorWait = nErrorWait * 11 / 10;
314 if (Wait(nErrorWait += 60))
315 continue;
316 else
317 return;
318 }
319
320 string strMyName;
321 if (addrLocalHost.IsRoutable() && !fUseProxy && !fNameInUse)
322 strMyName = EncodeAddress(addrLocalHost);
323 else
324 strMyName = strprintf("x%u", GetRand(1000000000));
325
326 Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str());
327 Send(hSocket, strprintf("USER %s 8 * : %s\r", strMyName.c_str(), strMyName.c_str()).c_str());
328
329 int nRet = RecvUntil(hSocket, " 004 ", " 433 ");
330 if (nRet != 1)
331 {
332 closesocket(hSocket);
333 hSocket = INVALID_SOCKET;
334 if (nRet == 2)
335 {
336 printf("IRC name already in use\n");
337 fNameInUse = true;
338 Wait(10);
339 continue;
340 }
341 nErrorWait = nErrorWait * 11 / 10;
342 if (Wait(nErrorWait += 60))
343 continue;
344 else
345 return;
346 }
347 Sleep(500);
348
349 // Get our external IP from the IRC server and re-nick before joining the channel
350 CAddress addrFromIRC;
351 if (GetIPFromIRC(hSocket, strMyName, addrFromIRC.ip))
352 {
353 printf("GetIPFromIRC() returned %s\n", addrFromIRC.ToStringIP().c_str());
354 if (!fUseProxy && addrFromIRC.IsRoutable())
355 {
356 // IRC lets you to re-nick
357 fGotExternalIP = true;
358 addrLocalHost.ip = addrFromIRC.ip;
359 strMyName = EncodeAddress(addrLocalHost);
360 Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str());
361 }
362 }
363
364 if (fTestNet) {
365 Send(hSocket, "JOIN #bitcoinTEST\r");
366 Send(hSocket, "WHO #bitcoinTEST\r");
367 } else {
368 // randomly join #bitcoin00-#bitcoin99
369 int channel_number = GetRandInt(100);
370 Send(hSocket, strprintf("JOIN #bitcoin%02d\r", channel_number).c_str());
371 Send(hSocket, strprintf("WHO #bitcoin%02d\r", channel_number).c_str());
372 }
373
374 int64 nStart = GetTime();
375 string strLine;
376 strLine.reserve(10000);
377 while (!fShutdown && RecvLineIRC(hSocket, strLine))
378 {
379 if (strLine.empty() || strLine.size() > 900 || strLine[0] != ':')
380 continue;
381
382 vector<string> vWords;
383 ParseString(strLine, ' ', vWords);
384 if (vWords.size() < 2)
385 continue;
386
387 char pszName[10000];
388 pszName[0] = '\0';
389
390 if (vWords[1] == "352" && vWords.size() >= 8)
391 {
392 // index 7 is limited to 16 characters
393 // could get full length name at index 10, but would be different from join messages
394 strlcpy(pszName, vWords[7].c_str(), sizeof(pszName));
395 printf("IRC got who\n");
396 }
397
398 if (vWords[1] == "JOIN" && vWords[0].size() > 1)
399 {
400 // :username!username@50000007.F000000B.90000002.IP JOIN :#channelname
401 strlcpy(pszName, vWords[0].c_str() + 1, sizeof(pszName));
402 if (strchr(pszName, '!'))
403 *strchr(pszName, '!') = '\0';
404 printf("IRC got join\n");
405 }
406
407 if (pszName[0] == 'u')
408 {
409 CAddress addr;
410 if (DecodeAddress(pszName, addr))
411 {
412 addr.nTime = GetAdjustedTime();
413 if (AddAddress(addr, 51 * 60))
414 printf("IRC got new address: %s\n", addr.ToString().c_str());
415 nGotIRCAddresses++;
416 }
417 else
418 {
419 printf("IRC decode failed\n");
420 }
421 }
422 }
423 closesocket(hSocket);
424 hSocket = INVALID_SOCKET;
425
426 if (GetTime() - nStart > 20 * 60)
427 {
428 nErrorWait /= 3;
429 nRetryWait /= 3;
430 }
431
432 nRetryWait = nRetryWait * 11 / 10;
433 if (!Wait(nRetryWait += 60))
434 return;
435 }
436 }
437
438
439
440
441
442
443
444
445
446
447 #ifdef TEST
448 int main(int argc, char *argv[])
449 {
450 WSADATA wsadata;
451 if (WSAStartup(MAKEWORD(2,2), &wsadata) != NO_ERROR)
452 {
453 printf("Error at WSAStartup()\n");
454 return false;
455 }
456
457 ThreadIRCSeed(NULL);
458
459 WSACleanup();
460 return 0;
461 }
462 #endif
- ED3B395DC5D402E50FB6A46188AC5AC5AC249F9A0FF7EB026F66B1B3CB057C1FB660C76EC0626CADDC056B36F208CB8951603316A49B2F2EA25721EFE05B5B4D
+
bitcoin/src/irc.h
(1 . 14)(0 . 0)
467 // Copyright (c) 2009-2010 Satoshi Nakamoto
468 // Copyright (c) 2011 The Bitcoin developers
469 // Distributed under the MIT/X11 software license, see the accompanying
470 // file license.txt or http://www.opensource.org/licenses/mit-license.php.
471 #ifndef BITCOIN_IRC_H
472 #define BITCOIN_IRC_H
473
474 bool RecvLine(SOCKET hSocket, std::string& strLine);
475 void ThreadIRCSeed(void* parg);
476
477 extern int nGotIRCAddresses;
478 extern bool fGotExternalIP;
479
480 #endif
- 0F0E33A7B5754899D74E4653292ABED226B5B28A9DFE250544AD7EAFD928041BD862B8D8293297DABAFD84547124F72E94FE77CAACEB7B1F0ED93460AA8CE449
+ 6CE9F5AA9BA9134F1B98E4AA862C6540BF929C950BF0CA84F35DC4A3FA489121388DD5D43ACA001D0E64DC16AF5D818485E2FF3BBE645A24ABB1FC69EB943A70
bitcoin/src/makefile.unix
(79 . 7)(79 . 6)
485 db.h \
486 headers.h \
487 init.h \
488 irc.h \
489 key.h \
490 keystore.h \
491 main.h \
(99 . 7)(98 . 6)
493 obj/crypter.o \
494 obj/db.o \
495 obj/init.o \
496 obj/irc.o \
497 obj/keystore.o \
498 obj/main.o \
499 obj/net.o \
- EAF9888F03CFC0267577D217D24B0FBA45D5D141E9D8536081059B97195590A0F7AA8D27704CABD46D1AF5033733B96D1BB01C47DCFBD636DB659DB101CC4A45
+ 712C2726313EE78027C22B67DB8F148572C19003463D8438F47D64DC4F354376A7B492D5A7BFBE324FE8B8E6023E4836473B2B76099B72F58262D616665D0F41
bitcoin/src/net.cpp
(4 . 7)(4 . 6)
504 // file license.txt or http://www.opensource.org/licenses/mit-license.php.
505
506 #include "headers.h"
507 #include "irc.h"
508 #include "db.h"
509 #include "net.h"
510 #include "init.h"
(244 . 24)(243 . 6)
512 }
513
514
515 void ThreadGetMyExternalIP(void* parg)
516 {
517 // Wait for IRC to get it first
518 if (!GetBoolArg("-noirc"))
519 {
520 for (int i = 0; i < 2 * 60; i++)
521 {
522 Sleep(1000);
523 if (fGotExternalIP || fShutdown)
524 return;
525 }
526 }
527
528 // Fallback in case IRC fails to get it
529 // ... nope.
530 }
531
532
533 bool AddAddress(CAddress addr, int64 nTimePenalty, CAddrDB *pAddrDB)
534 {
535 if (!addr.IsRoutable())
(1060 . 11)(1041 . 6)
537 if (nSinceLastTry < nDelay)
538 continue;
539
540 // If we have IRC, we'll be notified when they first come online,
541 // and again every 24 hours by the refresh broadcast.
542 if (nGotIRCAddresses > 0 && vNodes.size() >= 2 && nSinceLastSeen > 24 * 60 * 60)
543 continue;
544
545 // Only try the old stuff if we don't have enough connections
546 if (vNodes.size() >= 8 && nSinceLastSeen > 24 * 60 * 60)
547 continue;
(1298 . 21)(1274 . 22)
549 {
550 // Proxies can't take incoming connections
551 addrLocalHost.ip = CAddress("0.0.0.0").ip;
552 printf("addrLocalHost = %s\n", addrLocalHost.ToString().c_str());
553 }
554 else
555 {
556 CreateThread(ThreadGetMyExternalIP, NULL);
557 addrLocalHost.ip = CAddress(mapArgs["-myip"]).ip;
558 if (!addrLocalHost.IsValid())
559 throw runtime_error(strprintf(_("You must set myip=<ipaddress> on the command line or in the configuration file:\n%s\n"
560 "If the file does not exist, create it with owner-readable-only file permissions."),
561 GetConfigFile().c_str()));
562 }
563
564 printf("addrLocalHost = %s\n", addrLocalHost.ToString().c_str());
565
566 //
567 // Start threads
568 //
569
570 // Get addresses from IRC and advertise ours
571 if (!CreateThread(ThreadIRCSeed, NULL))
572 printf("Error: CreateThread(ThreadIRCSeed) failed\n");
573
574 // Send and receive from sockets, accept connections
575 if (!CreateThread(ThreadSocketHandler, NULL))
576 printf("Error: CreateThread(ThreadSocketHandler) failed\n");
- FD5E99A998637D3A0F154C2124A264A76649D115FE5B38BEBEB4BF3ABC1943DE9031EBD2CA002F81F1D7ED53C8E72F072689E16264BE1E6944AE2CF0926EA226
+ 2E06A0B090AF91EBB861BC575A121021EF352E4E55F16DDE823462413029BCE59C45F57D34066BC6D8F9C8E537BA39B6615BDAD286B744A581BC41E55D407A58
bitcoin/src/net.h
(28 . 7)(28 . 6)
581 bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet, int nTimeout=nConnectTimeout);
582 bool Lookup(const char *pszName, std::vector<CAddress>& vaddr, int nServices, int nMaxSolutions, int portDefault = 0, bool fAllowPort = false);
583 bool Lookup(const char *pszName, CAddress& addr, int nServices, int portDefault = 0, bool fAllowPort = false);
584 bool GetMyExternalIP(unsigned int& ipRet);
585 bool AddAddress(CAddress addr, int64 nTimePenalty=0, CAddrDB *pAddrDB=NULL);
586 void AddressCurrentlyConnected(const CAddress& addr);
587 CNode* FindNode(unsigned int ip);
- A8B934C161794E0EABBCBA01CFB3BD9C08F9C14EE92C2053C9F4707DB51139811A37C6C10EF027DB3433BEC9E8C7D3637354215DF85C50C10CB06AA07635D823
+ B4E3047EE278C2A47973DF102A7A8B59982C23EA5C873A20A3FCE83EA5E146FA73F7A3C8C32B43BB9979397A33984B045C561636473D57C97C3383611FC84C2A
bitcoin/src/serialize.h
(41 . 7)(41 . 7)
592 class CAutoFile;
593 static const unsigned int MAX_SIZE = 0x02000000;
594
595 static const int VERSION = 50301;
596 static const int VERSION = 50400;
597 static const char* pszSubVer = "";
598 static const bool VERSION_IS_BETA = true;
599