From 7add7134c9f39181415dd23efd64de4d2d06cd39 Mon Sep 17 00:00:00 2001 From: Ken Date: Thu, 11 Jun 2015 17:01:35 +0800 Subject: [PATCH 01/15] add comment --- src/udprelay.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/udprelay.c b/src/udprelay.c index 0318aaf..4b76701 100644 --- a/src/udprelay.c +++ b/src/udprelay.c @@ -210,6 +210,7 @@ target_send_cb(uv_udp_send_t *req, int status) { logger_log(LOG_ERR, "forward to target failed: %s", uv_strerror(status)); } uv_buf_t *buf = (uv_buf_t *)(req + 1); + // free client recv buffer free(buf->base); free(req); } From 561285a185f0f51d4caf790b7d8cf6962aea900c Mon Sep 17 00:00:00 2001 From: Ken Date: Thu, 11 Jun 2015 17:01:45 +0800 Subject: [PATCH 02/15] add log --- src/remote.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/remote.c b/src/remote.c index 74b605e..bb5ee2d 100644 --- a/src/remote.c +++ b/src/remote.c @@ -21,9 +21,13 @@ remote_timer_expire(uv_timer_t *handle) { struct remote_context *remote = handle->data; struct client_context *client = remote->client; if (verbose) { - char addrbuf[INET6_ADDRSTRLEN + 1] = {0}; - uint16_t port = ip_name(&client->addr, addrbuf, sizeof addrbuf); - logger_log(LOG_WARNING, "%s:%d <-> %s connection timeout", addrbuf, port, client->target_addr); + if (client->cmd == S5_CMD_UDP_ASSOCIATE) { + logger_log(LOG_WARNING, "udp assocation timeout"); + } else { + char addrbuf[INET6_ADDRSTRLEN + 1] = {0}; + uint16_t port = ip_name(&client->addr, addrbuf, sizeof addrbuf); + logger_log(LOG_WARNING, "%s:%d <-> %s connection timeout", addrbuf, port, client->target_addr); + } } request_ack(remote->client, S5_REP_TTL_EXPIRED); } From 892d9182960d62539711bc29b522843eea4b198a Mon Sep 17 00:00:00 2001 From: Ken Date: Thu, 11 Jun 2015 23:41:24 +0800 Subject: [PATCH 03/15] init recv buffer --- Makefile | 1 + src/udprelay.c | 90 ++++++++++++++++++++++++++------------------------ 2 files changed, 47 insertions(+), 44 deletions(-) diff --git a/Makefile b/Makefile index 59a4703..257863f 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,7 @@ endif CFLAGS = \ -Os \ + -g \ -std=gnu99 \ -Wall \ $(PLATFORM_CFLAGS) diff --git a/src/udprelay.c b/src/udprelay.c index 4b76701..5806ff7 100644 --- a/src/udprelay.c +++ b/src/udprelay.c @@ -79,61 +79,19 @@ close_target(struct target_context *target) { } } -static int -parse_target_address(const uint8_t atyp, const char *addrbuf, struct sockaddr *addr, char *host) { - int addrlen; - uint16_t portlen = 2; // network byte order port number, 2 bytes - union { - struct sockaddr addr; - struct sockaddr_in addr4; - struct sockaddr_in6 addr6; - } dest; - - memset(&dest, 0, sizeof(dest)); - - if (atyp == S5_ATYP_IPV4) { - size_t in_addr_len = sizeof(struct in_addr); // 4 bytes for IPv4 address - dest.addr4.sin_family = AF_INET; - memcpy(&dest.addr4.sin_addr, addrbuf, in_addr_len); - memcpy(&dest.addr4.sin_port, addrbuf + in_addr_len, portlen); - addrlen = 4 + portlen; - - } else if (atyp == S5_ATYP_HOST) { - uint8_t namelen = *(uint8_t *)(addrbuf); // 1 byte of name length - if (namelen > 0xFF) { - return -1; - } - memcpy(&dest.addr4.sin_port, addrbuf + 1 + namelen, portlen); - memcpy(host, addrbuf + 1, namelen); - host[namelen] = '\0'; - addrlen = 1 + namelen + portlen; - - } else if (atyp == S5_ATYP_IPV6) { - size_t in6_addr_len = sizeof(struct in6_addr); // 16 bytes for IPv6 address - memcpy(&dest.addr6.sin6_addr, addrbuf, in6_addr_len); - memcpy(&dest.addr6.sin6_port, addrbuf + in6_addr_len, portlen); - addrlen = 16 + portlen; - - } else { - return 0; - } - - memcpy(addr, &dest.addr, sizeof(*addr)); - return addrlen; -} - static void target_alloc_cb(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf) { struct target_context *target = handle->data; buf->base = malloc(suggested_size) + target->header_len; - memset(buf->base - target->header_len, 0, suggested_size); buf->len = suggested_size - target->header_len; + memset(buf->base - target->header_len, 0, suggested_size); } static void client_alloc_cb(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf) { buf->base = malloc(suggested_size); buf->len = suggested_size; + memset(buf->base, 0, suggested_size); } static void @@ -226,6 +184,7 @@ forward_to_target(struct target_context *target, uint8_t *data, ssize_t len) { logger_log(LOG_INFO, "%s:%d -> %s:%d", src, src_port, dst, dst_port); } uv_udp_send_t *write_req = malloc(sizeof(*write_req) + sizeof(uv_buf_t)); + memset(write_req, 0, sizeof(*write_req) + sizeof(uv_buf_t)); uv_buf_t *buf = (uv_buf_t *)(write_req + 1); buf->base = (char *)data; buf->len = len; @@ -252,6 +211,49 @@ resolve_target(struct target_context *target, char *addr, uint16_t port) { target->addr_query = resolver_query(ctx, addr, port, resolve_cb, target); } +static int +parse_target_address(const uint8_t atyp, const char *addrbuf, struct sockaddr *addr, char *host) { + int addrlen; + uint16_t portlen = 2; // network byte order port number, 2 bytes + union { + struct sockaddr addr; + struct sockaddr_in addr4; + struct sockaddr_in6 addr6; + } dest; + + memset(&dest, 0, sizeof(dest)); + + if (atyp == S5_ATYP_IPV4) { + size_t in_addr_len = sizeof(struct in_addr); // 4 bytes for IPv4 address + dest.addr4.sin_family = AF_INET; + memcpy(&dest.addr4.sin_addr, addrbuf, in_addr_len); + memcpy(&dest.addr4.sin_port, addrbuf + in_addr_len, portlen); + addrlen = 4 + portlen; + + } else if (atyp == S5_ATYP_HOST) { + uint8_t namelen = *(uint8_t *)(addrbuf); // 1 byte of name length + if (namelen > 0xFF) { + return -1; + } + memcpy(&dest.addr4.sin_port, addrbuf + 1 + namelen, portlen); + memcpy(host, addrbuf + 1, namelen); + host[namelen] = '\0'; + addrlen = 1 + namelen + portlen; + + } else if (atyp == S5_ATYP_IPV6) { + size_t in6_addr_len = sizeof(struct in6_addr); // 16 bytes for IPv6 address + memcpy(&dest.addr6.sin6_addr, addrbuf, in6_addr_len); + memcpy(&dest.addr6.sin6_port, addrbuf + in6_addr_len, portlen); + addrlen = 16 + portlen; + + } else { + return 0; + } + + memcpy(addr, &dest.addr, sizeof(*addr)); + return addrlen; +} + /* * * SOCKS5 UDP Request From 25147d85f10a1170f4ff613ab8075c056a5d47da Mon Sep 17 00:00:00 2001 From: Ken Date: Fri, 12 Jun 2015 16:22:59 +0800 Subject: [PATCH 04/15] thread local storage instead of global variable --- src/consumer.c | 16 ++++++++++------ src/main.c | 15 +++++++++------ src/remote.c | 17 ++++++++++++++--- src/udprelay.c | 6 +++++- 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/src/consumer.c b/src/consumer.c index f9b4ab6..566fe53 100644 --- a/src/consumer.c +++ b/src/consumer.c @@ -5,7 +5,6 @@ #include #include "uv.h" - #include "util.h" #include "common.h" #include "udprelay.h" @@ -13,6 +12,7 @@ #include "consumer.h" +extern uv_key_t thread_resolver_key; extern void close_loop(uv_loop_t *loop); static void @@ -67,8 +67,8 @@ consumer_close(uv_async_t *handle) { udprelay_close(ctx); } - struct resolver_context *res = handle->loop->data; - resolver_shutdown(res); + struct resolver_context *dns = uv_key_get(&thread_resolver_key); + resolver_shutdown(dns); } static void @@ -108,9 +108,12 @@ consumer_start(void *arg) { get_listen_handle(loop, (uv_stream_t*)&ctx->server_handle); - struct resolver_context *res = resolver_init(loop, MODE_IPV4, - ctx->nameserver_num == 0 ? NULL : ctx->nameservers, ctx->nameserver_num); - loop->data = res; + struct resolver_context *res = + resolver_init(loop, MODE_IPV4, + ctx->nameserver_num == 0 ? NULL : ctx->nameservers, ctx->nameserver_num); + + uv_key_create(&thread_resolver_key); + uv_key_set(&thread_resolver_key, res); uv_listen((uv_stream_t*)&ctx->server_handle, 128, ctx->accept_cb); @@ -123,6 +126,7 @@ consumer_start(void *arg) { close_loop(loop); free(loop); resolver_destroy(res); + uv_key_delete(&thread_resolver_key); uv_sem_post(&ctx->semaphore); } diff --git a/src/main.c b/src/main.c index 1759909..ed6aa27 100644 --- a/src/main.c +++ b/src/main.c @@ -138,8 +138,8 @@ signal_cb(uv_signal_t *handle, int signum) { uv_signal_stop(&signals[i].sig); } - struct resolver_context *res = handle->loop->data; - resolver_shutdown(res); + struct resolver_context *dns = uv_key_get(&thread_resolver_key); + resolver_shutdown(dns); struct server_context *ctx = handle->data; uv_close((uv_handle_t *)&ctx->tcp, NULL); udprelay_close(ctx); @@ -225,16 +225,19 @@ main(int argc, char *argv[]) { setup_signal(loop, signal_cb, &ctx); - struct resolver_context *res = resolver_init(loop, MODE_IPV4, - nameserver_num == 0 ? NULL : nameservers, nameserver_num); - loop->data = res; + struct resolver_context *dns = + resolver_init(loop, MODE_IPV4, + nameserver_num == 0 ? NULL : nameservers, nameserver_num); + uv_key_create(&thread_resolver_key); + uv_key_set(&thread_resolver_key, dns); udprelay_start(loop, &ctx); uv_run(loop, UV_RUN_DEFAULT); close_loop(loop); - resolver_destroy(res); + resolver_destroy(dns); + uv_key_delete(&thread_resolver_key); } else { logger_stderr("listen error: %s", uv_strerror(rc)); diff --git a/src/remote.c b/src/remote.c index bb5ee2d..1044b29 100644 --- a/src/remote.c +++ b/src/remote.c @@ -36,7 +36,7 @@ void reset_timer(struct remote_context *remote) { if (remote->timer != NULL) { remote->timer->data = remote; - uv_timer_start(remote->timer, remote_timer_expire, remote->idle_timeout, 0); + uv_timer_start(remote->timer, remote_timer_expire, remote->idle_timeout * 1000, 0); } } @@ -50,7 +50,7 @@ new_remote(uint16_t timeout) { struct remote_context *remote = malloc(sizeof(*remote)); memset(remote, 0, sizeof(*remote)); remote->timer = malloc(sizeof(uv_timer_t)); - remote->idle_timeout = timeout * 1000; + remote->idle_timeout = timeout; return remote; } @@ -143,6 +143,10 @@ resolve_cb(struct sockaddr *addr, void *data) { struct client_context *client = remote->client; if (addr == NULL) { + if (verbose) { + logger_log(LOG_ERR, "resolve %s failed: %s", + remote->client->target_addr, resolver_error(remote->addr_query)); + } remote->stage = S5_STAGE_TERMINATE; request_ack(client, S5_REP_HOST_UNREACHABLE); @@ -157,9 +161,16 @@ resolve_cb(struct sockaddr *addr, void *data) { void resolve_remote(struct remote_context *remote, char *addr, uint16_t port) { - struct resolver_context *ctx = remote->handle.handle.loop->data; + if (verbose) { + logger_log(LOG_INFO, "resolve %s", addr); + } + struct resolver_context *ctx = uv_key_get(&thread_resolver_key); remote->stage = S5_STAGE_RESOLVE; remote->addr_query = resolver_query(ctx, addr, port, resolve_cb, remote); + if (remote->addr_query == NULL) { + remote->stage = S5_STAGE_TERMINATE; + request_ack(remote->client, S5_REP_HOST_UNREACHABLE); + } } static void diff --git a/src/udprelay.c b/src/udprelay.c index 5806ff7..7b1f059 100644 --- a/src/udprelay.c +++ b/src/udprelay.c @@ -31,6 +31,7 @@ struct target_context { extern int verbose; extern uint16_t idle_timeout; +extern uv_key_t thread_resolver_key; static uv_mutex_t mutex; static struct cache *cache; @@ -207,7 +208,10 @@ resolve_cb(struct sockaddr *addr, void *data) { static void resolve_target(struct target_context *target, char *addr, uint16_t port) { - struct resolver_context *ctx = target->server_handle->loop->data; + if (verbose) { + logger_log(LOG_INFO, "resolve %s", addr); + } + struct resolver_context *ctx = uv_key_get(&thread_resolver_key); target->addr_query = resolver_query(ctx, addr, port, resolve_cb, target); } From bd02b890ccdf74b9da85824cecdb1854dbcb2ebd Mon Sep 17 00:00:00 2001 From: Ken Date: Fri, 12 Jun 2015 16:23:40 +0800 Subject: [PATCH 05/15] move log out of resolver --- src/resolver.c | 13 ++++++++----- src/resolver.h | 1 + src/socksd.h | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/resolver.c b/src/resolver.c index d20b4d3..91f72d5 100644 --- a/src/resolver.c +++ b/src/resolver.c @@ -87,11 +87,7 @@ static void dns_query_a4_cb(struct dns_ctx *dns, struct dns_rr_a4 *result, void *data) { struct dns_query *query = (struct dns_query *)data; - if (result == NULL) { - if (verbose) { - logger_log(LOG_ERR, "IPv4 resolver: %s", dns_strerror(dns_status(dns))); - } - } else if (result->dnsa4_nrr > 0) { + if (result != NULL && result->dnsa4_nrr > 0) { query->responses = realloc(query->responses, (query->response_count + result->dnsa4_nrr) * sizeof(struct sockaddr *)); query->response_count = result->dnsa4_nrr; for (int i = 0; i < result->dnsa4_nrr; i++) { @@ -101,6 +97,8 @@ dns_query_a4_cb(struct dns_ctx *dns, struct dns_rr_a4 *result, void *data) { sa->sin_port = query->port; query->responses[i] = (struct sockaddr *)sa; } + } else { + logger_stderr("dns query error......"); } free(result); @@ -274,3 +272,8 @@ resolver_cancel(struct dns_query *query) { free(query); } + +const char* +resolver_error(struct dns_query *query) { + return dns_strerror(dns_status(query->context->dns)); +} diff --git a/src/resolver.h b/src/resolver.h index 3f79138..8203961 100644 --- a/src/resolver.h +++ b/src/resolver.h @@ -24,5 +24,6 @@ struct dns_query * resolver_query(struct resolver_context *ctx, const char *host void resolver_cancel(struct dns_query *); void resolver_shutdown(struct resolver_context *rctx); void resolver_destroy(struct resolver_context *ctx); +const char* resolver_error(struct dns_query *query); #endif // for #ifndef _RESOLVER_H diff --git a/src/socksd.h b/src/socksd.h index 5177516..8905454 100644 --- a/src/socksd.h +++ b/src/socksd.h @@ -64,5 +64,6 @@ void close_loop(uv_loop_t *loop); int verbose; uint16_t idle_timeout; +uv_key_t thread_resolver_key; #endif // for #ifndef _SOCKSD_H From 84e5b6f583da92788e342c17d3ae50b91de4d700 Mon Sep 17 00:00:00 2001 From: Ken Date: Fri, 12 Jun 2015 23:20:12 +0800 Subject: [PATCH 06/15] initialize sockaddr_in --- src/resolver.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/resolver.c b/src/resolver.c index 91f72d5..5a17f1d 100644 --- a/src/resolver.c +++ b/src/resolver.c @@ -92,6 +92,7 @@ dns_query_a4_cb(struct dns_ctx *dns, struct dns_rr_a4 *result, void *data) { query->response_count = result->dnsa4_nrr; for (int i = 0; i < result->dnsa4_nrr; i++) { struct sockaddr_in *sa = (struct sockaddr_in *)malloc(sizeof(struct sockaddr_in)); + memset(sa, 0, sizeof(struct sockaddr_in)); sa->sin_family = AF_INET; sa->sin_addr = result->dnsa4_addr[i]; sa->sin_port = query->port; @@ -122,6 +123,7 @@ dns_query_a6_cb(struct dns_ctx *dns, struct dns_rr_a6 *result, void *data) { query->response_count = result->dnsa6_nrr; for (int i = 0; i < result->dnsa6_nrr; i++) { struct sockaddr_in6 *sa = (struct sockaddr_in6 *)malloc(sizeof(struct sockaddr_in6)); + memset(sa, 0, sizeof(struct sockaddr_in6)); sa->sin6_family = AF_INET6; sa->sin6_addr = result->dnsa6_addr[i]; sa->sin6_port = query->port; From a329c434dc6fb87ef9b949665102a53b2f94c7e2 Mon Sep 17 00:00:00 2001 From: Ken Date: Fri, 12 Jun 2015 23:20:30 +0800 Subject: [PATCH 07/15] update log --- src/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client.c b/src/client.c index 596bfab..341bd8c 100644 --- a/src/client.c +++ b/src/client.c @@ -282,7 +282,7 @@ client_send_cb(uv_write_t *req, int status) { } else { char addrbuf[INET6_ADDRSTRLEN + 1] = {0}; uint16_t port = ip_name(&client->addr, addrbuf, sizeof addrbuf); - logger_log(LOG_ERR, "%s -> %s:%d failed: %s", client->target_addr, addrbuf, port, uv_strerror(status)); + logger_log(LOG_ERR, "%s:%d <- %s failed: %s", addrbuf, port, client->target_addr, uv_strerror(status)); } free(req); From a84242ad980899091b06f96fd8d8f7abcef51e90 Mon Sep 17 00:00:00 2001 From: Ken Date: Sat, 13 Jun 2015 15:50:31 +0800 Subject: [PATCH 08/15] remove log --- src/resolver.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/resolver.c b/src/resolver.c index 5a17f1d..c927db7 100644 --- a/src/resolver.c +++ b/src/resolver.c @@ -88,7 +88,8 @@ dns_query_a4_cb(struct dns_ctx *dns, struct dns_rr_a4 *result, void *data) { struct dns_query *query = (struct dns_query *)data; if (result != NULL && result->dnsa4_nrr > 0) { - query->responses = realloc(query->responses, (query->response_count + result->dnsa4_nrr) * sizeof(struct sockaddr *)); + query->responses = realloc(query->responses, + (query->response_count + result->dnsa4_nrr) * sizeof(struct sockaddr *)); query->response_count = result->dnsa4_nrr; for (int i = 0; i < result->dnsa4_nrr; i++) { struct sockaddr_in *sa = (struct sockaddr_in *)malloc(sizeof(struct sockaddr_in)); @@ -98,8 +99,6 @@ dns_query_a4_cb(struct dns_ctx *dns, struct dns_rr_a4 *result, void *data) { sa->sin_port = query->port; query->responses[i] = (struct sockaddr *)sa; } - } else { - logger_stderr("dns query error......"); } free(result); @@ -114,11 +113,7 @@ static void dns_query_a6_cb(struct dns_ctx *dns, struct dns_rr_a6 *result, void *data) { struct dns_query *query = (struct dns_query *)data; - if (result == NULL) { - if (verbose) { - logger_log(LOG_ERR, "IPv6 resolver: %s", dns_strerror(dns_status(dns))); - } - } else if (result->dnsa6_nrr > 0) { + if (result != NULL && result->dnsa6_nrr > 0) { query->responses = realloc(query->responses, (query->response_count + result->dnsa6_nrr) * sizeof(struct sockaddr *)); query->response_count = result->dnsa6_nrr; for (int i = 0; i < result->dnsa6_nrr; i++) { From dd96b6400837113165cdaf69cb8ceb96c1e20e82 Mon Sep 17 00:00:00 2001 From: Ken Date: Sat, 13 Jun 2015 15:51:24 +0800 Subject: [PATCH 09/15] bugfix: delete TLS key --- src/consumer.c | 9 ++++----- src/main.c | 5 +++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/consumer.c b/src/consumer.c index 566fe53..18e31a2 100644 --- a/src/consumer.c +++ b/src/consumer.c @@ -68,6 +68,7 @@ consumer_close(uv_async_t *handle) { } struct resolver_context *dns = uv_key_get(&thread_resolver_key); + assert(dns != NULL); resolver_shutdown(dns); } @@ -108,12 +109,11 @@ consumer_start(void *arg) { get_listen_handle(loop, (uv_stream_t*)&ctx->server_handle); - struct resolver_context *res = + struct resolver_context *dns = resolver_init(loop, MODE_IPV4, ctx->nameserver_num == 0 ? NULL : ctx->nameservers, ctx->nameserver_num); - uv_key_create(&thread_resolver_key); - uv_key_set(&thread_resolver_key, res); + uv_key_set(&thread_resolver_key, dns); uv_listen((uv_stream_t*)&ctx->server_handle, 128, ctx->accept_cb); @@ -125,8 +125,7 @@ consumer_start(void *arg) { close_loop(loop); free(loop); - resolver_destroy(res); - uv_key_delete(&thread_resolver_key); + resolver_destroy(dns); uv_sem_post(&ctx->semaphore); } diff --git a/src/main.c b/src/main.c index ed6aa27..4f74c72 100644 --- a/src/main.c +++ b/src/main.c @@ -172,6 +172,7 @@ init(void) { signal(SIGPIPE, SIG_IGN); resolver_prepare(nameserver_num); + uv_key_create(&thread_resolver_key); if (idle_timeout == 0) { idle_timeout = 60; @@ -228,7 +229,6 @@ main(int argc, char *argv[]) { struct resolver_context *dns = resolver_init(loop, MODE_IPV4, nameserver_num == 0 ? NULL : nameservers, nameserver_num); - uv_key_create(&thread_resolver_key); uv_key_set(&thread_resolver_key, dns); udprelay_start(loop, &ctx); @@ -237,7 +237,6 @@ main(int argc, char *argv[]) { close_loop(loop); resolver_destroy(dns); - uv_key_delete(&thread_resolver_key); } else { logger_stderr("listen error: %s", uv_strerror(rc)); @@ -277,6 +276,8 @@ main(int argc, char *argv[]) { udprelay_destroy(); + uv_key_delete(&thread_resolver_key); + if (daemon_mode) { delete_pidfile(pidfile); } From aa08ebdec8cd7a4c2e7f73d01a260621f9812f79 Mon Sep 17 00:00:00 2001 From: Ken Date: Sat, 13 Jun 2015 15:51:42 +0800 Subject: [PATCH 10/15] add log --- src/remote.c | 9 +++++---- src/udprelay.c | 49 +++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 44 insertions(+), 14 deletions(-) diff --git a/src/remote.c b/src/remote.c index 1044b29..2f99e60 100644 --- a/src/remote.c +++ b/src/remote.c @@ -24,6 +24,9 @@ remote_timer_expire(uv_timer_t *handle) { if (client->cmd == S5_CMD_UDP_ASSOCIATE) { logger_log(LOG_WARNING, "udp assocation timeout"); } else { + if (client->target_addr == NULL || strlen(client->target_addr) < 1) { + logger_stderr("client cmd: %d", client->cmd); + } char addrbuf[INET6_ADDRSTRLEN + 1] = {0}; uint16_t port = ip_name(&client->addr, addrbuf, sizeof addrbuf); logger_log(LOG_WARNING, "%s:%d <-> %s connection timeout", addrbuf, port, client->target_addr); @@ -143,10 +146,8 @@ resolve_cb(struct sockaddr *addr, void *data) { struct client_context *client = remote->client; if (addr == NULL) { - if (verbose) { - logger_log(LOG_ERR, "resolve %s failed: %s", - remote->client->target_addr, resolver_error(remote->addr_query)); - } + logger_log(LOG_ERR, "resolve %s failed: %s", + remote->client->target_addr, resolver_error(remote->addr_query)); remote->stage = S5_STAGE_TERMINATE; request_ack(client, S5_REP_HOST_UNREACHABLE); diff --git a/src/udprelay.c b/src/udprelay.c index 7b1f059..0e58637 100644 --- a/src/udprelay.c +++ b/src/udprelay.c @@ -22,7 +22,7 @@ struct target_context { struct sockaddr dest_addr; uint16_t dest_port; uv_timer_t *timer; - struct dns_query *addr_query; + struct dns_query *host_query; int header_len; uint8_t *buf; ssize_t buflen; @@ -85,14 +85,12 @@ target_alloc_cb(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf) { struct target_context *target = handle->data; buf->base = malloc(suggested_size) + target->header_len; buf->len = suggested_size - target->header_len; - memset(buf->base - target->header_len, 0, suggested_size); } static void client_alloc_cb(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf) { buf->base = malloc(suggested_size); buf->len = suggested_size; - memset(buf->base, 0, suggested_size); } static void @@ -152,7 +150,7 @@ target_recv_cb(uv_udp_t *handle, ssize_t nread, const uv_buf_t *buf, const struc uint16_t src_port = 0, dst_port = 0; src_port = ip_name(addr, src, sizeof src); dst_port = ip_name(&target->client_addr, dst, sizeof dst); - logger_log(LOG_INFO, "%s:%d -> %s:%d", src, src_port, dst, dst_port); + logger_log(LOG_INFO, "%s:%d <- %s:%d", dst, dst_port, src, src_port); } forward_to_client(target, m, mlen); @@ -184,8 +182,9 @@ forward_to_target(struct target_context *target, uint8_t *data, ssize_t len) { dst_port = ip_name(&target->dest_addr, dst, sizeof dst); logger_log(LOG_INFO, "%s:%d -> %s:%d", src, src_port, dst, dst_port); } - uv_udp_send_t *write_req = malloc(sizeof(*write_req) + sizeof(uv_buf_t)); - memset(write_req, 0, sizeof(*write_req) + sizeof(uv_buf_t)); + + ssize_t sz = sizeof(uv_udp_send_t) + sizeof(uv_buf_t); + uv_udp_send_t *write_req = malloc(sz); uv_buf_t *buf = (uv_buf_t *)(write_req + 1); buf->base = (char *)data; buf->len = len; @@ -200,9 +199,12 @@ resolve_cb(struct sockaddr *addr, void *data) { target->header_len = addr->sa_family == AF_INET ? IPV4_HEADER_LEN : IPV6_HEADER_LEN; target->dest_addr = *addr; forward_to_target(target, target->buf, target->buflen); + target->buf = NULL; + target->buflen = 0; } else { - logger_stderr("resolve failed."); + free(target->buf); + logger_log(LOG_ERR, "[udp] resolve failed: %s", resolver_error(target->host_query)); } } @@ -212,7 +214,7 @@ resolve_target(struct target_context *target, char *addr, uint16_t port) { logger_log(LOG_INFO, "resolve %s", addr); } struct resolver_context *ctx = uv_key_get(&thread_resolver_key); - target->addr_query = resolver_query(ctx, addr, port, resolve_cb, target); + target->host_query = resolver_query(ctx, addr, port, resolve_cb, target); } static int @@ -258,6 +260,26 @@ parse_target_address(const uint8_t atyp, const char *addrbuf, struct sockaddr *a return addrlen; } +static void +cache_log(uint8_t atyp, const struct sockaddr *src_addr, const struct sockaddr *dst_addr, + const char *host, uint16_t port, int hit) { + char src[INET6_ADDRSTRLEN + 1] = {0}; + char dst[INET6_ADDRSTRLEN + 1] = {0}; + uint16_t src_port = 0, dst_port = 0; + char *hint = hit ? "hit" : "miss"; + if (verbose) { + src_port = ip_name(src_addr, src, sizeof src); + if (atyp == S5_ATYP_HOST) { + logger_log(hint ? LOG_INFO : LOG_WARNING, "[udp] cache %s: %s:%d -> %s:%d", + hint, src, src_port, host, ntohs(port)); + } else { + dst_port = ip_name(dst_addr, dst, sizeof dst); + logger_log(hint ? LOG_INFO : LOG_WARNING, "[udp] cache %s: %s:%d -> %s:%d", + hint, src, src_port, dst, dst_port); + } + } +} + /* * * SOCKS5 UDP Request @@ -278,6 +300,7 @@ client_recv_cb(uv_udp_t *handle, ssize_t nread, const uv_buf_t *buf, const struc logger_log(LOG_ERR, "don't support frag: %d", frag); goto err; } + memset(&dest_addr, 0, sizeof(dest_addr)); uint8_t atyp = (uint8_t)buf->base[3]; int addrlen = parse_target_address(atyp, buf->base + 4, &dest_addr, host); if (addrlen < 1) { @@ -285,6 +308,8 @@ client_recv_cb(uv_udp_t *handle, ssize_t nread, const uv_buf_t *buf, const struc goto err; } + uint16_t port = (*(uint16_t *)(buf->base + 4 + addrlen - 2)); + char key[KEY_BYTES + 1] = {0}; md5((char*)addr, sizeof(*addr), key); @@ -293,6 +318,8 @@ client_recv_cb(uv_udp_t *handle, ssize_t nread, const uv_buf_t *buf, const struc cache_lookup(cache, key, (void *)&target); uv_mutex_unlock(&mutex); if (target == NULL) { + cache_log(atyp, addr, &dest_addr, host, port, 0); + target = new_target(); target->client_addr = *addr; target->server_handle = handle; @@ -310,11 +337,12 @@ client_recv_cb(uv_udp_t *handle, ssize_t nread, const uv_buf_t *buf, const struc uv_mutex_lock(&mutex); cache_insert(cache, target->key, (void *)target); uv_mutex_unlock(&mutex); + + } else { + cache_log(atyp, addr, &dest_addr, host, port, 1); } - target->dest_addr = dest_addr; reset_timer(target); - uint16_t port = (*(uint16_t *)(buf->base + 4 + addrlen - 2)); uint8_t *m = (uint8_t*)buf->base; ssize_t mlen = nread - 4 - addrlen; memmove(m, m + 4 + addrlen, mlen); @@ -323,6 +351,7 @@ client_recv_cb(uv_udp_t *handle, ssize_t nread, const uv_buf_t *buf, const struc case S5_ATYP_IPV4: case S5_ATYP_IPV6: + target->dest_addr = dest_addr; target->header_len = dest_addr.sa_family == AF_INET ? IPV4_HEADER_LEN : IPV6_HEADER_LEN; forward_to_target(target, m, mlen); break; From b51c7a04deb1f3e8d90540cb576e5963082e62e1 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 13 Jun 2015 22:18:38 +0800 Subject: [PATCH 11/15] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7e1d9f5..db5c4aa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ socksd ================= -a socks5 server implements [RFC 1928](http://tools.ietf.org/html/rfc1928) (SOCKS V5) +A socks5 server implements [RFC 1928](http://tools.ietf.org/html/rfc1928) (SOCKS V5) Features ------------ From c371569702010706afb521be3df1269ff5490381 Mon Sep 17 00:00:00 2001 From: Ken Date: Mon, 15 Jun 2015 16:09:43 +0800 Subject: [PATCH 12/15] remove log info --- src/remote.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/remote.c b/src/remote.c index 2f99e60..9099a37 100644 --- a/src/remote.c +++ b/src/remote.c @@ -24,9 +24,6 @@ remote_timer_expire(uv_timer_t *handle) { if (client->cmd == S5_CMD_UDP_ASSOCIATE) { logger_log(LOG_WARNING, "udp assocation timeout"); } else { - if (client->target_addr == NULL || strlen(client->target_addr) < 1) { - logger_stderr("client cmd: %d", client->cmd); - } char addrbuf[INET6_ADDRSTRLEN + 1] = {0}; uint16_t port = ip_name(&client->addr, addrbuf, sizeof addrbuf); logger_log(LOG_WARNING, "%s:%d <-> %s connection timeout", addrbuf, port, client->target_addr); From 2ba4c118b3242d3e7a4f7f131747cfc5b51d76af Mon Sep 17 00:00:00 2001 From: Ken Date: Tue, 16 Jun 2015 16:47:47 +0800 Subject: [PATCH 13/15] adjust code style --- src/client.c | 58 ++++++++++++++++++++++++++++++++++++++-------------- src/main.c | 12 +++++++++++ src/remote.c | 23 ++++++++++++++------- 3 files changed, 71 insertions(+), 22 deletions(-) diff --git a/src/client.c b/src/client.c index 341bd8c..a14af37 100644 --- a/src/client.c +++ b/src/client.c @@ -56,15 +56,19 @@ verify_request(char *buf, ssize_t buflen) { struct socks5_request *req = (struct socks5_request *)buf; if (req->atyp == S5_ATYP_IPV4) { - if ((req->cmd == S5_CMD_CONNECT) && (strncmp(buf + 4, "\x0\x0\x0\x0", 4) == 0)) { + if ((req->cmd == S5_CMD_CONNECT) + && (strncmp(buf + 4, "\x0\x0\x0\x0", 4) == 0)) { return 0; } len = sizeof(struct socks5_request) + sizeof(struct in_addr) + 2; + } else if (req->atyp == S5_ATYP_HOST) { uint8_t name_len = *(uint8_t *)(req->addr); len = sizeof(struct socks5_request) + 1 + name_len + 2; + } else if (req->atyp == S5_ATYP_IPV6) { len = sizeof(struct socks5_request) + sizeof(struct in6_addr) + 2; + } else { len = 0; } @@ -80,24 +84,28 @@ analyse_request_addr(struct socks5_request *req, struct sockaddr *dest, char *de struct sockaddr_in6 addr6; } addr; int addrlen; - uint16_t portlen = 2; // network byte order port number, 2 bytes + /* network byte order port number, 2 bytes */ + uint16_t portlen = 2; memset(&addr, 0, sizeof(addr)); if (req->atyp == S5_ATYP_IPV4) { - size_t in_addr_len = sizeof(struct in_addr); // 4 bytes for IPv4 address + /* 4 bytes for IPv4 address */ + size_t in_addr_len = sizeof(struct in_addr); addr.addr4.sin_family = AF_INET; memcpy(&addr.addr4.sin_addr, req->addr, in_addr_len); memcpy(&addr.addr4.sin_port, req->addr + in_addr_len, portlen); - uv_inet_ntop(AF_INET, (const void *)(req->addr), dest_buf, INET_ADDRSTRLEN); + uv_inet_ntop(AF_INET, (const void *)(req->addr), dest_buf, + INET_ADDRSTRLEN); uint16_t port = read_size((uint8_t*)(req->addr + in_addr_len)); sprintf(dest_buf, "%s:%u", dest_buf, port); addrlen = 4; } else if (req->atyp == S5_ATYP_HOST) { - uint8_t namelen = *(uint8_t *)(req->addr); // 1 byte of name length + /* 1 byte of name length */ + uint8_t namelen = *(uint8_t *)(req->addr); if (namelen > 0xFF) { return 0; } @@ -112,11 +120,13 @@ analyse_request_addr(struct socks5_request *req, struct sockaddr *dest, char *de addrlen = 1 + namelen; } else if (req->atyp == S5_ATYP_IPV6) { - size_t in6_addr_len = sizeof(struct in6_addr); // 16 bytes for IPv6 address + /* 16 bytes for IPv6 address */ + size_t in6_addr_len = sizeof(struct in6_addr); memcpy(&addr.addr6.sin6_addr, req->addr, in6_addr_len); memcpy(&addr.addr6.sin6_port, req->addr + in6_addr_len, portlen); - uv_inet_ntop(AF_INET6, (const void *)(req->addr), dest_buf, INET_ADDRSTRLEN); + uv_inet_ntop(AF_INET6, (const void *)(req->addr), dest_buf, + INET_ADDRSTRLEN); uint16_t port = read_size((uint8_t*)(req->addr + in6_addr_len)); sprintf(dest_buf, "%s:%u", dest_buf, port); @@ -136,7 +146,8 @@ send_to_client(struct client_context *client, char *buf, int buflen) { client->write_req.data = client; uv_write_t *write_req = malloc(sizeof(*write_req)); write_req->data = client; - int rc = uv_write(write_req, &client->handle.stream, &reply, 1, client_send_cb); + int rc = uv_write(write_req, &client->handle.stream, &reply, 1, + client_send_cb); if (rc) { logger_log(LOG_ERR, "write to client error: %s", uv_strerror(rc)); } @@ -166,17 +177,23 @@ request_ack(struct client_context *client, enum s5_rep rep) { buf[2] = 0x00; // RSV memset(&addr, 0, sizeof(addr)); + if (client->cmd == S5_CMD_UDP_ASSOCIATE) { - uv_tcp_getsockname(&client->handle.tcp, (struct sockaddr *) &addr, &addrlen); + uv_tcp_getsockname(&client->handle.tcp, (struct sockaddr *) &addr, + &addrlen); + } else { - uv_tcp_getsockname(&remote->handle.tcp, (struct sockaddr *) &addr, &addrlen); + uv_tcp_getsockname(&remote->handle.tcp, (struct sockaddr *) &addr, + &addrlen); } + if (addrlen == sizeof(struct sockaddr_in6)) { buf[3] = 0x04; /* atyp - IPv6. */ const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *)&addr; memcpy(buf + 4, &addr6->sin6_addr, 16); /* BND.ADDR */ memcpy(buf + 20, &addr6->sin6_port, 2); /* BND.PORT */ buflen = 22; + } else { buf[3] = 0x01; /* atyp - IPv4. */ const struct sockaddr_in *addr4 = (const struct sockaddr_in *)&addr; @@ -191,6 +208,7 @@ request_ack(struct client_context *client, enum s5_rep rep) { } else { client->stage = S5_STAGE_UDP_RELAY; } + } else { client->stage = S5_STAGE_TERMINATE; } @@ -221,7 +239,8 @@ request_start(struct client_context *client, char *buf, ssize_t buflen) { client->cmd = request->cmd; - if (request->cmd != S5_CMD_CONNECT && request->cmd != S5_CMD_UDP_ASSOCIATE) { + if (request->cmd != S5_CMD_CONNECT && + request->cmd != S5_CMD_UDP_ASSOCIATE) { logger_log(LOG_ERR, "unsupported cmd: 0x%02x", request->cmd); request_ack(client, S5_REP_CMD_NOT_SUPPORTED); return; @@ -233,7 +252,8 @@ request_start(struct client_context *client, char *buf, ssize_t buflen) { } char host[256] = {0}; - int addrlen = analyse_request_addr(request, &remote->addr, client->target_addr, host); + int addrlen = analyse_request_addr(request, &remote->addr, + client->target_addr, host); if (addrlen < 1) { logger_log(LOG_ERR, "unsupported address type: 0x%02x", request->atyp); request_ack(client, S5_REP_ADDRESS_TYPE_NOT_SUPPORTED); @@ -274,6 +294,7 @@ client_send_cb(uv_write_t *req, int status) { if (client->stage == S5_STAGE_FORWARD) { reset_timer(remote); receive_from_remote(remote); + } else if (client->stage == S5_STAGE_TERMINATE) { close_client(client); close_remote(remote); @@ -282,7 +303,8 @@ client_send_cb(uv_write_t *req, int status) { } else { char addrbuf[INET6_ADDRSTRLEN + 1] = {0}; uint16_t port = ip_name(&client->addr, addrbuf, sizeof addrbuf); - logger_log(LOG_ERR, "%s:%d <- %s failed: %s", addrbuf, port, client->target_addr, uv_strerror(status)); + logger_log(LOG_ERR, "%s:%d <- %s failed: %s", addrbuf, port, + client->target_addr, uv_strerror(status)); } free(req); @@ -295,6 +317,7 @@ client_recv_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) { if (nread > 0) { switch (client->stage) { + case S5_STAGE_HANDSHAKE: if (verify_methods(buf->base, nread)) { handshake(client); @@ -304,6 +327,7 @@ client_recv_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) { close_remote(remote); } break; + case S5_STAGE_REQUEST: if (verify_request(buf->base, nread)) { request_start(client, buf->base, nread); @@ -313,10 +337,12 @@ client_recv_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) { close_remote(remote); } break; + case S5_STAGE_FORWARD: uv_read_stop(&client->handle.stream); forward_to_remote(remote, buf->base, nread); break; + default: break; } @@ -325,7 +351,8 @@ client_recv_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) { if (nread != UV_EOF) { char addrbuf[INET6_ADDRSTRLEN + 1] = {0}; uint16_t port = ip_name(&client->addr, addrbuf, sizeof addrbuf); - logger_log(LOG_ERR, "receive from %s:%d failed: %s", addrbuf, port, uv_strerror(nread)); + logger_log(LOG_ERR, "receive from %s:%d failed: %s", addrbuf, port, + uv_strerror(nread)); } close_client(client); close_remote(remote); @@ -350,7 +377,8 @@ client_accept_cb(uv_stream_t *server, int status) { uv_tcp_getpeername(&client->handle.tcp, &client->addr, &namelen); reset_timer(remote); client->handle.stream.data = client; - rc = uv_read_start(&client->handle.stream, client_alloc_cb, client_recv_cb); + rc = uv_read_start(&client->handle.stream, client_alloc_cb, + client_recv_cb); } else { logger_log(LOG_ERR, "accept error: %s", uv_strerror(rc)); close_client(client); diff --git a/src/main.c b/src/main.c index 4f74c72..366ccdf 100644 --- a/src/main.c +++ b/src/main.c @@ -67,32 +67,41 @@ parse_opts(int argc, char *argv[]) { int opt = 0, longindex = 0; while ((opt = getopt_long(argc, argv, _optString, _lopts, &longindex)) != -1) { + switch (opt) { + case 'v': printf("socksd version: %s \n", SOCKSD_VER); exit(0); break; + case 'h': case '?': print_usage(argv[0]); break; + case 'l': local_addrbuf = optarg; break; + case 'c': concurrency = strtol(optarg, NULL, 10); break; + case 'd': if (nameserver_num < MAX_DNS_NUM) { nameservers[nameserver_num++] = optarg; } break; + case 'p': pidfile = optarg; break; + case 'n': daemon_mode = 0; break; + case 's': xsignal = optarg; if (strcmp(xsignal, "stop") == 0 @@ -102,12 +111,15 @@ parse_opts(int argc, char *argv[]) { fprintf(stderr, "invalid option: -s %s\n", xsignal); print_usage(argv[0]); break; + case 't': idle_timeout = strtol(optarg, NULL, 10); break; + case 'V': verbose = 1; break; + default: print_usage(argv[0]); break; diff --git a/src/remote.c b/src/remote.c index 9099a37..f11ac64 100644 --- a/src/remote.c +++ b/src/remote.c @@ -26,7 +26,8 @@ remote_timer_expire(uv_timer_t *handle) { } else { char addrbuf[INET6_ADDRSTRLEN + 1] = {0}; uint16_t port = ip_name(&client->addr, addrbuf, sizeof addrbuf); - logger_log(LOG_WARNING, "%s:%d <-> %s connection timeout", addrbuf, port, client->target_addr); + logger_log(LOG_WARNING, "%s:%d <-> %s connection timeout", addrbuf, + port, client->target_addr); } } request_ack(remote->client, S5_REP_TTL_EXPIRED); @@ -105,9 +106,11 @@ remote_connect_cb(uv_connect_t *req, int status) { request_ack(client, S5_REP_SUCCESSED); remote->handle.stream.data = remote; uv_read_start(&remote->handle.stream, remote_alloc_cb, remote_recv_cb); + } else { if (status != UV_ECANCELED) { - logger_log(LOG_ERR, "connect to %s failed: %s", client->target_addr, uv_strerror(status)); + logger_log(LOG_ERR, "connect to %s failed: %s", client->target_addr, + uv_strerror(status)); request_ack(client, S5_REP_HOST_UNREACHABLE); } } @@ -123,16 +126,19 @@ void forward_to_remote(struct remote_context *remote, char *buf, int buflen) { uv_buf_t request = uv_buf_init(buf, buflen); remote->write_req.data = remote; - uv_write(&remote->write_req, &remote->handle.stream, &request, 1, remote_send_cb); + uv_write(&remote->write_req, &remote->handle.stream, &request, 1, + remote_send_cb); } void connect_to_remote(struct remote_context *remote) { remote->stage = S5_STAGE_CONNECT; remote->connect_req.data = remote; - int rc = uv_tcp_connect(&remote->connect_req, &remote->handle.tcp, &remote->addr, remote_connect_cb); + int rc = uv_tcp_connect(&remote->connect_req, &remote->handle.tcp, + &remote->addr, remote_connect_cb); if (rc) { - logger_log(LOG_ERR, "connect to %s error: %s", remote->client->target_addr, uv_strerror(rc)); + logger_log(LOG_ERR, "connect to %s error: %s", + remote->client->target_addr, uv_strerror(rc)); request_ack(remote->client, S5_REP_NETWORK_UNREACHABLE); } } @@ -184,7 +190,8 @@ remote_send_cb(uv_write_t *req, int status) { if (verbose) { char addrbuf[INET6_ADDRSTRLEN + 1] = {0}; uint16_t port = ip_name(&client->addr, addrbuf, sizeof addrbuf); - logger_log(LOG_ERR, "%s:%d -> failed: %s", addrbuf, port, client->target_addr, uv_strerror(status)); + logger_log(LOG_ERR, "%s:%d -> failed: %s", addrbuf, port, + client->target_addr, uv_strerror(status)); } } } @@ -200,9 +207,11 @@ remote_recv_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) { if (nread > 0) { uv_read_stop(&remote->handle.stream); forward_to_client(client, buf->base, nread); + } else if (nread < 0){ if (nread != UV_EOF && verbose) { - logger_log(LOG_ERR, "receive from %s failed: %s", client->target_addr, uv_strerror(nread)); + logger_log(LOG_ERR, "receive from %s failed: %s", + client->target_addr, uv_strerror(nread)); } close_client(client); close_remote(remote); From 071217bf9bedf9687a2cabb9f33f8d7994405dff Mon Sep 17 00:00:00 2001 From: Ken Date: Sun, 30 Aug 2015 18:12:31 +0800 Subject: [PATCH 14/15] minor fix --- LICENSE | 2 +- Makefile | 5 ----- README.md | 2 +- config.mk | 7 ------- src/main.c | 2 +- 5 files changed, 3 insertions(+), 15 deletions(-) diff --git a/LICENSE b/LICENSE index 76411d0..6e73c8e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014-2015 Ken +Copyright (c) 2014-2015 lparam Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/Makefile b/Makefile index 257863f..85288ef 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,3 @@ -# -# (C) Copyright 2000-2015 -# Ken -# - MAJOR = 0 MINOR = 2 PATCH = 0 diff --git a/README.md b/README.md index db5c4aa..31de2b2 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Features The MIT License (MIT) -Copyright (c) 2014-2015 Ken +Copyright (c) 2014-2015 lparam Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/config.mk b/config.mk index e603af7..fc57d55 100644 --- a/config.mk +++ b/config.mk @@ -1,9 +1,3 @@ -# -# (C) Copyright 2000-2015 -# Ken -# - -######################################################################### ifneq ($(OBJTREE),$(SRCTREE)) ifeq ($(CURDIR),$(SRCTREE)) @@ -81,4 +75,3 @@ endif $(obj)%.o: %.c $(shell [ -d $(dir $@) ] || mkdir -p $(dir $@)) $(CCC) -c $< -o $(cobj) - diff --git a/src/main.c b/src/main.c index 366ccdf..0b2892e 100644 --- a/src/main.c +++ b/src/main.c @@ -45,7 +45,7 @@ static const struct option _lopts[] = { static void print_usage(const char *prog) { - printf("socksd Version: %s Maintained by Ken \n", SOCKSD_VER); + printf("socksd Version: %s Maintained by lparam\n", SOCKSD_VER); printf("Usage: %s [-l bind] [-p pidfile] [-c concurrency] [-t timeout] -s [signal] [-nhvV]\n\n", prog); printf("Options:\n"); puts(" -h, --help\t\t : this help\n" From e2c9f289bc92a7b53b7090a26c6a9393fd3e99d2 Mon Sep 17 00:00:00 2001 From: lparam Date: Tue, 8 Sep 2015 15:06:00 +0800 Subject: [PATCH 15/15] Bumped verbion 0.2.1 --- CHANGES.md | 5 +++++ Makefile | 2 +- src/socksd.h | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 171a6b3..f41997b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,8 @@ +v0.2.1 (2015-9-08) +----------- +* Change: Minor fix + + v0.2.0 (2015-5-11) ----------- * Feature: Support UDP relay diff --git a/Makefile b/Makefile index 85288ef..5a5b05c 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ MAJOR = 0 MINOR = 2 -PATCH = 0 +PATCH = 1 NAME = socksd ifdef O diff --git a/src/socksd.h b/src/socksd.h index 8905454..254988b 100644 --- a/src/socksd.h +++ b/src/socksd.h @@ -7,7 +7,7 @@ #include "resolver.h" -#define SOCKSD_VERSION "0.2.0" +#define SOCKSD_VERSION "0.2.1" #define SOCKSD_VER "socksd/" SOCKSD_VERSION