[jira] [Commented] (TS-803) Fix SOCKS breakage and allow for setting next-hop SOCKS

2016-09-19 Thread Oknet Xu (JIRA)

[ 
https://issues.apache.org/jira/browse/TS-803?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15502680#comment-15502680
 ] 

Oknet Xu commented on TS-803:
-

Form my understand:

  - compare to parent http proxy server, socks proxy server as a parent proxy 
is an bottom setting
  - the socks proxy is designed to proxy all outgoing connections including 
parent http proxy server.

So we can set a socks proxy with the new API in a remap or plugin manually.

About the API name:

  - proxy/api/ts/ts.h:tsapi void TSHttpTxnParentProxySet(TSHttpTxn txnp, const 
char *hostname, int port);
  - we already have ParentProxySet API that is named without "Addr"
  - the socks proxy is not only set for HTTP protocol and it is set for a 
VConnection. Can we named it with TSVConnSocksParentSet ?

And we need more parameters for socks server: 

  - socks version
  - username (optional)
  - password (optional)



> Fix SOCKS breakage and allow for setting next-hop SOCKS
> ---
>
> Key: TS-803
> URL: https://issues.apache.org/jira/browse/TS-803
> Project: Traffic Server
>  Issue Type: New Feature
>  Components: Network, SOCKS
>Affects Versions: 3.0.0
> Environment: Wherever ATS might run
>Reporter: M. Nunberg
>
> Here is a patch I drew up a few months ago against a snapshot of ATS/2.1.7 
> unstable/git. There are some quirks here, and I'm not that sure any more what 
> this patch does exactly. However it:
> 1) Does fix SOCKS connections in general
> 2) Allows setting next-hop SOCKS proxy via the API
> Problems:
> See https://issues.apache.org/jira/browse/TS-802
> This has no effect on connections which are drawn from the connection pool, 
> as it seems ATS currently doesn't maintain unique identities for peripheral 
> connection params (source IP, SOCKS etc); i.e. this only affects new TCP 
> connections to an OS.
> diff -x '*.o' -ru tsorig/iocore/net/I_NetVConnection.h 
> tsgit217/iocore/net/I_NetVConnection.h
> --- tsorig/iocore/net/I_NetVConnection.h2011-03-09 21:43:58.0 
> +
> +++ tsgit217/iocore/net/I_NetVConnection.h2011-03-17 14:37:18.0 
> +
> @@ -120,6 +120,13 @@
>/// Version of SOCKS to use.
>unsigned char socks_version;
> +  struct {
> +  unsigned int ip;
> +  int port;
> +  char *username;
> +  char *password;
> +  } socks_override;
> +
>int socket_recv_bufsize;
>int socket_send_bufsize;
> Only in tsgit217/iocore/net: Makefile
> Only in tsgit217/iocore/net: Makefile.in
> diff -x '*.o' -ru tsorig/iocore/net/P_Socks.h tsgit217/iocore/net/P_Socks.h
> --- tsorig/iocore/net/P_Socks.h2011-03-09 21:43:58.0 +
> +++ tsgit217/iocore/net/P_Socks.h2011-03-17 13:17:20.0 +
> @@ -126,7 +126,7 @@
>unsigned char version;
>bool write_done;
> -
> +  bool manual_parent_selection;
>SocksAuthHandler auth_handler;
>unsigned char socks_cmd;
> @@ -145,7 +145,8 @@
>  SocksEntry():Continuation(NULL), netVConnection(0),
>  ip(0), port(0), server_ip(0), server_port(0), nattempts(0),
> -lerrno(0), timeout(0), version(5), write_done(false), 
> auth_handler(NULL), socks_cmd(NORMAL_SOCKS)
> +lerrno(0), timeout(0), version(5), write_done(false), 
> manual_parent_selection(false),
> +auth_handler(NULL), socks_cmd(NORMAL_SOCKS)
>{
>}
>  };
> diff -x '*.o' -ru tsorig/iocore/net/Socks.cc tsgit217/iocore/net/Socks.cc
> --- tsorig/iocore/net/Socks.cc2011-03-09 21:43:58.0 +
> +++ tsgit217/iocore/net/Socks.cc2011-03-17 13:46:07.0 +
> @@ -73,7 +73,8 @@
>nattempts = 0;
>findServer();
> -  timeout = this_ethread()->schedule_in(this, 
> HRTIME_SECONDS(netProcessor.socks_conf_stuff->server_connect_timeout));
> +//  timeout = this_ethread()->schedule_in(this, 
> HRTIME_SECONDS(netProcessor.socks_conf_stuff->server_connect_timeout));
> +  timeout = this_ethread()->schedule_in(this, HRTIME_SECONDS(5));
>write_done = false;
>  }
> @@ -81,6 +82,15 @@
>  SocksEntry::findServer()
>  {
>nattempts++;
> +  if(manual_parent_selection) {
> +  if(nattempts > 1) {
> +  //Nullify IP and PORT
> +  server_ip = -1;
> +  server_port = 0;
> +  }
> +  Debug("mndebug(Socks)", "findServer() is a noop with manual socks 
> selection");
> +  return;
> +  }
>  #ifdef SOCKS_WITH_TS
>if (nattempts == 1) {
> @@ -187,7 +197,6 @@
>  }
>  Debug("Socks", "Failed to connect to %u.%u.%u.%u:%d", 
> PRINT_IP(server_ip), server_port);
> -
>  findServer();
>  if (server_ip == (uint32_t) - 1) {
> diff -x '*.o' -ru tsorig/iocore/net/UnixNetProcessor.cc 
> tsgit217/iocore/net/UnixNetProcessor.cc
> --- tsorig/iocore/net/UnixNetProcessor.cc2011-03-09 21:43:58.0 
> +
> +++ tsgit217/iocore/net/UnixNetProcessor.cc2011-03-17 15:48:38.0 
> +
> @@ 

[jira] [Commented] (TS-803) Fix SOCKS breakage and allow for setting next-hop SOCKS

2016-09-18 Thread James Peach (JIRA)

[ 
https://issues.apache.org/jira/browse/TS-803?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15501506#comment-15501506
 ] 

James Peach commented on TS-803:


Yep, we should take it through [API 
review|https://cwiki.apache.org/confluence/display/TS/API+Review+Process]. 
Looking at the patch above, I'd recommend we call it something line 
{{TSHttpTxnSocksParentAddrSet}} since {{AddrSet}} is the naming convention we 
have for setting addresses. It should take a {{const struct sockaddr*}}.

> Fix SOCKS breakage and allow for setting next-hop SOCKS
> ---
>
> Key: TS-803
> URL: https://issues.apache.org/jira/browse/TS-803
> Project: Traffic Server
>  Issue Type: New Feature
>  Components: Network, SOCKS
>Affects Versions: 3.0.0
> Environment: Wherever ATS might run
>Reporter: M. Nunberg
>
> Here is a patch I drew up a few months ago against a snapshot of ATS/2.1.7 
> unstable/git. There are some quirks here, and I'm not that sure any more what 
> this patch does exactly. However it:
> 1) Does fix SOCKS connections in general
> 2) Allows setting next-hop SOCKS proxy via the API
> Problems:
> See https://issues.apache.org/jira/browse/TS-802
> This has no effect on connections which are drawn from the connection pool, 
> as it seems ATS currently doesn't maintain unique identities for peripheral 
> connection params (source IP, SOCKS etc); i.e. this only affects new TCP 
> connections to an OS.
> diff -x '*.o' -ru tsorig/iocore/net/I_NetVConnection.h 
> tsgit217/iocore/net/I_NetVConnection.h
> --- tsorig/iocore/net/I_NetVConnection.h2011-03-09 21:43:58.0 
> +
> +++ tsgit217/iocore/net/I_NetVConnection.h2011-03-17 14:37:18.0 
> +
> @@ -120,6 +120,13 @@
>/// Version of SOCKS to use.
>unsigned char socks_version;
> +  struct {
> +  unsigned int ip;
> +  int port;
> +  char *username;
> +  char *password;
> +  } socks_override;
> +
>int socket_recv_bufsize;
>int socket_send_bufsize;
> Only in tsgit217/iocore/net: Makefile
> Only in tsgit217/iocore/net: Makefile.in
> diff -x '*.o' -ru tsorig/iocore/net/P_Socks.h tsgit217/iocore/net/P_Socks.h
> --- tsorig/iocore/net/P_Socks.h2011-03-09 21:43:58.0 +
> +++ tsgit217/iocore/net/P_Socks.h2011-03-17 13:17:20.0 +
> @@ -126,7 +126,7 @@
>unsigned char version;
>bool write_done;
> -
> +  bool manual_parent_selection;
>SocksAuthHandler auth_handler;
>unsigned char socks_cmd;
> @@ -145,7 +145,8 @@
>  SocksEntry():Continuation(NULL), netVConnection(0),
>  ip(0), port(0), server_ip(0), server_port(0), nattempts(0),
> -lerrno(0), timeout(0), version(5), write_done(false), 
> auth_handler(NULL), socks_cmd(NORMAL_SOCKS)
> +lerrno(0), timeout(0), version(5), write_done(false), 
> manual_parent_selection(false),
> +auth_handler(NULL), socks_cmd(NORMAL_SOCKS)
>{
>}
>  };
> diff -x '*.o' -ru tsorig/iocore/net/Socks.cc tsgit217/iocore/net/Socks.cc
> --- tsorig/iocore/net/Socks.cc2011-03-09 21:43:58.0 +
> +++ tsgit217/iocore/net/Socks.cc2011-03-17 13:46:07.0 +
> @@ -73,7 +73,8 @@
>nattempts = 0;
>findServer();
> -  timeout = this_ethread()->schedule_in(this, 
> HRTIME_SECONDS(netProcessor.socks_conf_stuff->server_connect_timeout));
> +//  timeout = this_ethread()->schedule_in(this, 
> HRTIME_SECONDS(netProcessor.socks_conf_stuff->server_connect_timeout));
> +  timeout = this_ethread()->schedule_in(this, HRTIME_SECONDS(5));
>write_done = false;
>  }
> @@ -81,6 +82,15 @@
>  SocksEntry::findServer()
>  {
>nattempts++;
> +  if(manual_parent_selection) {
> +  if(nattempts > 1) {
> +  //Nullify IP and PORT
> +  server_ip = -1;
> +  server_port = 0;
> +  }
> +  Debug("mndebug(Socks)", "findServer() is a noop with manual socks 
> selection");
> +  return;
> +  }
>  #ifdef SOCKS_WITH_TS
>if (nattempts == 1) {
> @@ -187,7 +197,6 @@
>  }
>  Debug("Socks", "Failed to connect to %u.%u.%u.%u:%d", 
> PRINT_IP(server_ip), server_port);
> -
>  findServer();
>  if (server_ip == (uint32_t) - 1) {
> diff -x '*.o' -ru tsorig/iocore/net/UnixNetProcessor.cc 
> tsgit217/iocore/net/UnixNetProcessor.cc
> --- tsorig/iocore/net/UnixNetProcessor.cc2011-03-09 21:43:58.0 
> +
> +++ tsgit217/iocore/net/UnixNetProcessor.cc2011-03-17 15:48:38.0 
> +
> @@ -228,6 +228,11 @@
>!socks_conf_stuff->ip_range.match(ip))
>  #endif
>  );
> +  if(opt->socks_override.ip >= 1) {
> +  using_socks = true;
> +  Debug("mndebug", "trying to set using_socks to true");
> +  }
> +
>SocksEntry *socksEntry = NULL;
>  #endif
>NET_SUM_GLOBAL_DYN_STAT(net_connections_currently_open_stat, 1);
> @@ -242,6 +247,16 @@
>if 

[jira] [Commented] (TS-803) Fix SOCKS breakage and allow for setting next-hop SOCKS

2016-09-18 Thread Oknet Xu (JIRA)

[ 
https://issues.apache.org/jira/browse/TS-803?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15500410#comment-15500410
 ] 

Oknet Xu commented on TS-803:
-

[~jpe...@apache.org] The patch implemented a new API: TSHttpTxnSocksProxySet to 
set socks server in plugin manually. And I don't find any codes related to 
“Does fix SOCKS connections in general”.

Does it need API REVIEW if it is a new API ?

> Fix SOCKS breakage and allow for setting next-hop SOCKS
> ---
>
> Key: TS-803
> URL: https://issues.apache.org/jira/browse/TS-803
> Project: Traffic Server
>  Issue Type: New Feature
>  Components: Network, SOCKS
>Affects Versions: 3.0.0
> Environment: Wherever ATS might run
>Reporter: M. Nunberg
>
> Here is a patch I drew up a few months ago against a snapshot of ATS/2.1.7 
> unstable/git. There are some quirks here, and I'm not that sure any more what 
> this patch does exactly. However it:
> 1) Does fix SOCKS connections in general
> 2) Allows setting next-hop SOCKS proxy via the API
> Problems:
> See https://issues.apache.org/jira/browse/TS-802
> This has no effect on connections which are drawn from the connection pool, 
> as it seems ATS currently doesn't maintain unique identities for peripheral 
> connection params (source IP, SOCKS etc); i.e. this only affects new TCP 
> connections to an OS.
> diff -x '*.o' -ru tsorig/iocore/net/I_NetVConnection.h 
> tsgit217/iocore/net/I_NetVConnection.h
> --- tsorig/iocore/net/I_NetVConnection.h2011-03-09 21:43:58.0 
> +
> +++ tsgit217/iocore/net/I_NetVConnection.h2011-03-17 14:37:18.0 
> +
> @@ -120,6 +120,13 @@
>/// Version of SOCKS to use.
>unsigned char socks_version;
> +  struct {
> +  unsigned int ip;
> +  int port;
> +  char *username;
> +  char *password;
> +  } socks_override;
> +
>int socket_recv_bufsize;
>int socket_send_bufsize;
> Only in tsgit217/iocore/net: Makefile
> Only in tsgit217/iocore/net: Makefile.in
> diff -x '*.o' -ru tsorig/iocore/net/P_Socks.h tsgit217/iocore/net/P_Socks.h
> --- tsorig/iocore/net/P_Socks.h2011-03-09 21:43:58.0 +
> +++ tsgit217/iocore/net/P_Socks.h2011-03-17 13:17:20.0 +
> @@ -126,7 +126,7 @@
>unsigned char version;
>bool write_done;
> -
> +  bool manual_parent_selection;
>SocksAuthHandler auth_handler;
>unsigned char socks_cmd;
> @@ -145,7 +145,8 @@
>  SocksEntry():Continuation(NULL), netVConnection(0),
>  ip(0), port(0), server_ip(0), server_port(0), nattempts(0),
> -lerrno(0), timeout(0), version(5), write_done(false), 
> auth_handler(NULL), socks_cmd(NORMAL_SOCKS)
> +lerrno(0), timeout(0), version(5), write_done(false), 
> manual_parent_selection(false),
> +auth_handler(NULL), socks_cmd(NORMAL_SOCKS)
>{
>}
>  };
> diff -x '*.o' -ru tsorig/iocore/net/Socks.cc tsgit217/iocore/net/Socks.cc
> --- tsorig/iocore/net/Socks.cc2011-03-09 21:43:58.0 +
> +++ tsgit217/iocore/net/Socks.cc2011-03-17 13:46:07.0 +
> @@ -73,7 +73,8 @@
>nattempts = 0;
>findServer();
> -  timeout = this_ethread()->schedule_in(this, 
> HRTIME_SECONDS(netProcessor.socks_conf_stuff->server_connect_timeout));
> +//  timeout = this_ethread()->schedule_in(this, 
> HRTIME_SECONDS(netProcessor.socks_conf_stuff->server_connect_timeout));
> +  timeout = this_ethread()->schedule_in(this, HRTIME_SECONDS(5));
>write_done = false;
>  }
> @@ -81,6 +82,15 @@
>  SocksEntry::findServer()
>  {
>nattempts++;
> +  if(manual_parent_selection) {
> +  if(nattempts > 1) {
> +  //Nullify IP and PORT
> +  server_ip = -1;
> +  server_port = 0;
> +  }
> +  Debug("mndebug(Socks)", "findServer() is a noop with manual socks 
> selection");
> +  return;
> +  }
>  #ifdef SOCKS_WITH_TS
>if (nattempts == 1) {
> @@ -187,7 +197,6 @@
>  }
>  Debug("Socks", "Failed to connect to %u.%u.%u.%u:%d", 
> PRINT_IP(server_ip), server_port);
> -
>  findServer();
>  if (server_ip == (uint32_t) - 1) {
> diff -x '*.o' -ru tsorig/iocore/net/UnixNetProcessor.cc 
> tsgit217/iocore/net/UnixNetProcessor.cc
> --- tsorig/iocore/net/UnixNetProcessor.cc2011-03-09 21:43:58.0 
> +
> +++ tsgit217/iocore/net/UnixNetProcessor.cc2011-03-17 15:48:38.0 
> +
> @@ -228,6 +228,11 @@
>!socks_conf_stuff->ip_range.match(ip))
>  #endif
>  );
> +  if(opt->socks_override.ip >= 1) {
> +  using_socks = true;
> +  Debug("mndebug", "trying to set using_socks to true");
> +  }
> +
>SocksEntry *socksEntry = NULL;
>  #endif
>NET_SUM_GLOBAL_DYN_STAT(net_connections_currently_open_stat, 1);
> @@ -242,6 +247,16 @@
>if (using_socks) {
>  Debug("Socks", "Using Socks ip: %u.%u.%u.%u:%d\n", PRINT_IP(ip), port);
>  

[jira] [Commented] (TS-803) Fix SOCKS breakage and allow for setting next-hop SOCKS

2016-08-29 Thread James Peach (JIRA)

[ 
https://issues.apache.org/jira/browse/TS-803?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15446266#comment-15446266
 ] 

James Peach commented on TS-803:


[~oknet] Are you interested in taking a look at this patch?

> Fix SOCKS breakage and allow for setting next-hop SOCKS
> ---
>
> Key: TS-803
> URL: https://issues.apache.org/jira/browse/TS-803
> Project: Traffic Server
>  Issue Type: New Feature
>  Components: Network, SOCKS
>Affects Versions: 3.0.0
> Environment: Wherever ATS might run
>Reporter: M. Nunberg
>
> Here is a patch I drew up a few months ago against a snapshot of ATS/2.1.7 
> unstable/git. There are some quirks here, and I'm not that sure any more what 
> this patch does exactly. However it:
> 1) Does fix SOCKS connections in general
> 2) Allows setting next-hop SOCKS proxy via the API
> Problems:
> See https://issues.apache.org/jira/browse/TS-802
> This has no effect on connections which are drawn from the connection pool, 
> as it seems ATS currently doesn't maintain unique identities for peripheral 
> connection params (source IP, SOCKS etc); i.e. this only affects new TCP 
> connections to an OS.
> diff -x '*.o' -ru tsorig/iocore/net/I_NetVConnection.h 
> tsgit217/iocore/net/I_NetVConnection.h
> --- tsorig/iocore/net/I_NetVConnection.h2011-03-09 21:43:58.0 
> +
> +++ tsgit217/iocore/net/I_NetVConnection.h2011-03-17 14:37:18.0 
> +
> @@ -120,6 +120,13 @@
>/// Version of SOCKS to use.
>unsigned char socks_version;
> +  struct {
> +  unsigned int ip;
> +  int port;
> +  char *username;
> +  char *password;
> +  } socks_override;
> +
>int socket_recv_bufsize;
>int socket_send_bufsize;
> Only in tsgit217/iocore/net: Makefile
> Only in tsgit217/iocore/net: Makefile.in
> diff -x '*.o' -ru tsorig/iocore/net/P_Socks.h tsgit217/iocore/net/P_Socks.h
> --- tsorig/iocore/net/P_Socks.h2011-03-09 21:43:58.0 +
> +++ tsgit217/iocore/net/P_Socks.h2011-03-17 13:17:20.0 +
> @@ -126,7 +126,7 @@
>unsigned char version;
>bool write_done;
> -
> +  bool manual_parent_selection;
>SocksAuthHandler auth_handler;
>unsigned char socks_cmd;
> @@ -145,7 +145,8 @@
>  SocksEntry():Continuation(NULL), netVConnection(0),
>  ip(0), port(0), server_ip(0), server_port(0), nattempts(0),
> -lerrno(0), timeout(0), version(5), write_done(false), 
> auth_handler(NULL), socks_cmd(NORMAL_SOCKS)
> +lerrno(0), timeout(0), version(5), write_done(false), 
> manual_parent_selection(false),
> +auth_handler(NULL), socks_cmd(NORMAL_SOCKS)
>{
>}
>  };
> diff -x '*.o' -ru tsorig/iocore/net/Socks.cc tsgit217/iocore/net/Socks.cc
> --- tsorig/iocore/net/Socks.cc2011-03-09 21:43:58.0 +
> +++ tsgit217/iocore/net/Socks.cc2011-03-17 13:46:07.0 +
> @@ -73,7 +73,8 @@
>nattempts = 0;
>findServer();
> -  timeout = this_ethread()->schedule_in(this, 
> HRTIME_SECONDS(netProcessor.socks_conf_stuff->server_connect_timeout));
> +//  timeout = this_ethread()->schedule_in(this, 
> HRTIME_SECONDS(netProcessor.socks_conf_stuff->server_connect_timeout));
> +  timeout = this_ethread()->schedule_in(this, HRTIME_SECONDS(5));
>write_done = false;
>  }
> @@ -81,6 +82,15 @@
>  SocksEntry::findServer()
>  {
>nattempts++;
> +  if(manual_parent_selection) {
> +  if(nattempts > 1) {
> +  //Nullify IP and PORT
> +  server_ip = -1;
> +  server_port = 0;
> +  }
> +  Debug("mndebug(Socks)", "findServer() is a noop with manual socks 
> selection");
> +  return;
> +  }
>  #ifdef SOCKS_WITH_TS
>if (nattempts == 1) {
> @@ -187,7 +197,6 @@
>  }
>  Debug("Socks", "Failed to connect to %u.%u.%u.%u:%d", 
> PRINT_IP(server_ip), server_port);
> -
>  findServer();
>  if (server_ip == (uint32_t) - 1) {
> diff -x '*.o' -ru tsorig/iocore/net/UnixNetProcessor.cc 
> tsgit217/iocore/net/UnixNetProcessor.cc
> --- tsorig/iocore/net/UnixNetProcessor.cc2011-03-09 21:43:58.0 
> +
> +++ tsgit217/iocore/net/UnixNetProcessor.cc2011-03-17 15:48:38.0 
> +
> @@ -228,6 +228,11 @@
>!socks_conf_stuff->ip_range.match(ip))
>  #endif
>  );
> +  if(opt->socks_override.ip >= 1) {
> +  using_socks = true;
> +  Debug("mndebug", "trying to set using_socks to true");
> +  }
> +
>SocksEntry *socksEntry = NULL;
>  #endif
>NET_SUM_GLOBAL_DYN_STAT(net_connections_currently_open_stat, 1);
> @@ -242,6 +247,16 @@
>if (using_socks) {
>  Debug("Socks", "Using Socks ip: %u.%u.%u.%u:%d\n", PRINT_IP(ip), port);
>  socksEntry = socksAllocator.alloc();
> +
> +if (opt->socks_override.ip) {
> +//Needs to be done before socksEntry->init()
> +socksEntry->server_ip = 

[jira] [Commented] (TS-803) Fix SOCKS breakage and allow for setting next-hop SOCKS

2013-03-18 Thread Leif Hedstrom (JIRA)

[ 
https://issues.apache.org/jira/browse/TS-803?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13605222#comment-13605222
 ] 

Leif Hedstrom commented on TS-803:
--

Is this still being worked on?

 Fix SOCKS breakage and allow for setting next-hop SOCKS
 ---

 Key: TS-803
 URL: https://issues.apache.org/jira/browse/TS-803
 Project: Traffic Server
  Issue Type: New Feature
  Components: Network
Affects Versions: 3.0.0
 Environment: Wherever ATS might run
Reporter: M. Nunberg
 Fix For: 3.3.3


 Here is a patch I drew up a few months ago against a snapshot of ATS/2.1.7 
 unstable/git. There are some quirks here, and I'm not that sure any more what 
 this patch does exactly. However it:
 1) Does fix SOCKS connections in general
 2) Allows setting next-hop SOCKS proxy via the API
 Problems:
 See https://issues.apache.org/jira/browse/TS-802
 This has no effect on connections which are drawn from the connection pool, 
 as it seems ATS currently doesn't maintain unique identities for peripheral 
 connection params (source IP, SOCKS etc); i.e. this only affects new TCP 
 connections to an OS.
 diff -x '*.o' -ru tsorig/iocore/net/I_NetVConnection.h 
 tsgit217/iocore/net/I_NetVConnection.h
 --- tsorig/iocore/net/I_NetVConnection.h2011-03-09 21:43:58.0 
 +
 +++ tsgit217/iocore/net/I_NetVConnection.h2011-03-17 14:37:18.0 
 +
 @@ -120,6 +120,13 @@
/// Version of SOCKS to use.
unsigned char socks_version;
 +  struct {
 +  unsigned int ip;
 +  int port;
 +  char *username;
 +  char *password;
 +  } socks_override;
 +
int socket_recv_bufsize;
int socket_send_bufsize;
 Only in tsgit217/iocore/net: Makefile
 Only in tsgit217/iocore/net: Makefile.in
 diff -x '*.o' -ru tsorig/iocore/net/P_Socks.h tsgit217/iocore/net/P_Socks.h
 --- tsorig/iocore/net/P_Socks.h2011-03-09 21:43:58.0 +
 +++ tsgit217/iocore/net/P_Socks.h2011-03-17 13:17:20.0 +
 @@ -126,7 +126,7 @@
unsigned char version;
bool write_done;
 -
 +  bool manual_parent_selection;
SocksAuthHandler auth_handler;
unsigned char socks_cmd;
 @@ -145,7 +145,8 @@
  SocksEntry():Continuation(NULL), netVConnection(0),
  ip(0), port(0), server_ip(0), server_port(0), nattempts(0),
 -lerrno(0), timeout(0), version(5), write_done(false), 
 auth_handler(NULL), socks_cmd(NORMAL_SOCKS)
 +lerrno(0), timeout(0), version(5), write_done(false), 
 manual_parent_selection(false),
 +auth_handler(NULL), socks_cmd(NORMAL_SOCKS)
{
}
  };
 diff -x '*.o' -ru tsorig/iocore/net/Socks.cc tsgit217/iocore/net/Socks.cc
 --- tsorig/iocore/net/Socks.cc2011-03-09 21:43:58.0 +
 +++ tsgit217/iocore/net/Socks.cc2011-03-17 13:46:07.0 +
 @@ -73,7 +73,8 @@
