diff --git a/src/local.c b/src/local.c index 675b48a0..e14d0b50 100644 --- a/src/local.c +++ b/src/local.c @@ -353,7 +353,7 @@ server_handshake(EV_P_ ev_io *w, buffer_t *buf) } return server_handshake_reply(EV_A_ w, 1, &response); } else if (request->cmd != SOCKS5_CMD_CONNECT) { - LOGE("unsupported cmd: %d", request->cmd); + LOGE("unsupported command: %d", request->cmd); response.rep = SOCKS5_REP_CMD_NOT_SUPPORTED; char *send_buf = (char *)&response; send(server->fd, send_buf, 4, 0); @@ -876,6 +876,13 @@ server_recv_cb(EV_P_ ev_io *w, int revents) // all processed return; } else if (server->stage == STAGE_INIT) { + if(verbose) { + struct sockaddr_in peer_addr; + socklen_t peer_addr_len = sizeof peer_addr; + if(getpeername(server->fd, (struct sockaddr *)&peer_addr, &peer_addr_len) == 0) { + LOGI("connection from %s:%hu", inet_ntoa(peer_addr.sin_addr), ntohs(peer_addr.sin_port)); + } + } if (buf->len < 1) return; if (buf->data[0] != SVERSION) { @@ -1359,6 +1366,11 @@ create_remote(listen_ctx_t *listener, memcpy(&(remote->addr), remote_addr, remote->addr_len); remote->direct = direct; + if(verbose) { + struct sockaddr_in *sockaddr = (struct sockaddr_in *)&remote->addr; + LOGI("remote: %s:%hu", inet_ntoa(sockaddr->sin_addr), ntohs(sockaddr->sin_port)); + } + return remote; } @@ -1685,12 +1697,22 @@ main(int argc, char **argv) } } - if (remote_num == 0 || remote_port == NULL || + if(remote_num == 0) { + fprintf(stderr, "remote_num is 0\n"); + exit(EXIT_FAILURE); + } + if(!remote_port) { + fprintf(stderr, "remote_port is NULL\n"); + exit(EXIT_FAILURE); + } #ifndef HAVE_LAUNCHD - local_port == NULL || + if(!local_port) { + fprintf(stderr, "local_port is NULL\n"); + exit(EXIT_FAILURE); + } #endif - (password == NULL && key == NULL)) { - usage(); + if(!password && !key) { + fprintf(stderr, "both password and key are NULL\n"); exit(EXIT_FAILURE); }