diff --git a/main.c b/main.c index f63485d..22ea01f 100644 --- a/main.c +++ b/main.c @@ -24,7 +24,7 @@ #define close(fd) closesocket(fd) #endif -#define VERSION "11" +#define VERSION "11.1" char oob_char[1] = "a"; char ip_option[1] = "\0"; @@ -243,7 +243,7 @@ struct mphdr *parse_hosts(char *buffer, size_t size) char *e = buffer, *s = buffer; for (; e <= end; e++) { - if (*e != ' ' && *e != '\n' && *e != '\r' && e != end) { + if (e != end && *e != ' ' && *e != '\n' && *e != '\r') { continue; } if (s == e) { @@ -373,6 +373,10 @@ void clear_params(void) free(s.file_ptr); s.file_ptr = 0; } + if (s.hosts != 0) { + mem_destroy(s.hosts); + s.hosts = 0; + } } free(params.dp); params.dp = 0; diff --git a/proxy.c b/proxy.c index 7200620..e4d1ecc 100644 --- a/proxy.c +++ b/proxy.c @@ -394,6 +394,12 @@ int create_conn(struct poolhd *pool, pair->in6 = dst->in6; pair->flag = FLAG_CONN; val->type = EV_IGNORE; + + if (params.debug) { + INIT_ADDR_STR((*dst)); + LOG(LOG_S, "new conn: fd=%d, addr=%s:%d\n", + val->pair->fd, ADDR_STR, ntohs(dst->in.sin_port)); + } return 0; } @@ -505,7 +511,7 @@ static inline int on_accept(struct poolhd *pool, struct eval *val) uniperror("accept"); return -1; } - LOG(LOG_L, "accept: fd=%d\n", c); + LOG(LOG_S, "accept: fd=%d\n", c); #ifndef __linux__ #ifdef _WIN32 unsigned long mode = 1; @@ -757,11 +763,6 @@ static inline int on_request(struct poolhd *pool, struct eval *val, LOG(LOG_S, "ss error: %d\n", en); return -1; } - if (params.debug) { - INIT_ADDR_STR(dst); - LOG(LOG_L, "new conn: fd=%d, addr=%s:%d\n", - val->pair->fd, ADDR_STR, ntohs(dst.in.sin_port)); - } return 0; } @@ -796,7 +797,7 @@ static inline int on_connect(struct poolhd *pool, struct eval *val, int e) void close_conn(struct poolhd *pool, struct eval *val) { - LOG(LOG_L, "close: fds=%d,%d\n", val->fd, val->pair ? val->pair->fd : -1); + LOG(LOG_S, "close: fds=%d,%d\n", val->fd, val->pair ? val->pair->fd : -1); del_event(pool, val); }