Fix parsing bug
This commit is contained in:
parent
3a3e61aac5
commit
0e03e02e31
2 changed files with 9 additions and 7 deletions
|
@ -33,11 +33,6 @@ int faketor_socks5_server_success(struct evt_core_ctx* ctx, struct evt_core_fdin
|
|||
printf("success!\n");
|
||||
struct socks5_ctx *s5ctx = fdinfo->other;
|
||||
|
||||
char buffer[1024];
|
||||
sprintf(buffer, "socket:%s:%d", s5ctx->cr.dest_addr.dns.str, s5ctx->cr.port);
|
||||
|
||||
evt_core_fdinfo_url_set(fdinfo, buffer);
|
||||
printf("new socket name: %s\n", fdinfo->url);
|
||||
return EVT_CORE_FD_EXHAUSTED;
|
||||
}
|
||||
|
||||
|
|
11
src/socks5.c
11
src/socks5.c
|
@ -435,7 +435,7 @@ int on_socks5_server_recv_client_req(struct evt_core_ctx* ctx, struct evt_core_f
|
|||
size_t to_read = 0;
|
||||
|
||||
size_t fixed_size = ((void*)&s5ctx->cr.dest_addr) - ((void*)&s5ctx->cr);
|
||||
if (s5ctx->cr_cursor < fixed_size) {
|
||||
if (s5ctx->cr.atyp == 0x00) {
|
||||
to_read = fixed_size - s5ctx->cr_cursor;
|
||||
nread = recv(fdinfo->fd, ((void*)&s5ctx->cr) + s5ctx->cr_cursor, to_read, 0);
|
||||
if (nread == -1 && errno == EAGAIN) return EVT_CORE_FD_EXHAUSTED;
|
||||
|
@ -451,7 +451,7 @@ int on_socks5_server_recv_client_req(struct evt_core_ctx* ctx, struct evt_core_f
|
|||
if (nread == -1 && errno == EAGAIN) return EVT_CORE_FD_EXHAUSTED;
|
||||
if (nread == -1) goto recv_client_req_error;
|
||||
s5ctx->cr_cursor += nread;
|
||||
if (to_read == nread) {
|
||||
if (s5ctx->cr_cursor >= sizeof(s5ctx->cr.dest_addr.dns.len) + s5ctx->cr.dest_addr.dns.len) {
|
||||
s5ctx->cr_host_read = TRUE;
|
||||
s5ctx->cr_cursor = 0;
|
||||
} else return EVT_CORE_FD_UNFINISHED;
|
||||
|
@ -484,6 +484,13 @@ int on_socks5_server_recv_client_req(struct evt_core_ctx* ctx, struct evt_core_f
|
|||
s5ctx->cr_cursor += nread;
|
||||
if (to_read != nread) return EVT_CORE_FD_UNFINISHED;
|
||||
|
||||
char buffer[1024];
|
||||
if (s5ctx->cr.atyp == ATYP_DOMAINNAME) {
|
||||
sprintf(buffer, "socket:%s:%d", s5ctx->cr.dest_addr.dns.str, ntohs(s5ctx->cr.port));
|
||||
evt_core_fdinfo_url_set(fdinfo, buffer);
|
||||
printf("new socket name: %s\n", fdinfo->url);
|
||||
}
|
||||
|
||||
printf("[%s][socks5] received client request atyp=%s\n", current_human_datetime (), atyp_str[s5ctx->cr.atyp]);
|
||||
evt_core_mv_fd2 (ctx, fdinfo, "socks5-server-send-server-reply");
|
||||
return EVT_CORE_FD_EXHAUSTED;
|
||||
|
|
Loading…
Reference in a new issue