From: Amos Jeffries Date: Fri, 24 Apr 2009 03:50:58 +0000 (+1200) Subject: Author: Mikio Kishi X-Git-Tag: SQUID_3_2_0_1~1044 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=232820e290235a7654ada7b1b415a6e7c1bef78d;p=thirdparty%2Fsquid.git Author: Mikio Kishi Enable TPROXY v4 spoofing of CONNECT requests with some code polish sourced from ViSolve --- diff --git a/src/forward.cc b/src/forward.cc index 5ebffc30b8..076b72aa84 100644 --- a/src/forward.cc +++ b/src/forward.cc @@ -860,12 +860,13 @@ FwdState::connectStart() debugs(17, 3, "fwdConnectStart: got outgoing addr " << outgoing << ", tos " << tos); + int flags = COMM_NONBLOCKING; if (request->flags.spoof_client_ip) { - fd = comm_openex(SOCK_STREAM, IPPROTO_TCP, outgoing, (COMM_NONBLOCKING|COMM_TRANSPARENT), tos, url); - } else { - fd = comm_openex(SOCK_STREAM, IPPROTO_TCP, outgoing, COMM_NONBLOCKING, tos, url); + flags |= COMM_TRANSPARENT; } + fd = comm_openex(SOCK_STREAM, IPPROTO_TCP, outgoing, flags, tos, url); + debugs(17, 3, "fwdConnectStart: got TCP FD " << fd); if (fd < 0) { diff --git a/src/tunnel.cc b/src/tunnel.cc index 5b6635fc46..e20ff11a25 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -636,10 +636,14 @@ tunnelStart(ClientHttpRequest * http, int64_t * size_ptr, int *status_ptr) statCounter.server.other.requests++; /* Create socket. */ IpAddress temp = getOutgoingAddr(request,NULL); + int flags = COMM_NONBLOCKING; + if (request->flags.spoof_client_ip) { + flags |= COMM_TRANSPARENT; + } sock = comm_openex(SOCK_STREAM, IPPROTO_TCP, temp, - COMM_NONBLOCKING, + flags, getOutgoingTOS(request), url);