IPIntercept::NetfilterTransparent(int fd, const IPAddress &me, IPAddress &dst, int silent)
{
#if LINUX_NETFILTER
- int tmp = 0;
- /** \par
- * Try lookup for TPROXY targets. BUT, only if the FD is flagged for transparent operations. */
- if(getsockopt(fd, SOL_IP, IP_TRANSPARENT, NULL, &tmp) != 0) {
- if(!silent) {
- debugs(89, DBG_IMPORTANT, HERE << " NF getsockopt(IP_TRANSPARENT) failed on FD " << fd << ": " << xstrerror());
- last_reported = squid_curtime;
- }
- return -1;
- }
- else {
- // mark the socket for preservation of IP_TRANSPARENT
- fd_table[fd].flags.transparent = 1;
- dst = me;
- debugs(89, 9, HERE << "address: me= " << me << ", dst= " << dst);
- return 0;
- }
-
-#endif
+ /* Trust the user configured properly. If not no harm done.
+ * We will simply attempt a bind outgoing on our own IP.
+ * Maybe a port clash which will show them the problem.
+ */
+ return (fd_table[fd].flags.transparent ? 0 : -1);
+#else
return -1;
+#endif
}
// TODO split this one call into one per transparency method
}
#endif
} else if (strcmp(token, "tproxy") == 0) {
+ if(s->intercepted || s->accel) {
+ debugs(3,DBG_CRITICAL, "http(s)_port: TPROXY option requires its own interception port. It cannot be shared.");
+ self_destruct();
+ }
s->spoof_client_ip = 1;
IPInterceptor.StartTransparency();
/* Log information regarding the port modes under transparency. */
} else {
self_destruct();
}
+
+ if( s->spoof_client_ip && (s->intercepted || s->accel) ) {
+ debugs(3,DBG_CRITICAL, "http(s)_port: TPROXY option requires its own interception port. It cannot be shared.");
+ self_destruct();
+ }
}
static http_port_list *
commSetNonBlocking(sock);
-#if 0
-// AYJ: 2008-09-16 - might be a bad idea to pass this down from here.
-// if KK is right, this flag should be set on successful NatLookup
-
- if(fd_table[fd].flags.transparent == 1) {
- F->flags.transparent = 1;
- }
-#endif
+ /* IFF the socket is (tproxy) transparent, pass the flag down to allow spoofing */
+ F->flags.transparent = fd_table[fd].flags.transparent;
PROF_stop(comm_accept);
return sock;