nattempts = 0;
findServer();
 -  timeout = this_ethread()-schedule_in(this, 
 HRTIME_SECONDS(netProcessor.socks_conf_stuff-server_connect_timeout));
 +//  timeout = this_ethread()-schedule_in(this, 
 HRTIME_SECONDS(netProcessor.socks_conf_stuff-server_connect_timeout));
 +  timeout = this_ethread()-schedule_in(this, HRTIME_SECONDS(5));
write_done = false;
  }
 @@ -81,6 +82,15 @@
  SocksEntry::findServer()
  {
nattempts++;
 +  if(manual_parent_selection) {
 +  if(nattempts  1) {
 +  //Nullify IP and PORT
 +  server_ip = -1;
 +  server_port = 0;
 +  }
 +  Debug(mndebug(Socks), findServer() is a noop with manual socks 
 selection);
 +  return;
 +  }
  #ifdef SOCKS_WITH_TS
if (nattempts == 1) {
 @@ -187,7 +197,6 @@
  }
  Debug(Socks, Failed to connect to %u.%u.%u.%u:%d, 
 PRINT_IP(server_ip), server_port);
 -
  findServer();
  if (server_ip == (uint32_t) - 1) {
 diff -x '*.o' -ru tsorig/iocore/net/UnixNetProcessor.cc 
 tsgit217/iocore/net/UnixNetProcessor.cc
 --- tsorig/iocore/net/UnixNetProcessor.cc2011-03-09 21:43:58.0 
 +
 +++ tsgit217/iocore/net/UnixNetProcessor.cc2011-03-17 15:48:38.0 
 +
 @@ -228,6 +228,11 @@
!socks_conf_stuff-ip_range.match(ip))
  #endif
  );
 +  if(opt-socks_override.ip = 1) {
 +  using_socks = true;
 +  Debug(mndebug, trying to set using_socks to true);
 +  }
 +
SocksEntry *socksEntry = NULL;
  #endif
NET_SUM_GLOBAL_DYN_STAT(net_connections_currently_open_stat, 1);
 @@ -242,6 +247,16 @@
if (using_socks) {
  Debug(Socks, Using Socks ip: %u.%u.%u.%u:%d\n, PRINT_IP(ip), port);
  socksEntry = socksAllocator.alloc();
 +
 +if (opt-socks_override.ip) {
 +//Needs to be done before socksEntry-init()
 +socksEntry-server_ip = opt-socks_override.ip;
 +socksEntry-server_port = opt-socks_override.port;
 +socksEntry-manual_parent_selection = true;
 +   

[jira] [Commented] (TS-803) Fix SOCKS breakage and allow for setting next-hop SOCKS

2011-09-16 Thread Leif Hedstrom (JIRA)

[ 
https://issues.apache.org/jira/browse/TS-803?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13106631#comment-13106631
 ] 

Leif Hedstrom commented on TS-803:
--

Moving out again, until we can get a fresh patch :)

 Fix SOCKS breakage and allow for setting next-hop SOCKS
 ---

 Key: TS-803
 URL: https://issues.apache.org/jira/browse/TS-803
 Project: Traffic Server
  Issue Type: New Feature
  Components: Network
 Environment: Wherever ATS might run
Reporter: M. Nunberg
 Fix For: 3.1.1


 Here is a patch I drew up a few months ago against a snapshot of ATS/2.1.7 
 unstable/git. There are some quirks here, and I'm not that sure any more what 
 this patch does exactly. However it:
 1) Does fix SOCKS connections in general
 2) Allows setting next-hop SOCKS proxy via the API
 Problems:
 See https://issues.apache.org/jira/browse/TS-802
 This has no effect on connections which are drawn from the connection pool, 
 as it seems ATS currently doesn't maintain unique identities for peripheral 
 connection params (source IP, SOCKS etc); i.e. this only affects new TCP 
 connections to an OS.
 diff -x '*.o' -ru tsorig/iocore/net/I_NetVConnection.h 
 tsgit217/iocore/net/I_NetVConnection.h
 --- tsorig/iocore/net/I_NetVConnection.h2011-03-09 21:43:58.0 
 +
 +++ tsgit217/iocore/net/I_NetVConnection.h2011-03-17 14:37:18.0 
 +
 @@ -120,6 +120,13 @@
