--- /dev/null
+ o Minor features:
+ - Support the ipfw firewall interface for transparent proxy support on
+ FreeBSD. To enable it, set "TransProxyType ipfw" in your torrc.
+ Resolves ticket 10267; patch from "yurivict".
compatibility, TransListenAddress is only allowed when TransPort is just
a port number.)
-[[TransProxyType]] **TransProxyTYpe** **default**|**TPROXY**::
+[[TransProxyType]] **TransProxyTYpe** **default**|**TPROXY**|**ipfw**::
TransProxyType may only be enabled when there is transparent proxy listener
enabled.
+
feature can be found in the Linux kernel source tree in the file
Documentation/networking/tproxy.txt.
+
- Set this to "default", or leave it unconfigured, to use regular IPTables
- on Linux, or to use pf on the *BSD operating systems.
+ Set this option to "ipfw" to use the FreeBSD ipfw interface.
+ +
+ Set this option to "default", or leave it unconfigured, to use regular
+ IPTables on Linux, or to use pf on the *BSD operating systems.
+
(Default: "default".)
#if defined(HAVE_NET_IF_H) && defined(HAVE_NET_PFVAR_H)
/* Open /dev/pf before dropping privileges. */
- if (options->TransPort_set) {
+ if (options->TransPort_set && options->TransProxyType_parsed != TPT_IPFW) {
if (get_pf_socket() < 0) {
*msg = tor_strdup("Unable to open /dev/pf for transparent proxy.");
goto rollback;
REJECT("TPROXY is a Linux-specific feature.");
#else
options->TransProxyType_parsed = TPT_TPROXY;
+#endif
+ } else if (!strcasecmp(options->TransProxyType, "ipfw")) {
+#ifndef __FreeBSD__
+ REJECT("ipfw is a FreeBSD-specific feature.");
+#else
+ options->TransProxyType_parsed = TPT_IPFW;
#endif
} else {
REJECT("Unrecognized value for TransProxyType");
return -1;
}
+#ifdef __FreeBSD__
+ if (get_options()->TransProxyType_parsed == TPT_IPFW) {
+ /* ipfw(8) is used and in this case getsockname returned the original
+ destination */
+ if (proxy_sa->sa_family == AF_INET) {
+ struct sockaddr_in *dest_addr4 = (struct sockaddr_in *)proxy_sa;
+ tor_addr_from_ipv4n(&addr, dest_addr4->sin_addr.s_addr);
+ req->port = ntohs(dest_addr4->sin_port);
+ } else if (proxy_sa->sa_family == AF_INET6) {
+ struct sockaddr_in6 *dest_addr6 = (struct sockaddr_in6 *)proxy_sa;
+ tor_addr_from_in6(&addr, &dest_addr6->sin6_addr);
+ req->port = ntohs(dest_addr6->sin6_port);
+ } else {
+ tor_fragile_assert();
+ return -1;
+ }
+
+ tor_addr_to_str(req->address, &addr, sizeof(req->address), 0);
+
+ return 0;
+ }
+#endif
+
memset(&pnl, 0, sizeof(pnl));
pnl.proto = IPPROTO_TCP;
pnl.direction = PF_OUT;
const char *TransProxyType; /**< What kind of transparent proxy
* implementation are we using? */
/** Parsed value of TransProxyType. */
- enum { TPT_DEFAULT, TPT_TPROXY } TransProxyType_parsed;
+ enum { TPT_DEFAULT, TPT_TPROXY, TPT_IPFW } TransProxyType_parsed;
config_line_t *NATDPort_lines; /**< Ports to listen on for transparent natd
* connections. */
config_line_t *ControlPort_lines; /**< Ports to listen on for control