You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ok...@apache.org on 2016/12/23 15:08:23 UTC
[trafficserver] branch master updated: TS-5105: Do
vc->con.setRemote(target) before socksEntry->init()
This is an automated email from the ASF dual-hosted git repository.
oknet pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 25140ce TS-5105: Do vc->con.setRemote(target) before socksEntry->init()
25140ce is described below
commit 25140ce7b2d2d8214bbc22dde6a2db9144ff2693
Author: Oknet Xu <xu...@skyguard.com.cn>
AuthorDate: Fri Dec 23 13:06:22 2016 +0800
TS-5105: Do vc->con.setRemote(target) before socksEntry->init()
---
iocore/net/Socks.cc | 2 +-
iocore/net/UnixNetProcessor.cc | 8 +++++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/iocore/net/Socks.cc b/iocore/net/Socks.cc
index 825fda1..30e3855 100644
--- a/iocore/net/Socks.cc
+++ b/iocore/net/Socks.cc
@@ -248,7 +248,7 @@ SocksEntry::mainEvent(int event, void *data)
p[n_bytes++] = version;
p[n_bytes++] = (socks_cmd == NORMAL_SOCKS) ? SOCKS_CONNECT : socks_cmd;
- ts = ntohs(ats_ip_port_cast(&target_addr));
+ ts = ats_ip_port_cast(&target_addr);
if (version == SOCKS5_VERSION) {
p[n_bytes++] = 0; // Reserved
diff --git a/iocore/net/UnixNetProcessor.cc b/iocore/net/UnixNetProcessor.cc
index c3d2fa7..490d92e 100644
--- a/iocore/net/UnixNetProcessor.cc
+++ b/iocore/net/UnixNetProcessor.cc
@@ -216,11 +216,16 @@ UnixNetProcessor::connect_re_internal(Continuation *cont, sockaddr const *target
vc->submit_time = Thread::get_hrtime();
vc->mutex = cont->mutex;
Action *result = &vc->action_;
+ // Copy target to con.addr,
+ // then con.addr will copy to vc->remote_addr by set_remote_addr()
+ vc->con.setRemote(target);
if (using_socks) {
char buff[INET6_ADDRPORTSTRLEN];
Debug("Socks", "Using Socks ip: %s", ats_ip_nptop(target, buff, sizeof(buff)));
socksEntry = socksAllocator.alloc();
+ // The socksEntry->init() will get the origin server addr by vc->get_remote_addr(),
+ // and save it to socksEntry->req_data.dest_ip.
socksEntry->init(cont->mutex, vc, opt->socks_support, opt->socks_version); /*XXXX remove last two args */
socksEntry->action_ = cont;
cont = socksEntry;
@@ -229,12 +234,13 @@ UnixNetProcessor::connect_re_internal(Continuation *cont, sockaddr const *target
socksEntry->free();
return ACTION_RESULT_DONE;
}
+ // At the end of socksEntry->init(), a socks server will be selected and saved to socksEntry->server_addr.
+ // Therefore, we should set the remote to socks server in order to establish a connection with socks server.
vc->con.setRemote(&socksEntry->server_addr.sa);
result = &socksEntry->action_;
vc->action_ = socksEntry;
} else {
Debug("Socks", "Not Using Socks %d ", socks_conf_stuff->socks_needed);
- vc->con.setRemote(target);
vc->action_ = cont;
}
--
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].