Implement the TRANSPORT_LAUNCHED control port event.

This commit is contained in:
George Kadianakis 2013-01-23 12:41:19 +02:00 committed by Nick Mathewson
parent 2452302354
commit 6dd462e8bc
3 changed files with 26 additions and 1 deletions

View File

@ -82,7 +82,8 @@
#define EVENT_BUILDTIMEOUT_SET 0x0017
#define EVENT_SIGNAL 0x0018
#define EVENT_CONF_CHANGED 0x0019
#define EVENT_MAX_ 0x0019
#define EVENT_TRANSPORT_LAUNCHED 0x0020
#define EVENT_MAX_ 0x0020
/* If EVENT_MAX_ ever hits 0x0020, we need to make the mask wider. */
/** Bitfield: The bit 1&lt;&lt;e is set if <b>any</b> open control
@ -958,6 +959,7 @@ static const struct control_event_t control_event_table[] = {
{ EVENT_BUILDTIMEOUT_SET, "BUILDTIMEOUT_SET" },
{ EVENT_SIGNAL, "SIGNAL" },
{ EVENT_CONF_CHANGED, "CONF_CHANGED"},
{ EVENT_TRANSPORT_LAUNCHED, "TRANSPORT_LAUNCHED" },
{ 0, NULL },
};
@ -4737,6 +4739,21 @@ control_event_clients_seen(const char *controller_str)
"650 CLIENTS_SEEN %s\r\n", controller_str);
}
/** A new pluggable transport called <b>transport_name</b> was
* launched on <b>addr</b>:<b>port</b>. <b>mode</b> is either
* "server" or "client" depending on the mode of the pluggable
* transport.
* "650" SP "TRANSPORT_LAUNCHED" SP Mode SP Name SP Address SP Port
*/
void
control_event_transport_launched(const char *mode, const char *transport_name,
tor_addr_t *addr, uint16_t port)
{
send_control_event(EVENT_TRANSPORT_LAUNCHED, ALL_FORMATS,
"650 TRANSPORT_LAUNCHED %s %s %s %u\r\n",
mode, transport_name, fmt_addr(addr), port);
}
/** Free any leftover allocated memory of the control.c subsystem. */
void
control_free_all(void)

View File

@ -89,6 +89,10 @@ MOCK_DECL(void, control_event_bootstrap_problem,(const char *warn,
int reason));
void control_event_clients_seen(const char *controller_str);
void control_event_transport_launched(const char *mode,
const char *transport_name,
tor_addr_t *addr, uint16_t port);
void control_free_all(void);
#ifdef CONTROL_PRIVATE

View File

@ -98,6 +98,7 @@
#include "entrynodes.h"
#include "connection_or.h"
#include "ext_orport.h"
#include "control.h"
static process_environment_t *
create_managed_proxy_environment(const managed_proxy_t *mp);
@ -659,6 +660,7 @@ register_server_proxy(const managed_proxy_t *mp)
save_transport_to_state(t->name, &t->addr, t->port);
log_notice(LD_GENERAL, "Registered server transport '%s' at '%s'",
t->name, fmt_addrport(&t->addr, t->port));
control_event_transport_launched("server", t->name, &t->addr, t->port);
} SMARTLIST_FOREACH_END(t);
}
@ -681,9 +683,11 @@ register_client_proxy(const managed_proxy_t *mp)
break;
case 0:
log_info(LD_GENERAL, "Successfully registered transport %s", t->name);
control_event_transport_launched("client", t->name, &t->addr, t->port);
break;
case 1:
log_info(LD_GENERAL, "Successfully registered transport %s", t->name);
control_event_transport_launched("client", t->name, &t->addr, t->port);
transport_free(transport_tmp);
break;
}