<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.16.1">
</HEAD>
<BODY>
Squid with this changes is currently work in our server<BR>
<BR>
diff -ru squid-2.6.STABLE16.tproxy-freebind/src/comm.c squid-2.6.STABLE16/src/comm.c<BR>
--- squid-2.6.STABLE16.tproxy-freebind/src/comm.c 2007-12-18 09:31:55.000000000 +0200<BR>
+++ squid-2.6.STABLE16/src/comm.c 2007-04-17 12:39:56.000000000 +0300<BR>
@@ -162,7 +162,7 @@<BR>
int flags,<BR>
const char *note)<BR>
{<BR>
- return comm_openex(sock_type, proto, addr, port, flags, 0, note,0);<BR>
+ return comm_openex(sock_type, proto, addr, port, flags, 0, note);<BR>
}<BR>
<BR>
<BR>
@@ -175,8 +175,7 @@<BR>
u_short port,<BR>
int flags,<BR>
unsigned char TOS,<BR>
- const char *note,<BR>
- struct in_addr* tproxy)<BR>
+ const char *note)<BR>
{<BR>
int new_socket;<BR>
int tos = 0;<BR>
@@ -210,16 +209,6 @@<BR>
debug(5, 0) ("comm_open: setsockopt(IP_TOS) not supported on this platform\n");<BR>
#endif<BR>
}<BR>
- {<BR>
- #define IP_FREEBIND 15<BR>
- int x=1;<BR>
- if (setsockopt(new_socket, SOL_IP, IP_FREEBIND, &x, sizeof(x)) == -1) {<BR>
- debug(20, 1) ("tproxy ip ,port ERROR ASSIGN\n");<BR>
- } else if (tproxy){<BR>
- addr.s_addr = tproxy->s_addr;<BR>
- port=0;<BR>
- }<BR>
- }<BR>
/* update fdstat */<BR>
debug(5, 5) ("comm_open: FD %d is a new socket\n", new_socket);<BR>
fd_open(new_socket, FD_SOCKET, note);<BR>
diff -ru squid-2.6.STABLE16.tproxy-freebind/src/forward.c squid-2.6.STABLE16/src/forward.c<BR>
--- squid-2.6.STABLE16.tproxy-freebind/src/forward.c 2007-12-18 14:17:42.000000000 +0200<BR>
+++ squid-2.6.STABLE16/src/forward.c 2007-09-06 00:28:34.000000000 +0300<BR>
@@ -27,7 +27,7 @@<BR>
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<BR>
* GNU General Public License for more details.<BR>
*<BR>
- * You should have received a copy of theF GNU General Public License<BR>
+ * You should have received a copy of the GNU General Public License<BR>
* along with this program; if not, write to the Free Software<BR>
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.<BR>
*<BR>
@@ -556,8 +556,7 @@<BR>
0,<BR>
COMM_NONBLOCKING,<BR>
tos,<BR>
- url,<BR>
- (fwdState->request->flags.tproxy && strcmp(host,"127.0.0.2"))?( &( fwdState->src.sin_addr)):0);<BR>
+ url);<BR>
if (fd < 0) {<BR>
debug(50, 4) ("fwdConnectStart: %s\n", xstrerror());<BR>
err = errorCon(ERR_SOCKET_FAILURE, HTTP_INTERNAL_SERVER_ERROR, fwdState->request);<BR>
@@ -588,6 +587,32 @@<BR>
if (fs->peer) {<BR>
hierarchyNote(&fwdState->request->hier, fs->code, fs->peer->name);<BR>
} else {<BR>
+#if LINUX_TPROXY<BR>
+ if (fwdState->request->flags.tproxy) {<BR>
+<BR>
+ itp.v.addr.faddr.s_addr = fwdState->src.sin_addr.s_addr;<BR>
+ itp.v.addr.fport = 0;<BR>
+<BR>
+ /* If these syscalls fail then we just fallback to connecting<BR>
+ * normally by simply ignoring the errors...<BR>
+ */<BR>
+ itp.op = TPROXY_ASSIGN;<BR>
+ if (setsockopt(fd, SOL_IP, IP_TPROXY, &itp, sizeof(itp)) == -1) {<BR>
+ debug(20, 1) ("tproxy ip=%s,0x%x,port=%d ERROR ASSIGN\n",<BR>
+ inet_ntoa(itp.v.addr.faddr),<BR>
+ itp.v.addr.faddr.s_addr,<BR>
+ itp.v.addr.fport);<BR>
+ } else {<BR>
+ itp.op = TPROXY_FLAGS;<BR>
+ itp.v.flags = ITP_CONNECT;<BR>
+ if (setsockopt(fd, SOL_IP, IP_TPROXY, &itp, sizeof(itp)) == -1) {<BR>
+ debug(20, 1) ("tproxy ip=%x,port=%d ERROR CONNECT\n",<BR>
+ itp.v.addr.faddr.s_addr,<BR>
+ itp.v.addr.fport);<BR>
+ }<BR>
+ }<BR>
+ }<BR>
+#endif<BR>
hierarchyNote(&fwdState->request->hier, fs->code, fwdState->request->host);<BR>
}<BR>
commConnectStart(fd, host, port, fwdConnectDone, fwdState);<BR>
diff -ru squid-2.6.STABLE16.tproxy-freebind/src/main.c squid-2.6.STABLE16/src/main.c<BR>
--- squid-2.6.STABLE16.tproxy-freebind/src/main.c 2007-12-05 14:21:51.000000000 +0200<BR>
+++ squid-2.6.STABLE16/src/main.c 2007-08-31 16:52:10.000000000 +0300<BR>
@@ -487,13 +487,13 @@<BR>
#ifdef _SQUID_OS2_<BR>
return;<BR>
#endif<BR>
-/* if (geteuid() == 0) {<BR>
+ if (geteuid() == 0) {<BR>
debug(0, 0) ("Squid is not safe to run as root! If you must\n");<BR>
debug(0, 0) ("start Squid as root, then you must configure\n");<BR>
debug(0, 0) ("it to run as a non-priveledged user with the\n");<BR>
debug(0, 0) ("'cache_effective_user' option in the config file.\n");<BR>
fatal("Don't run Squid as root, set 'cache_effective_user'!");<BR>
- }*/<BR>
+ }<BR>
}<BR>
<BR>
static void<BR>
diff -ru squid-2.6.STABLE16.tproxy-freebind/src/protos.h squid-2.6.STABLE16/src/protos.h<BR>
--- squid-2.6.STABLE16.tproxy-freebind/src/protos.h 2007-12-18 09:26:35.000000000 +0200<BR>
+++ squid-2.6.STABLE16/src/protos.h 2007-07-15 12:52:17.000000000 +0300<BR>
@@ -160,7 +160,7 @@<BR>
extern void comm_init(void);<BR>
extern int comm_listen(int sock);<BR>
extern int comm_open(int, int, struct in_addr, u_short port, int, const char *note);<BR>
-extern int comm_openex(int, int, struct in_addr, u_short, int, unsigned char TOS, const char *,struct in_addr* );<BR>
+extern int comm_openex(int, int, struct in_addr, u_short, int, unsigned char TOS, const char *);<BR>
extern u_short comm_local_port(int fd);<BR>
<BR>
extern void commDeferFD(int fd);<BR>
diff -ru squid-2.6.STABLE16.tproxy-freebind/src/ssl.c squid-2.6.STABLE16/src/ssl.c<BR>
--- squid-2.6.STABLE16.tproxy-freebind/src/ssl.c 2007-12-18 09:27:04.000000000 +0200<BR>
+++ squid-2.6.STABLE16/src/ssl.c 2007-02-03 23:53:38.000000000 +0200<BR>
@@ -524,8 +524,7 @@<BR>
0,<BR>
COMM_NONBLOCKING,<BR>
getOutgoingTOS(request),<BR>
- url,<BR>
- 0);<BR>
+ url);<BR>
if (sock == COMM_ERROR) {<BR>
debug(26, 4) ("sslStart: Failed because we're out of sockets.\n");<BR>
err = errorCon(ERR_SOCKET_FAILURE, HTTP_INTERNAL_SERVER_ERROR, request);<BR>
<BR>
<BR>
<BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
-- <BR>
Andrey Luzgin <<A HREF="mailto:andrey@icomsw.com">andrey@icomsw.com</A>><BR>
I-com software
</TD>
</TR>
</TABLE>
</BODY>
</HTML>