[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Implement the TRANSPORT_LAUNCHED control port event.



commit 6dd462e8bcaecb8224302b402214b546cf790c5f
Author: George Kadianakis <desnacked@xxxxxxxxxx>
Date:   Wed Jan 23 12:41:19 2013 +0200

    Implement the TRANSPORT_LAUNCHED control port event.
---
 src/or/control.c    |   19 ++++++++++++++++++-
 src/or/control.h    |    4 ++++
 src/or/transports.c |    4 ++++
 3 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/src/or/control.c b/src/or/control.c
index fc4809b..37bbab4 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -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)
diff --git a/src/or/control.h b/src/or/control.h
index 1a44768..2d38ed8 100644
--- a/src/or/control.h
+++ b/src/or/control.h
@@ -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
diff --git a/src/or/transports.c b/src/or/transports.c
index f6bbbe8..f9499eb 100644
--- a/src/or/transports.c
+++ b/src/or/transports.c
@@ -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;
     }



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits