This is an automated email from the ASF dual-hosted git repository.
sorber pushed a commit to branch 6.2.x
in repository https://git-dual.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/6.2.x by this push:
new c7601b1 TS-2482: Should use target_addr instead of server_addr
when build socks request.
c7601b1 is described below
commit c7601b19ec1563510f126fc228257446d126027d
Author: Oknet Xu <[email protected]>
AuthorDate: Sat Aug 27 20:18:06 2016 +0800
TS-2482: Should use target_addr instead of server_addr when build socks
request.
(cherry picked from commit 15b8263f6f8cdc39b4e28ebf5d20d311ce0a0eb3)
---
iocore/net/Socks.cc | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/iocore/net/Socks.cc b/iocore/net/Socks.cc
index 9c2a9d0..d8ca123 100644
--- a/iocore/net/Socks.cc
+++ b/iocore/net/Socks.cc
@@ -56,7 +56,7 @@ SocksEntry::init(ProxyMutex *m, SocksNetVC *vc, unsigned char
socks_support, uns
SET_HANDLER(&SocksEntry::startEvent);
- ats_ip_copy(&target_addr, vc->get_local_addr());
+ ats_ip_copy(&target_addr, vc->get_remote_addr());
#ifdef SOCKS_WITH_TS
req_data.hdr = 0;
@@ -136,12 +136,9 @@ void
SocksEntry::free()
{
MUTEX_TRY_LOCK(lock, action_.mutex, this_ethread());
- if (lock.is_locked()) {
- // Socks continuation share the user's lock
- // so acquiring a lock shouldn't fail
- ink_assert(0);
- return;
- }
+ // Socks continuation share the user's lock
+ // so acquiring a lock shouldn't fail
+ ink_release_assert(lock.is_locked());
if (timeout)
timeout->cancel(this);
@@ -251,17 +248,17 @@ 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(&server_addr));
+ ts = ntohs(ats_ip_port_cast(&target_addr));
if (version == SOCKS5_VERSION) {
p[n_bytes++] = 0; // Reserved
- if (ats_is_ip4(&server_addr)) {
+ if (ats_is_ip4(&target_addr)) {
p[n_bytes++] = 1; // IPv4 addr
- memcpy(p + n_bytes, &server_addr.sin.sin_addr, 4);
+ memcpy(p + n_bytes, &target_addr.sin.sin_addr, 4);
n_bytes += 4;
- } else if (ats_is_ip6(&server_addr)) {
+ } else if (ats_is_ip6(&target_addr)) {
p[n_bytes++] = 4; // IPv6 addr
- memcpy(p + n_bytes, &server_addr.sin6.sin6_addr, TS_IP6_SIZE);
+ memcpy(p + n_bytes, &target_addr.sin6.sin6_addr, TS_IP6_SIZE);
n_bytes += TS_IP6_SIZE;
} else {
Debug("Socks", "SOCKS supports only IP addresses.");
@@ -272,9 +269,9 @@ SocksEntry::mainEvent(int event, void *data)
n_bytes += 2;
if (version == SOCKS4_VERSION) {
- if (ats_is_ip4(&server_addr)) {
+ if (ats_is_ip4(&target_addr)) {
// for socks4, ip addr is after the port
- memcpy(p + n_bytes, &server_addr.sin.sin_addr, 4);
+ memcpy(p + n_bytes, &target_addr.sin.sin_addr, 4);
n_bytes += 4;
p[n_bytes++] = 0; // NULL
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].