Start passing ports to tor_check_port_forwarding().

Conflicts:
	src/or/transports.c
This commit is contained in:
George Kadianakis
2012-06-07 19:20:36 +03:00
parent cd05f35d2c
commit da16c425ef
4 changed files with 65 additions and 1 deletions
+35
View File
@@ -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
+1 -1
View File
@@ -1547,7 +1547,7 @@ run_scheduled_events(time_t now)
options->PortForwarding &&
is_server) {
#define PORT_FORWARDING_CHECK_INTERVAL 5
smartlist_t *ports_to_forward = NULL;//get_list_of_ports_to_forward();
smartlist_t *ports_to_forward = get_list_of_ports_to_forward();
if (ports_to_forward) {
tor_check_port_forwarding(options->PortForwardingHelper,
ports_to_forward,
+27
View File
@@ -1324,6 +1324,33 @@ pt_prepare_proxy_list_for_config_read(void)
tor_assert(unconfigured_proxies_n == 0);
}
/** Return a smartlist containing the ports where our pluggable
* transports are listening. */
smartlist_t *
get_transport_proxy_ports(void)
{
smartlist_t *sl = NULL;
if (!managed_proxy_list)
return NULL;
/** XXX assume that external proxy ports have been forwarded
manually */
SMARTLIST_FOREACH_BEGIN(managed_proxy_list, const managed_proxy_t *, mp) {
if (!mp->is_server || mp->conf_state != PT_PROTO_COMPLETED)
continue;
if (!sl) sl = smartlist_new();
tor_assert(mp->transports);
SMARTLIST_FOREACH(mp->transports, const transport_t *, t,
smartlist_add_asprintf(sl, "%u:%u", t->port, t->port));
} SMARTLIST_FOREACH_END(mp);
return sl;
}
/** Return the pluggable transport string that we should display in
* our extra-info descriptor. If we shouldn't display such a string,
* or we have nothing to display, return NULL. The string is
+2
View File
@@ -54,6 +54,8 @@ void pt_free_all(void);
void pt_prepare_proxy_list_for_config_read(void);
void sweep_proxy_list(void);
smartlist_t *get_transport_proxy_ports(void);
#ifdef PT_PRIVATE
/** State of the managed proxy configuration protocol. */
enum pt_proto_state {