diff options
| author | Bitflash <admin@bitflash.network> | 2026-08-12 10:18:14 -0300 |
|---|---|---|
| committer | Bitflash <admin@bitflash.network> | 2026-08-12 10:18:14 -0300 |
| commit | c330b8e5e1c057049b5b361908c94f41344dff80 (patch) | |
| tree | 44e70a657e4fa70205d9d318839ac68f175a1fb9 /src/btfrv.cpp | |
| parent | 026ec904b7bde4898fbb889b7758dbcb13bf860a (diff) | |
| parent | 066379ebcb1dac720221fe1a1841fa6f59df21d9 (diff) | |
Merge pull request 'net: add optional SOCKS5 outbound proxy' (#27) from socks5-proxy into main
Diffstat (limited to 'src/btfrv.cpp')
| -rw-r--r-- | src/btfrv.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/btfrv.cpp b/src/btfrv.cpp index 6ac3280..d4f079f 100644 --- a/src/btfrv.cpp +++ b/src/btfrv.cpp | |||
| @@ -5,6 +5,9 @@ | |||
| 5 | // Windows/Winsock implementation (Layer 6 will #ifdef this for Linux/BSD sockets). | 5 | // Windows/Winsock implementation (Layer 6 will #ifdef this for Linux/BSD sockets). |
| 6 | 6 | ||
| 7 | #include "btfrv.h" | 7 | #include "btfrv.h" |
| 8 | #ifdef BITFLASH_NODE_BUILD | ||
| 9 | #include "proxy.h" | ||
| 10 | #endif | ||
| 8 | 11 | ||
| 9 | // Portable sockets: Winsock on Windows, BSD sockets on Linux/POSIX (for the | 12 | // Portable sockets: Winsock on Windows, BSD sockets on Linux/POSIX (for the |
| 10 | // headless relay `bitflashd` that runs on the VPS). | 13 | // headless relay `bitflashd` that runs on the VPS). |
| @@ -92,6 +95,11 @@ static bool WriteN(SOCKET s, const void* buf, int n) | |||
| 92 | 95 | ||
| 93 | static SOCKET ConnectTo(const char* host, unsigned short port) | 96 | static SOCKET ConnectTo(const char* host, unsigned short port) |
| 94 | { | 97 | { |
| 98 | #ifdef BITFLASH_NODE_BUILD | ||
| 99 | SOCKET s = BtfConnectSocket(host, port, SOCK_RV_DIAL, 10); | ||
| 100 | if (s == INVALID_SOCKET) | ||
| 101 | return INVALID_SOCKET; | ||
| 102 | #else | ||
| 95 | struct addrinfo hints, *res = NULL; | 103 | struct addrinfo hints, *res = NULL; |
| 96 | memset(&hints, 0, sizeof(hints)); | 104 | memset(&hints, 0, sizeof(hints)); |
| 97 | hints.ai_family = AF_INET; | 105 | hints.ai_family = AF_INET; |
| @@ -119,6 +127,7 @@ static SOCKET ConnectTo(const char* host, unsigned short port) | |||
| 119 | CLOSESOCK(s); freeaddrinfo(res); return INVALID_SOCKET; | 127 | CLOSESOCK(s); freeaddrinfo(res); return INVALID_SOCKET; |
| 120 | } | 128 | } |
| 121 | freeaddrinfo(res); | 129 | freeaddrinfo(res); |
| 130 | #endif | ||
| 122 | 131 | ||
| 123 | // Clear the timeout -- the socket is now a live tunnel and must not | 132 | // Clear the timeout -- the socket is now a live tunnel and must not |
| 124 | // time out when idle. recv() will block until data arrives or peer closes. | 133 | // time out when idle. recv() will block until data arrives or peer closes. |