/// Version of SOCKS to use.
unsigned char socks_version;
 +  struct {
 +  unsigned int ip;
 +  int port;
 +  char *username;
 +  char *password;
 +  } socks_override;
 +
int socket_recv_bufsize;
int socket_send_bufsize;
 Only in tsgit217/iocore/net: Makefile
 Only in tsgit217/iocore/net: Makefile.in
 diff -x '*.o' -ru tsorig/iocore/net/P_Socks.h tsgit217/iocore/net/P_Socks.h
 --- tsorig/iocore/net/P_Socks.h2011-03-09 21:43:58.0 +
 +++ tsgit217/iocore/net/P_Socks.h2011-03-17 13:17:20.0 +
 @@ -126,7 +126,7 @@
unsigned char version;
bool write_done;
 -
 +  bool manual_parent_selection;
SocksAuthHandler auth_handler;
unsigned char socks_cmd;
 @@ -145,7 +145,8 @@
  SocksEntry():Continuation(NULL), netVConnection(0),
  ip(0), port(0), server_ip(0), server_port(0), nattempts(0),
 -lerrno(0), timeout(0), version(5), write_done(false), 
 auth_handler(NULL), socks_cmd(NORMAL_SOCKS)
 +lerrno(0), timeout(0), version(5), write_done(false), 
 manual_parent_selection(false),
 +auth_handler(NULL), socks_cmd(NORMAL_SOCKS)
{
}
  };
 diff -x '*.o' -ru tsorig/iocore/net/Socks.cc tsgit217/iocore/net/Socks.cc
 --- tsorig/iocore/net/Socks.cc2011-03-09 21:43:58.0 +
 +++ tsgit217/iocore/net/Socks.cc2011-03-17 13:46:07.0 +
 @@ -73,7 +73,8 @@
