<!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.2">
</HEAD>
<BODY>
We tried to modify forward.c in squid source like this:<BR>
<BR>
#if LINUX_TPROXY<BR>
/* hack to allow rewrite to 127.0.0.1: */<BR>
if (fwdState->request->flags.tproxy && strcmp(host,"127.0.0.1")) {<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>
#define IP_FREEBIND 15<BR>
int x=1;<BR>
if (setsockopt(fd, SOL_IP, IP_FREEBIND, &x, sizeof(x)) == -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>
<BR>
static struct sockaddr_in to_addr;<BR>
bzero(&to_addr, sizeof(struct sockaddr_in));<BR>
to_addr.sin_family = AF_INET;<BR>
to_addr.sin_port = 0;<BR>
/*statuc IP-adress of the client for testing */<BR>
if( inet_aton( "XXX.XXX.XXX.XXX", &to_addr.sin_addr ) == 0 ) { <BR>
debug(20, 1) ("tproxy fail to set to_addr.sin.addr\n");<BR>
}<BR>
/* Here it falls */<BR>
<B>if (bind(fd, (struct sockaddr *) &to_addr, sizeof(to_addr)) == -1) {</B><BR>
<B> debug(20, 1) ("tproxy fail to bind\n");</B><BR>
<B> }</B><BR>
/*<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>
<BR>
}<BR>
#endif<BR>
<BR>
We receive the message "tproxy fail to bind". <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(www.icomsw.com)
</TD>
</TR>
</TABLE>
</BODY>
</HTML>