aboutsummaryrefslogtreecommitdiff
path: root/src/or/config.c
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2012-06-07 19:20:36 +0300
committerGeorge Kadianakis <desnacked@riseup.net>2012-09-05 18:08:18 +0300
commitda16c425ef8c17a753ae0abc3fdb26a328004062 (patch)
treeca4cb298c5393740d44dd616cd4ef5b7c86d7309 /src/or/config.c
parentcd05f35d2cdf50d31108428cf5c19549d468dbc0 (diff)
downloadtor-da16c425ef8c17a753ae0abc3fdb26a328004062.tar
tor-da16c425ef8c17a753ae0abc3fdb26a328004062.tar.gz
Start passing ports to tor_check_port_forwarding().
Conflicts: src/or/transports.c
Diffstat (limited to 'src/or/config.c')
-rw-r--r--src/or/config.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/or/config.c b/src/or/config.c
index f21016d48..ad422efcd 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -7254,6 +7254,41 @@ 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 = get_primary_or_port(); /* Get ORPort */
+ if (port)
+ smartlist_add_asprintf(ports_to_forward, "%d:%d", port, port);
+
+ port = get_primary_dir_port(); /* 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