nattempts = 0;
findServer();
 -  timeout = this_ethread()-schedule_in(this, 
 HRTIME_SECONDS(netProcessor.socks_conf_stuff-server_connect_timeout));
 +//  timeout = this_ethread()-schedule_in(this, 
 HRTIME_SECONDS(netProcessor.socks_conf_stuff-server_connect_timeout));
 +  timeout = this_ethread()-schedule_in(this, HRTIME_SECONDS(5));
write_done = false;
  }
 @@ -81,6 +82,15 @@
  SocksEntry::findServer()
  {
nattempts++;
 +  if(manual_parent_selection) {
 +  if(nattempts  1) {
 +  //Nullify IP and PORT
 +  server_ip = -1;
 +  server_port = 0;
 +  }
 +  Debug(mndebug(Socks), findServer() is a noop with manual socks 
 selection);
 +  return;
 +  }
  #ifdef SOCKS_WITH_TS
if (nattempts == 1) {
 @@ -187,7 +197,6 @@
  }
  Debug(Socks, Failed to connect to %u.%u.%u.%u:%d, 
 PRINT_IP(server_ip), server_port);
 -
  findServer();
  if (server_ip == (uint32_t) - 1) {
 diff -x '*.o' -ru tsorig/iocore/net/UnixNetProcessor.cc 
 tsgit217/iocore/net/UnixNetProcessor.cc
 --- tsorig/iocore/net/UnixNetProcessor.cc2011-03-09 21:43:58.0 
 +
 +++ tsgit217/iocore/net/UnixNetProcessor.cc2011-03-17 15:48:38.0 
 +
 @@ -228,6 +228,11 @@
!socks_conf_stuff-ip_range.match(ip))
  #endif
  );
 +  if(opt-socks_override.ip = 1) {
 +  using_socks = true;
 +  Debug(mndebug, trying to set using_socks to true);
 +  }
 +
