Skip to content

Commit 2d92bf3

Browse files
committedAug 6, 2022
Finished initial socks5 implementation without authentication
1 parent e229cd7 commit 2d92bf3

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed
 

‎README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ Please refer to the [tutorial](doc/Tutorial.md) for more examples.
247247
- Override RequestBody to let the library pull for data when required.
248248
- Write directly to the outgoing DataWriter when data is required.
249249
- Just provide a C++ object and let the library serialize it directly to the wire.
250+
- HTTP Proxy support
251+
- SOCKS5 Proxy support (naive implementatin for now, no support for authentication).
250252

251253
# Current Status
252254
The project has been in public BETA since April 11th 2017.

‎ci/mock-backends/docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ services:
1919

2020
socks:
2121
image: jgaafromnorth/shinysocks
22+
environment:
23+
- LOG_LEVEL=trace
2224
ports:
2325
- "3004:1080"
2426
links:

‎create-and-run-containers.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ else
1313
exit -1
1414
fi
1515

16+
docker-compose stop
1617
docker-compose build
1718
docker-compose up -d
1819
docker ps

‎src/RequestImpl.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const std::string& Request::Proxy::GetName() {
3333
namespace {
3434

3535
static constexpr char SOCKS5_VERSION = 0x05;
36-
static constexpr char SOCKS5_TCP_STREAM = 0x02;
36+
static constexpr char SOCKS5_TCP_STREAM = 0x01;
3737
static constexpr char SOCKS5_MAX_HOSTNAME_LEN = 255;
3838
static constexpr char SOCKS5_IPV4_ADDR = 0x01;
3939
static constexpr char SOCKS5_IPV6_ADDR = 0x04;
@@ -150,18 +150,18 @@ bool isCompleteSocks5ConnectReply(uint8_t *buf, size_t len) {
150150

151151
size_t hdr_len = 5; // Mandatory bytes
152152

153-
switch(buf[2]) {
153+
switch(buf[3]) {
154154
case SOCKS5_IPV4_ADDR:
155-
hdr_len += 4;
155+
hdr_len += 4 + 1;
156156
break;
157157
case SOCKS5_IPV6_ADDR:
158-
hdr_len += 16;
158+
hdr_len += 16 + 1;
159159
break;
160160
case SOCKS5_HOSTNAME_ADDR:
161161
if (len < 4) {
162162
return false; // We need the length field...
163163
}
164-
hdr_len += buf[3];
164+
hdr_len += buf[3] + 1 + 1;
165165
break;
166166
default:
167167
throw ProtocolException{"Wrong/unsupported SOCKS5 BINDADDR type: "s

0 commit comments

Comments
 (0)
Please sign in to comment.