[or-cvs] Add "platform" to router descriptors.

Nick Mathewson nickm at seul.org
Tue Sep 30 22:44:35 UTC 2003


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv13492/src/or

Modified Files:
	main.c routers.c 
Log Message:
Add "platform" to router descriptors.

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -d -r1.116 -r1.117
--- main.c	30 Sep 2003 20:36:20 -0000	1.116
+++ main.c	30 Sep 2003 22:44:33 -0000	1.117
@@ -3,6 +3,9 @@
 /* $Id$ */
 
 #include "or.h"
+#ifdef HAVE_UNAME
+#include <sys/utsname.h>
+#endif
 
 /********* START PROTOTYPES **********/
 
@@ -672,11 +675,28 @@
   }
 }
 
+static void get_platform_str(char *platform, int len)
+{
+#ifdef HAVE_UNAME
+  struct utsname u;
+  if (!uname(&u)) {
+    snprintf(platform, len-1, "Tor %s on %s %s %s %s %s",
+             VERSION, u.sysname, u.nodename, u.release, u.version, u.machine);
+    platform[len-1] = '\0';
+    return;
+  } else
+#endif
+    {
+      snprintf(platform, len-1, "Tor %s", VERSION);
+    }
+}
+
 int dump_router_to_string(char *s, int maxlen, routerinfo_t *router,
                           crypto_pk_env_t *ident_key) {
   char *onion_pkey;
   char *link_pkey;
   char *identity_pkey;
+  char platform[256];
   char digest[20];
   char signature[128];
   char published[32];
@@ -684,6 +704,8 @@
   int written;
   int result=0;
   struct exit_policy_t *tmpe;
+  
+  get_platform_str(platform, 256);
 
   if(crypto_pk_write_public_key_to_string(router->onion_pkey,
                                           &onion_pkey,&onion_pkeylen)<0) {
@@ -706,16 +728,18 @@
   
   result = snprintf(s, maxlen, 
                     "router %s %s %d %d %d %d\n"
+                    "platform %s\n"
                     "published %s\n"
                     "onion-key\n%s"
                     "link-key\n%s"
                     "signing-key\n%s",
-    router->nickname,                   
+    router->nickname,             
     router->address,
     router->or_port,
     router->ap_port,
     router->dir_port,
     router->bandwidth,
+    platform,
     published,
     onion_pkey, link_pkey, identity_pkey);
 

Index: routers.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routers.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- routers.c	30 Sep 2003 21:27:16 -0000	1.63
+++ routers.c	30 Sep 2003 22:44:33 -0000	1.64
@@ -275,6 +275,7 @@
   K_ROUTER_SIGNATURE,
   K_PUBLISHED,
   K_RUNNING_ROUTERS,
+  K_PLATFORM,
   _SIGNATURE, 
   _PUBLIC_KEY, 
   _ERR, 
@@ -296,6 +297,7 @@
   { "router-signature", K_ROUTER_SIGNATURE },
   { "published", K_PUBLISHED },
   { "running-routers", K_RUNNING_ROUTERS },
+  { "platform", K_PLATFORM },
   { NULL, -1 }
 };
 
@@ -453,6 +455,7 @@
     case K_ROUTER_SIGNATURE: printf("Router-signature"); break;
     case K_PUBLISHED: printf("Published"); break;
     case K_RUNNING_ROUTERS: printf("Running-routers"); break;
+    case K_PLATFORM: printf("Platform"); break;
     default:
       printf("?????? %d\n", tok->tp); return;
     }
@@ -886,7 +889,12 @@
   log_fn(LOG_DEBUG,"or_port %d, ap_port %d, dir_port %d, bandwidth %d.",
     router->or_port, router->ap_port, router->dir_port, router->bandwidth);
 
+  /* XXX Later, require platform before published. */
   NEXT_TOKEN();
+  if (tok->tp == K_PLATFORM) {
+    NEXT_TOKEN();
+  }
+  
   if (tok->tp != K_PUBLISHED) {
     log_fn(LOG_WARNING, "Missing published time"); goto err;
   }



More information about the tor-commits mailing list