SocksEntry *socksEntry = NULL;
  #endif
NET_SUM_GLOBAL_DYN_STAT(net_connections_currently_open_stat, 1);
 @@ -242,6 +247,16 @@
if (using_socks) {
  Debug(Socks, Using Socks ip: %u.%u.%u.%u:%d\n, PRINT_IP(ip), port);
  socksEntry = socksAllocator.alloc();
 +
 +if (opt-socks_override.ip) {
 +//Needs to be done before socksEntry-init()
 +socksEntry-server_ip = opt-socks_override.ip;
 +socksEntry-server_port = opt-socks_override.port;
 +socksEntry-manual_parent_selection = true;
 +opt-socks_support 

[jira] [Commented] (TS-803) Fix SOCKS breakage and allow for setting next-hop SOCKS

2011-07-31 Thread Leif Hedstrom (JIRA)

[ 
https://issues.apache.org/jira/browse/TS-803?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=1307#comment-1307
 ] 

Leif Hedstrom commented on TS-803:
--

Can we get a patch against current trunk, and attached as an attachment? That'd 
make review and inclusion much easier :).

Thanks!

-- leif


 Fix SOCKS breakage and allow for setting next-hop SOCKS
 ---

 Key: TS-803
 URL: https://issues.apache.org/jira/browse/TS-803
 Project: Traffic Server
  Issue Type: New Feature
  Components: Network
 Environment: Wherever ATS might run
Reporter: M. Nunberg
 Fix For: 3.1.0


 Here is a patch I drew up a few months ago against a snapshot of ATS/2.1.7 
 unstable/git. There are some quirks here, and I'm not that sure any more what 
 this patch does exactly. However it:
 1) Does fix SOCKS connections in general
 2) Allows setting next-hop SOCKS proxy via the API
 Problems:
 See https://issues.apache.org/jira/browse/TS-802
 This has no effect on connections which are drawn from the connection pool, 
 as it seems ATS currently doesn't maintain unique identities for peripheral 
 connection params (source IP, SOCKS etc); i.e. this only affects new TCP 
 connections to an OS.
 diff -x '*.o' -ru tsorig/iocore/net/I_NetVConnection.h 
 tsgit217/iocore/net/I_NetVConnection.h
 --- tsorig/iocore/net/I_NetVConnection.h2011-03-09 21:43:58.0 
 +
 +++ tsgit217/iocore/net/I_NetVConnection.h2011-03-17 14:37:18.0 
 +
 @@ -120,6 +120,13 @@
