diff --git a/samples/socks5-proxy/build.gyp b/samples/socks5-proxy/build.gyp index 771a1e146d..ca9f14c658 100644 --- a/samples/socks5-proxy/build.gyp +++ b/samples/socks5-proxy/build.gyp @@ -21,10 +21,11 @@ { 'targets': [ { - 'dependencies': ['../../uv.gyp:libuv'], - 'target_name': 's5-proxy', - 'type': 'executable', - 'sources': [ + 'variables': {'uv_library': 'static'}, + 'dependencies': ['../../uv.gyp:libuv'], + 'target_name': 's5-proxy', + 'type': 'executable', + 'sources': [ 'client.c', 'defs.h', 'main.c', diff --git a/samples/socks5-proxy/client.c b/samples/socks5-proxy/client.c index ae9913a1c6..ab1f94ca4c 100644 --- a/samples/socks5-proxy/client.c +++ b/samples/socks5-proxy/client.c @@ -95,7 +95,7 @@ static int do_kill(client_ctx *cx); static int do_almost_dead(client_ctx *cx); static int conn_cycle(const char *who, conn *a, conn *b); static void conn_timer_reset(conn *c); -static void conn_timer_expire(uv_timer_t *handle, int status); +static void conn_timer_expire(uv_timer_t *handle); static void conn_getaddrinfo(conn *c, const char *hostname); static void conn_getaddrinfo_done(uv_getaddrinfo_t *req, int status, @@ -530,7 +530,7 @@ static int do_kill(client_ctx *cx) { new_state = s_almost_dead_1; if (cx->state == s_req_lookup) { new_state = s_almost_dead_0; - uv_cancel(&cx->outgoing.t.req); + uv_cancel(&cx->outgoing.req); } conn_close(&cx->incoming); @@ -582,10 +582,8 @@ static void conn_timer_reset(conn *c) { 0)); } -static void conn_timer_expire(uv_timer_t *handle, int status) { +static void conn_timer_expire(uv_timer_t *handle) { conn *c; - - CHECK(0 == status); c = CONTAINER_OF(handle, conn, timer_handle); c->result = UV_ETIMEDOUT; do_next(c->client); @@ -599,7 +597,7 @@ static void conn_getaddrinfo(conn *c, const char *hostname) { hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; CHECK(0 == uv_getaddrinfo(c->client->sx->loop, - &c->t.addrinfo_req, + &c->addrinfo_req, conn_getaddrinfo_done, hostname, NULL, @@ -612,7 +610,7 @@ static void conn_getaddrinfo_done(uv_getaddrinfo_t *req, struct addrinfo *ai) { conn *c; - c = CONTAINER_OF(req, conn, t.addrinfo_req); + c = CONTAINER_OF(req, conn, addrinfo_req); c->result = status; if (status == 0) { @@ -635,7 +633,7 @@ static int conn_connect(conn *c) { ASSERT(c->t.addr.sa_family == AF_INET || c->t.addr.sa_family == AF_INET6); conn_timer_reset(c); - return uv_tcp_connect(&c->t.connect_req, + return uv_tcp_connect(&c->connect_req, &c->handle.tcp, &c->t.addr, conn_connect_done); @@ -648,7 +646,7 @@ static void conn_connect_done(uv_connect_t *req, int status) { return; /* Handle has been closed. */ } - c = CONTAINER_OF(req, conn, t.connect_req); + c = CONTAINER_OF(req, conn, connect_req); c->result = status; do_next(c->client); } diff --git a/samples/socks5-proxy/defs.h b/samples/socks5-proxy/defs.h index 99ee8160c8..5596a5dbdc 100644 --- a/samples/socks5-proxy/defs.h +++ b/samples/socks5-proxy/defs.h @@ -26,10 +26,12 @@ #include "uv.h" #include -#include /* sockaddr_in, sockaddr_in6 */ #include /* size_t, ssize_t */ #include +#if !defined(_WIN32) +#include /* sockaddr_in, sockaddr_in6 */ #include /* sockaddr */ +#endif struct client_ctx; @@ -59,11 +61,11 @@ typedef struct { } handle; uv_timer_t timer_handle; /* For detecting timeouts. */ uv_write_t write_req; + uv_getaddrinfo_t addrinfo_req; + uv_connect_t connect_req; + uv_req_t req; /* We only need one of these at a time so make them share memory. */ union { - uv_getaddrinfo_t addrinfo_req; - uv_connect_t connect_req; - uv_req_t req; struct sockaddr_in6 addr6; struct sockaddr_in addr4; struct sockaddr addr; diff --git a/samples/socks5-proxy/getopt.c b/samples/socks5-proxy/getopt.c index 8481b2264f..9e7cde3ffa 100644 --- a/samples/socks5-proxy/getopt.c +++ b/samples/socks5-proxy/getopt.c @@ -36,8 +36,9 @@ static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95"; #include #include #include +#if !defined(_WIN32) #include - +#endif extern const char *_getprogname(void); int opterr = 1, /* if error message should be printed */ diff --git a/samples/socks5-proxy/main.c b/samples/socks5-proxy/main.c index 04020cbd3a..344d1ff596 100644 --- a/samples/socks5-proxy/main.c +++ b/samples/socks5-proxy/main.c @@ -63,9 +63,9 @@ const char *_getprogname(void) { static void parse_opts(server_config *cf, int argc, char **argv) { int opt; - while (-1 != (opt = getopt(argc, argv, "H:hp:"))) { + while (-1 != (opt = getopt(argc, argv, "b:hp:"))) { switch (opt) { - case 'H': + case 'b': cf->bind_host = optarg; break; diff --git a/samples/socks5-proxy/server.c b/samples/socks5-proxy/server.c index 3f1ba42c9e..3267e15d38 100644 --- a/samples/socks5-proxy/server.c +++ b/samples/socks5-proxy/server.c @@ -20,7 +20,9 @@ */ #include "defs.h" +#if !defined(_WIN32) #include /* INET6_ADDRSTRLEN */ +#endif #include #include diff --git a/samples/socks5-proxy/vcbuild.bat b/samples/socks5-proxy/vcbuild.bat new file mode 100644 index 0000000000..b7462a8077 --- /dev/null +++ b/samples/socks5-proxy/vcbuild.bat @@ -0,0 +1 @@ +python ..\..\gyp_uv.py build.gyp --generator-output=build \ No newline at end of file