aboutsummaryrefslogtreecommitdiff
path: root/src/or/connection_edge.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-02-03 14:09:07 -0500
committerNick Mathewson <nickm@torproject.org>2014-04-16 23:03:25 -0400
commit3e4680f3126c2a06358535b08bf267dca1bb90a7 (patch)
tree014486c97356c86c7124ff33159c1a40159671a3 /src/or/connection_edge.c
parentd290e36576c07b288a6347385d144a493869bd97 (diff)
downloadtor-3e4680f3126c2a06358535b08bf267dca1bb90a7.tar.gz
tor-3e4680f3126c2a06358535b08bf267dca1bb90a7.zip
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.)
Diffstat (limited to 'src/or/connection_edge.c')
-rw-r--r--src/or/connection_edge.c23
1 files changed, 23 insertions, 0 deletions
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;