@@ -39,7 +39,7 @@ int nConnectTimeout = DEFAULT_CONNECT_TIMEOUT;
39
39
bool fNameLookup = DEFAULT_NAME_LOOKUP;
40
40
41
41
// Need ample time for negotiation for very slow proxies such as Tor (milliseconds)
42
- static const int SOCKS5_RECV_TIMEOUT = 20 * 1000 ;
42
+ int g_socks5_recv_timeout = 20 * 1000 ;
43
43
static std::atomic<bool > interruptSocks5Recv (false );
44
44
45
45
enum Network ParseNetwork (const std::string& net_in) {
@@ -455,7 +455,7 @@ bool Socks5(const std::string& strDest, int port, const ProxyCredentials* auth,
455
455
return error (" Error sending to proxy" );
456
456
}
457
457
uint8_t pchRet1[2 ];
458
- if ((recvr = InterruptibleRecv (pchRet1, 2 , SOCKS5_RECV_TIMEOUT , sock)) != IntrRecvError::OK) {
458
+ if ((recvr = InterruptibleRecv (pchRet1, 2 , g_socks5_recv_timeout , sock)) != IntrRecvError::OK) {
459
459
LogPrintf (" Socks5() connect to %s:%d failed: InterruptibleRecv() timeout or other failure\n " , strDest, port);
460
460
return false ;
461
461
}
@@ -478,7 +478,7 @@ bool Socks5(const std::string& strDest, int port, const ProxyCredentials* auth,
478
478
}
479
479
LogPrint (BCLog::PROXY, " SOCKS5 sending proxy authentication %s:%s\n " , auth->username , auth->password );
480
480
uint8_t pchRetA[2 ];
481
- if ((recvr = InterruptibleRecv (pchRetA, 2 , SOCKS5_RECV_TIMEOUT , sock)) != IntrRecvError::OK) {
481
+ if ((recvr = InterruptibleRecv (pchRetA, 2 , g_socks5_recv_timeout , sock)) != IntrRecvError::OK) {
482
482
return error (" Error reading proxy authentication response" );
483
483
}
484
484
if (pchRetA[0 ] != 0x01 || pchRetA[1 ] != 0x00 ) {
@@ -503,7 +503,7 @@ bool Socks5(const std::string& strDest, int port, const ProxyCredentials* auth,
503
503
return error (" Error sending to proxy" );
504
504
}
505
505
uint8_t pchRet2[4 ];
506
- if ((recvr = InterruptibleRecv (pchRet2, 4 , SOCKS5_RECV_TIMEOUT , sock)) != IntrRecvError::OK) {
506
+ if ((recvr = InterruptibleRecv (pchRet2, 4 , g_socks5_recv_timeout , sock)) != IntrRecvError::OK) {
507
507
if (recvr == IntrRecvError::Timeout) {
508
508
/* If a timeout happens here, this effectively means we timed out while connecting
509
509
* to the remote node. This is very common for Tor, so do not print an
@@ -527,24 +527,24 @@ bool Socks5(const std::string& strDest, int port, const ProxyCredentials* auth,
527
527
uint8_t pchRet3[256 ];
528
528
switch (pchRet2[3 ])
529
529
{
530
- case SOCKS5Atyp::IPV4: recvr = InterruptibleRecv (pchRet3, 4 , SOCKS5_RECV_TIMEOUT , sock); break ;
531
- case SOCKS5Atyp::IPV6: recvr = InterruptibleRecv (pchRet3, 16 , SOCKS5_RECV_TIMEOUT , sock); break ;
530
+ case SOCKS5Atyp::IPV4: recvr = InterruptibleRecv (pchRet3, 4 , g_socks5_recv_timeout , sock); break ;
531
+ case SOCKS5Atyp::IPV6: recvr = InterruptibleRecv (pchRet3, 16 , g_socks5_recv_timeout , sock); break ;
532
532
case SOCKS5Atyp::DOMAINNAME:
533
533
{
534
- recvr = InterruptibleRecv (pchRet3, 1 , SOCKS5_RECV_TIMEOUT , sock);
534
+ recvr = InterruptibleRecv (pchRet3, 1 , g_socks5_recv_timeout , sock);
535
535
if (recvr != IntrRecvError::OK) {
536
536
return error (" Error reading from proxy" );
537
537
}
538
538
int nRecv = pchRet3[0 ];
539
- recvr = InterruptibleRecv (pchRet3, nRecv, SOCKS5_RECV_TIMEOUT , sock);
539
+ recvr = InterruptibleRecv (pchRet3, nRecv, g_socks5_recv_timeout , sock);
540
540
break ;
541
541
}
542
542
default : return error (" Error: malformed proxy response" );
543
543
}
544
544
if (recvr != IntrRecvError::OK) {
545
545
return error (" Error reading from proxy" );
546
546
}
547
- if ((recvr = InterruptibleRecv (pchRet3, 2 , SOCKS5_RECV_TIMEOUT , sock)) != IntrRecvError::OK) {
547
+ if ((recvr = InterruptibleRecv (pchRet3, 2 , g_socks5_recv_timeout , sock)) != IntrRecvError::OK) {
548
548
return error (" Error reading from proxy" );
549
549
}
550
550
LogPrint (BCLog::NET, " SOCKS5 connected %s\n " , strDest);
0 commit comments