Browse Source

fix bugs

pull/1/head
Max Lv 12 years ago
parent
commit
adce8f681c
1 changed files with 4 additions and 11 deletions
  1. 15
      local.c

15
local.c

@ -109,7 +109,7 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) {
int *buf_len = &remote->buf_len; int *buf_len = &remote->buf_len;
if (server->stage != 5) { if (server->stage != 5) {
buf = server->buf; buf = server->buf;
buf_len = server->buf_len;
buf_len = &server->buf_len;
} }
while (1) { while (1) {
@ -197,16 +197,9 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) {
if (request->atyp == 1) { if (request->atyp == 1) {
// IP V4 // IP V4
struct in_addr *in_addr;
in_addr = (struct in_addr *)(server->buf + 4);
char* addr_buf = inet_ntoa(*in_addr);
unsigned char name_len = strlen(addr_buf);
memcpy(addr_to_send + addr_len, addr_buf, name_len);
addr_len += name_len;
// get port
addr_to_send[addr_len++] = *(unsigned char *)(server->buf + 4 + 4);
addr_to_send[addr_len++] = *(unsigned char *)(server->buf + 4 + 4 + 1);
size_t in_addr_len = sizeof(struct in_addr);
memcpy(addr_to_send + addr_len, server->buf + 4, in_addr_len + 2);
addr_len += in_addr_len + 2;
addr_to_send[addr_len] = 0; addr_to_send[addr_len] = 0;
} else if (request->atyp == 3) { } else if (request->atyp == 3) {

Loading…
Cancel
Save