From 86c2b2d9a6afa2b2d07b725704bf22a13be110e8 Mon Sep 17 00:00:00 2001 From: Quentin Date: Sun, 15 Sep 2019 11:18:43 +0200 Subject: [PATCH] Better log socks5 to find infinite loop source --- src/socks5.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/socks5.c b/src/socks5.c index 8f1f5b0..46c996e 100644 --- a/src/socks5.c +++ b/src/socks5.c @@ -241,6 +241,7 @@ int on_socks5_recv_server_reply(struct evt_core_ctx* ctx, struct evt_core_fdinfo // Read headers if (s5ctx->sr_cursor < fixed_headers_size) { + printf(" [socks5] read headers\n"); readn = read(fdinfo->fd, (char*)&s5ctx->sr + s5ctx->sr_cursor, fixed_headers_size - s5ctx->sr_cursor); if (readn == -1 && errno == EAGAIN) return 1; if (readn < 0) goto move_to_failed; @@ -250,6 +251,7 @@ int on_socks5_recv_server_reply(struct evt_core_ctx* ctx, struct evt_core_fdinfo // Read host if (!s5ctx->sr_host_read) { + printf(" [socks5] read host\n"); if (s5ctx->sr.atyp == ATYP_IPV4) return socks5_server_reply_atyp_ipv4(ctx, fdinfo); else if (s5ctx->sr.atyp == ATYP_IPV6) return socks5_server_reply_atyp_ipv6(ctx, fdinfo); else if (s5ctx->sr.atyp == ATYP_DOMAINNAME) return socks5_server_reply_atyp_dn(ctx, fdinfo); @@ -259,6 +261,7 @@ int on_socks5_recv_server_reply(struct evt_core_ctx* ctx, struct evt_core_fdinfo // Read port size_t final_size = socks5_server_reply_size(&s5ctx->sr); if (s5ctx->sr_cursor < final_size) { + printf(" [socks5] read port\n"); size_t relative_cursor = s5ctx->sr_cursor - (final_size - sizeof(s5ctx->sr.port)); readn = read(fdinfo->fd, (char*)&s5ctx->sr.port + relative_cursor, sizeof(s5ctx->sr.port) - relative_cursor); if (readn == -1 && errno == EAGAIN) return 1;