/// Version of SOCKS to use.
unsigned char socks_version;
 +  struct {
 +  unsigned int ip;
 +  int port;
 +  char *username;
 +  char *password;
 +  } socks_override;
 +
int socket_recv_bufsize;
int socket_send_bufsize;
 Only in tsgit217/iocore/net: Makefile
 Only in tsgit217/iocore/net: Makefile.in
 diff -x '*.o' -ru tsorig/iocore/net/P_Socks.h tsgit217/iocore/net/P_Socks.h
 --- tsorig/iocore/net/P_Socks.h2011-03-09 21:43:58.0 +
 +++ tsgit217/iocore/net/P_Socks.h2011-03-17 13:17:20.0 +
 @@ -126,7 +126,7 @@
unsigned char version;
bool write_done;
 -
 +  bool manual_parent_selection;
SocksAuthHandler auth_handler;
unsigned char socks_cmd;
 @@ -145,7 +145,8 @@
  SocksEntry():Continuation(NULL), netVConnection(0),
  ip(0), port(0), server_ip(0), server_port(0), nattempts(0),
 -lerrno(0), timeout(0), version(5), write_done(false), 
 auth_handler(NULL), socks_cmd(NORMAL_SOCKS)
 +lerrno(0), timeout(0), version(5), write_done(false), 
 manual_parent_selection(false),
 +auth_handler(NULL), socks_cmd(NORMAL_SOCKS)
{
}
  };
 diff -x '*.o' -ru tsorig/iocore/net/Socks.cc tsgit217/iocore/net/Socks.cc
 --- tsorig/iocore/net/Socks.cc2011-03-09 21:43:58.0 +
 +++ tsgit217/iocore/net/Socks.cc2011-03-17 13:46:07.0 +
 @@ -73,7 +73,8 @@
