From 3e4680f3126c2a06358535b08bf267dca1bb90a7 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 3 Feb 2014 14:09:07 -0500 Subject: ipfw TransPort support on FreeBSD (10267) This isn't on by default; to get it, you need to set "TransProxyType ipfw". (The original patch had automatic detection for whether /dev/pf is present and openable, but that seems marginally fragile.) --- src/or/connection_edge.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/or/connection_edge.c') diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index 41ca6119b0..ddeac10381 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -1435,6 +1435,29 @@ connection_ap_get_original_destination(entry_connection_t *conn, 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; -- cgit v1.2.3-54-g00ecf