Hi

Here's a small patch I made to latest n2n_v1 branch.
Added -T <traceLevel> to change tracelevel
and fixed a recurring warnng message when using the -b option

I don't know if n2n_v1 is still under development. But I'm using it.

I don't use n2n_v2 because I tried n2n_v2 edge under openwrt (without
openssl) and I couldn't make it work.

Thanks

Here's the patch:


Index: edge.c
===================================================================
--- edge.c      (revision 5209)
+++ edge.c      (working copy)
@@ -255,6 +255,7 @@
         "-c <community> "
         "-k <encrypt key> "
         "-s <netmask> "
+        "-T <trace level> "
 #ifndef WIN32
         "[-u <uid> -g <gid>]"
         "[-f]"
@@ -288,6 +289,7 @@
   printf("-t                       | Use http tunneling (experimental)\n");
   printf("-r                       | Enable packet forwarding through
n2n community\n");
   printf("-v                       | Verbose\n");
+  printf("-T <trace level>         | 0:Error 1:Warning 2:Normal 3:Info\n");

   printf("\nEnvironment variables:\n");
   printf("  N2N_KEY                | Encryption key (ASCII)\n" );
@@ -1093,6 +1095,8 @@

 /* ***************************************************** */

+static int supernode_addr_evaluated=0;
+
 static void supernode2addr(n2n_edge_t * eee, char* addr) {
   char *supernode_host = strtok(addr, ":");

@@ -1103,9 +1107,12 @@
     int nameerr;
     ipstr_t ip_buf;

-    if ( supernode_port )
+    if ( supernode_port ) {
       eee->supernode.port = htons(atoi(supernode_port));
-    else
+      /* strtok truncates the addr string, so it must not be called again */
+      supernode_addr_evaluated=1;
+    }
+    else if (!supernode_addr_evaluated)
       traceEvent(TRACE_WARNING, "Bad supernode parameter (-l <host:port>)");

     nameerr = getaddrinfo( supernode_host, NULL, &aihints, &ainfo );
@@ -1233,7 +1240,7 @@
   /* {int k;for(k=0;k<effectiveargc;++k)  printf("%s\n",effectiveargv[k]);} */

   optarg = NULL;
-  while((opt = getopt_long(effectiveargc, effectiveargv,
"k:a:bc:u:g:m:M:s:d:l:p:fvhrt", long_options, NULL)) != EOF) {
+  while((opt = getopt_long(effectiveargc, effectiveargv,
"k:a:bc:u:g:m:M:s:d:l:p:fvhrtT:", long_options, NULL)) != EOF) {
     switch (opt) {
     case 'a':
                  printf("%s\n", optarg);
@@ -1309,6 +1316,9 @@
     case 'v': /* verbose */
       traceLevel = 3;
       break;
+    case 'T': /* set trace level */
+      traceLevel = atoi(optarg);
+      break;
     }
   }
Index: edge.c
===================================================================
--- edge.c	(revision 5209)
+++ edge.c	(working copy)
@@ -255,6 +255,7 @@
 	 "-c <community> "
 	 "-k <encrypt key> "
 	 "-s <netmask> "
+	 "-T <trace level> "
 #ifndef WIN32
 	 "[-u <uid> -g <gid>]"
 	 "[-f]"
@@ -288,6 +289,7 @@
   printf("-t                       | Use http tunneling (experimental)\n");
   printf("-r                       | Enable packet forwarding through n2n community\n");
   printf("-v                       | Verbose\n");
+  printf("-T <trace level>         | 0:Error 1:Warning 2:Normal 3:Info\n");
 
   printf("\nEnvironment variables:\n");
   printf("  N2N_KEY                | Encryption key (ASCII)\n" );
@@ -1093,6 +1095,8 @@
 
 /* ***************************************************** */
 
+static int supernode_addr_evaluated=0;
+
 static void supernode2addr(n2n_edge_t * eee, char* addr) {
   char *supernode_host = strtok(addr, ":");
 
@@ -1103,9 +1107,12 @@
     int nameerr;
     ipstr_t ip_buf;
 
-    if ( supernode_port )
+    if ( supernode_port ) {
       eee->supernode.port = htons(atoi(supernode_port));
-    else
+      /* strtok truncates the addr string, so it must not be called again */
+      supernode_addr_evaluated=1;
+    }
+    else if (!supernode_addr_evaluated) 
       traceEvent(TRACE_WARNING, "Bad supernode parameter (-l <host:port>)");
 
     nameerr = getaddrinfo( supernode_host, NULL, &aihints, &ainfo );
@@ -1233,7 +1240,7 @@
   /* {int k;for(k=0;k<effectiveargc;++k)  printf("%s\n",effectiveargv[k]);} */
 
   optarg = NULL;
-  while((opt = getopt_long(effectiveargc, effectiveargv, "k:a:bc:u:g:m:M:s:d:l:p:fvhrt", long_options, NULL)) != EOF) {
+  while((opt = getopt_long(effectiveargc, effectiveargv, "k:a:bc:u:g:m:M:s:d:l:p:fvhrtT:", long_options, NULL)) != EOF) {
     switch (opt) {
     case 'a':
 		  printf("%s\n", optarg);
@@ -1309,6 +1316,9 @@
     case 'v': /* verbose */
       traceLevel = 3;
       break;
+    case 'T': /* set trace level */
+      traceLevel = atoi(optarg);
+      break;
     }
   }
 
_______________________________________________
Ntop-dev mailing list
[email protected]
http://listgateway.unipi.it/mailman/listinfo/ntop-dev

Reply via email to