nattempts = 0;
findServer();
 -  timeout = this_ethread()-schedule_in(this, 
 HRTIME_SECONDS(netProcessor.socks_conf_stuff-server_connect_timeout));
 +//  timeout = this_ethread()-schedule_in(this, 
 HRTIME_SECONDS(netProcessor.socks_conf_stuff-server_connect_timeout));
 +  timeout = this_ethread()-schedule_in(this, HRTIME_SECONDS(5));
write_done = false;
  }
 @@ -81,6 +82,15 @@
  SocksEntry::findServer()
  {
nattempts++;
 +  if(manual_parent_selection) {
 +  if(nattempts  1) {
 +  //Nullify IP and PORT
 +  server_ip = -1;
 +  server_port = 0;
 +  }
 +  Debug(mndebug(Socks), findServer() is a noop with manual socks 
 selection);
 +  return;
 +  }
  #ifdef SOCKS_WITH_TS
if (nattempts == 1) {
 @@ -187,7 +197,6 @@
  }
  Debug(Socks, Failed to connect to %u.%u.%u.%u:%d, 
 PRINT_IP(server_ip), server_port);
 -
  findServer();
  if (server_ip == (uint32_t) - 1) {
 diff -x '*.o' -ru tsorig/iocore/net/UnixNetProcessor.cc 
 tsgit217/iocore/net/UnixNetProcessor.cc
 --- tsorig/iocore/net/UnixNetProcessor.cc2011-03-09 21:43:58.0 
 +
 +++ tsgit217/iocore/net/UnixNetProcessor.cc2011-03-17 15:48:38.0 
 +
 @@ -228,6 +228,11 @@
!socks_conf_stuff-ip_range.match(ip))
  #endif
  );
 +  if(opt-socks_override.ip = 1) {
 +  using_socks = true;
 +  Debug(mndebug, trying to set using_socks to true);
 +  }
 +
SocksEntry *socksEntry = NULL;
  #endif
NET_SUM_GLOBAL_DYN_STAT(net_connections_currently_open_stat, 1);
 @@ -242,6 +247,16 @@
if (using_socks) {
  Debug(Socks, Using Socks ip: %u.%u.%u.%u:%d\n, PRINT_IP(ip), port);
  socksEntry = socksAllocator.alloc();
 +
 +if (opt-socks_override.ip) {
 +//Needs to be done before socksEntry-init()
 +socksEntry-server_ip = opt-socks_override.ip;
 +socksEntry-server_port =