summaryrefslogtreecommitdiff
path: root/main2.c
diff options
context:
space:
mode:
authorfadhil riyanto <me@fadev.org>2024-10-08 19:18:49 +0700
committerfadhil riyanto <me@fadev.org>2024-10-08 19:18:49 +0700
commitcbbaf6283ecb185d91192a2eadb0dc8e2ffc6048 (patch)
treea3f5ed1f47312923bbc6a24a5e89861d5a9c2197 /main2.c
parent8872aa62ae025f607d2959ef9884afb38a625f62 (diff)
parentb7eccb556bee7d172fb1426ab51e36e441242835 (diff)
Merge branch 'master' into ipv6
Signed-off-by: fadhil riyanto <me@fadev.org>
Diffstat (limited to 'main2.c')
-rw-r--r--main2.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/main2.c b/main2.c
index 332721d..cbfe2c8 100644
--- a/main2.c
+++ b/main2.c
@@ -617,6 +617,19 @@ static int start_unpack_packet(int fd, void* reserved, struct socks5_session *so
return 1;
}
+/*
+ o X'00' succeeded
+ o X'01' general SOCKS server failure
+ o X'02' connection not allowed by ruleset
+ o X'03' Network unreachable
+ o X'04' Host unreachable
+ o X'05' Connection refused
+ o X'06' TTL expired
+ o X'07' Command not supported
+ o X'08' Address type not supported
+ o X'09' to X'FF' unassigned
+*/
+
static int create_server2server_conn(int *fdptr, int atyp, u_int8_t *addr, u_int16_t port)
{
int ret = 0;
@@ -642,8 +655,15 @@ static int create_server2server_conn(int *fdptr, int atyp, u_int8_t *addr, u_int
ret = connect(tcpfd, (struct sockaddr*)&serv_addr, len);
if (ret == -1) {
+ ret = errno;
+
perror("connect()");
- return -1;
+ log_error("errno: %d", ret);
+
+ if (ret == 111) {
+ return 3;
+ }
+ // return -1;
}
*fdptr = tcpfd;
@@ -1061,6 +1081,9 @@ static int start_unpack_packet_no_epl(int fd, void* reserved, struct socks5_sess
close(fd);
return 0;
}
+ } else {
+ socks5_send_connstate(fd, 3, next_req->atyp, next_req->dest,
+ next_req->port);
}
} else if (buf[3] == 4) {
log_info("ipv6 conn requested");