Hello!

May I ask you to submit this patch via github Pull Request interface?

There is certainly some stuff that we could pull to fix it, and I have a
few comments
that would be either to send there.

Cheers,
Fedor.


On Tue, May 20, 2014 at 5:36 PM, Arnaud Grandville <[email protected]>wrote:

>
> I encountered several problems for compiling the s5-proxy sample under
> windows platform.
>
> I modified some files,
> the libuv dependency can't be compiled because uv_library parameter is
> missing, it's easiest to link the libuv.lib directly.
>
> diff --git a/samples/socks5-proxy/build.gyp
> b/samples/socks5-proxy/build.gyp
> index 771a1e1..cba7a00 100644
> --- a/samples/socks5-proxy/build.gyp
> +++ b/samples/socks5-proxy/build.gyp
> @@ -19,9 +19,8 @@
>  # IN THE SOFTWARE.
>
>  {
> -  'targets': [
> +    'targets': [
>      {
> -      'dependencies': ['../../uv.gyp:libuv'],
>        'target_name': 's5-proxy',
>        'type': 'executable',
>        'sources': [
> @@ -36,7 +35,12 @@
>        'conditions': [
>          ['OS=="win"', {
>            'defines': ['HAVE_UNISTD_H=0'],
> -          'sources': ['getopt.c']
> +          'sources': ['getopt.c'],
> +          'link_settings': {
> +            'libraries':
> ['-llibuv.lib','-ladvapi32.lib','-lWs2_32.lib','-lPsapi.lib','-lIphlpapi.lib'],
> +            'library_dirs': ['../../Debug/lib']
> +            },
> +          'include_dirs': ['../../include']
>          }, {
>            'defines': ['HAVE_UNISTD_H=1']
>          }]
>
>
> the binding address in main.c must be prefixed by a 'b'
> diff --git a/samples/socks5-proxy/main.c b/samples/socks5-proxy/main.c
> index 04020cb..344d1ff 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;
>
>
>
> some specific unix include must be excluded for the windows version.
> --server.c
> #if !defined(_WIN32)
> #include <netinet/in.h>  /* INET6_ADDRSTRLEN */
> #endif
>
> --getopt.c
> #if !defined(_WIN32)
> #include <unistd.h>
> #endif
>
> for the conn_timer_expire at client.c function the status parameter is no
> more need.
>
> and the last but not the least, the conn struct must be modified.
>
> In fact, the req item is reset in the conn_connect at client.c function,
> doing so result in filling the address with zero ?!?!
>
> diff --git a/samples/socks5-proxy/defs.h b/samples/socks5-proxy/defs.h
> index 99ee816..5596a5d 100644
> --- a/samples/socks5-proxy/defs.h
> +++ b/samples/socks5-proxy/defs.h
> @@ -26,10 +26,12 @@
>  #include "uv.h"
>
>  #include <assert.h>
> -#include <netinet/in.h>  /* sockaddr_in, sockaddr_in6 */
>  #include <stddef.h>      /* size_t, ssize_t */
>  #include <stdint.h>
> +#if !defined(_WIN32)
> +#include <netinet/in.h>  /* sockaddr_in, sockaddr_in6 */
>  #include <sys/socket.h>  /* 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;
>
>
>  client.c must be update to reflect the new struct
>
> diff --git a/samples/socks5-proxy/client.c b/samples/socks5-proxy/client.c
> index ae9913a..ab1f94c 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);
>  }
>
> now, i can compile the sample with this command
> python ..\..\gyp_uv.py build.gyp --generator-output=build
>
> run it
> s5-proxy.exe -b 127.0.0.1 -p 10000
>
> and test it
> curl.exe --socks5 127.0.0.1:10000 http://www.google.com
>
>
>
>
>
> Regards,
>
> Arnaud Grandville
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "libuv" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/libuv.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"libuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/d/optout.

Reply via email to