aboutsummaryrefslogtreecommitdiff
path: root/src/or/config.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-09-06 10:12:28 -0400
committerNick Mathewson <nickm@torproject.org>2012-09-06 10:12:28 -0400
commite9684405acf5d3bbfa3c2d4f70332cef3c66d553 (patch)
tree6fb59c7aa83a0f587b20e552e189e3bfade8077f /src/or/config.c
parentd2d7cab5b83e49aba4ae8ecf0aabb9dfcda8d31e (diff)
parent4edc57caa5c4a7d4d46d30bf0150a7f70e8dcccb (diff)
downloadtor-e9684405acf5d3bbfa3c2d4f70332cef3c66d553.tar.gz
tor-e9684405acf5d3bbfa3c2d4f70332cef3c66d553.zip
Merge remote-tracking branch 'asn/bug4567_rebased'
Diffstat (limited to 'src/or/config.c')
-rw-r--r--src/or/config.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/or/config.c b/src/or/config.c
index a4a794a14d..c6a4fe4303 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -7253,6 +7253,43 @@ remove_file_if_very_old(const char *fname, time_t now)
}
}
+/** Return a smartlist of ports that must be forwarded by
+ * tor-fw-helper. The smartlist contains the ports in a string format
+ * that is understandable by tor-fw-helper. */
+smartlist_t *
+get_list_of_ports_to_forward(void)
+{
+ smartlist_t *ports_to_forward = smartlist_new();
+ int port = 0;
+
+ /** XXX TODO tor-fw-helper does not support forwarding ports to
+ other hosts than the local one. If the user is binding to a
+ different IP address, tor-fw-helper won't work. */
+ port = router_get_advertised_or_port(get_options()); /* Get ORPort */
+ if (port)
+ smartlist_add_asprintf(ports_to_forward, "%d:%d", port, port);
+
+ port = router_get_advertised_dir_port(get_options(), 0); /* Get DirPort */
+ if (port)
+ smartlist_add_asprintf(ports_to_forward, "%d:%d", port, port);
+
+ /* Get ports of transport proxies */
+ {
+ smartlist_t *transport_ports = get_transport_proxy_ports();
+ if (transport_ports) {
+ smartlist_add_all(ports_to_forward, transport_ports);
+ smartlist_free(transport_ports);
+ }
+ }
+
+ if (!smartlist_len(ports_to_forward)) {
+ smartlist_free(ports_to_forward);
+ ports_to_forward = NULL;
+ }
+
+ return ports_to_forward;
+}
+
/** Helper to implement GETINFO functions about configuration variables (not
* their values). Given a "config/names" question, set *<b>answer</b> to a
* new string describing the supported configuration variables and their