gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r20080 - gnunet/src/gns


From: gnunet
Subject: [GNUnet-SVN] r20080 - gnunet/src/gns
Date: Mon, 27 Feb 2012 19:33:49 +0100

Author: schanzen
Date: 2012-02-27 19:33:49 +0100 (Mon, 27 Feb 2012)
New Revision: 20080

Modified:
   gnunet/src/gns/gnunet-service-gns.c
   gnunet/src/gns/test_gns_twopeer.c
   gnunet/src/gns/test_gns_twopeer.conf
Log:
-cleanup, fixes


Modified: gnunet/src/gns/gnunet-service-gns.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns.c 2012-02-27 17:31:20 UTC (rev 20079)
+++ gnunet/src/gns/gnunet-service-gns.c 2012-02-27 18:33:49 UTC (rev 20080)
@@ -817,9 +817,9 @@
   }
 
   if (len == 0)
-    return NULL; //Error
+    return NULL;
 
-  name[len] = '\0'; //terminate string
+  name[len] = '\0';
 
   return (name+len+1);
 }
@@ -839,7 +839,7 @@
 {
   if (is_canonical(rh->name))
   {
-    //We only need to check this zone's ns
+    /* We only need to check the current zone's ns */
     GNUNET_NAMESTORE_lookup_record(namestore_handle,
                                &rh->authority,
                                rh->name,
@@ -849,7 +849,7 @@
   }
   else
   {
-    //We have to resolve the authoritative entity
+    /* We have to resolve the authoritative entity first */
     rh->authority_name = pop_tld(rh->name);
     GNUNET_NAMESTORE_lookup_record(namestore_handle,
                                  &rh->authority,
@@ -885,7 +885,6 @@
   rh->query = q;
   rh->authority = zone_hash;
   
-  //FIXME do not forget to free!!
   rh->name = GNUNET_malloc(strlen(q->name)
                               - strlen(gnunet_tld) + 1);
   memset(rh->name, 0,
@@ -895,7 +894,7 @@
 
   rh->request_handle = request;
 
-  //Start resolution in our zone
+  /* Start resolution in our zone */
   resolve_name(rh);
 }
 
@@ -949,7 +948,7 @@
 
   if (p->num_queries > 1)
   {
-    //Note: We could also look for .gnunet
+    /* Note: We could also look for .gnunet */
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 ">1 queriy in DNS packet... odd. We only process #1\n");
   }
@@ -983,71 +982,25 @@
 put_some_records(void)
 {
   GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Populating namestore\n");
-  /* put a few records into namestore */
-  char* ipA = "1.2.3.4";
+  /* put an A record into namestore FIXME use gnunet.org */
   char* ipB = "5.6.7.8";
-  //struct GNUNET_CRYPTO_RsaPrivateKey *bob_key = GNUNET_CRYPTO_rsa_key_create 
();
-  //struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *bob;
-  //bob = GNUNET_malloc(sizeof(struct 
GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded));
 
-  //GNUNET_CRYPTO_rsa_key_get_public (bob_key, bob);
-
-  //GNUNET_HashCode *bob_zone = GNUNET_malloc(sizeof(GNUNET_HashCode));
-
-  //GNUNET_CRYPTO_hash(bob, GNUNET_CRYPTO_RSA_KEY_LENGTH, bob_zone);
-
-  struct in_addr *alice = GNUNET_malloc(sizeof(struct in_addr));
   struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr));
-  struct GNUNET_NAMESTORE_RecordData rda;
-  //struct GNUNET_NAMESTORE_RecordData rdb;
   struct GNUNET_NAMESTORE_RecordData rdb_web;
 
-  GNUNET_assert(1 == inet_pton (AF_INET, ipA, alice));
   GNUNET_assert(1 == inet_pton (AF_INET, ipB, web));
 
-  rda.data_size = sizeof(struct in_addr);
   rdb_web.data_size = sizeof(struct in_addr);
-  //rdb.data_size = sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded);
-  rda.data = alice;
-  //rdb.data = bob;
   rdb_web.data = web;
-  rda.record_type = GNUNET_GNS_RECORD_TYPE_A;
   rdb_web.record_type = GNUNET_DNSPARSER_TYPE_A;
-  //rdb.record_type = GNUNET_GNS_RECORD_PKEY;
   rdb_web.expiration = GNUNET_TIME_absolute_get_forever ();
-  rda.expiration = GNUNET_TIME_absolute_get_forever ();
-  //rdb.expiration = GNUNET_TIME_absolute_get_forever ();
   
-  //alice.gnunet A IN 1.2.3.4
-  /*GNUNET_NAMESTORE_record_create (namestore_handle,
-                               zone_key,
-                               "alice",
-                               &rda,
-                               NULL,
-                               NULL);*/
   GNUNET_NAMESTORE_record_create (namestore_handle,
                                   zone_key,
                                   "www",
                                   &rdb_web,
                                   NULL,
                                   NULL);
-/*
-  //www.bob.gnunet A IN 5.6.7.8
-  GNUNET_NAMESTORE_record_create (namestore_handle,
-                               zone_key,
-                               "bob",
-                               &rdb,
-                               NULL,
-                               NULL);*/
-  /*GNUNET_NAMESTORE_record_put(namestore_handle,
-                              zone_key,
-                              "www",
-                              GNUNET_TIME_absolute_get_forever (),
-                              1,
-                              &rdb_web,
-                              NULL, //Signature
-                              NULL, //Cont
-                              NULL); //cls*/
 }
 
 void
@@ -1097,7 +1050,8 @@
   int i;
   uint32_t rd_payload_length;
 
-  if (NULL == name) //We're done
+  /* we're done */
+  if (NULL == name)
   {
     GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Zone iteration finished\n");
     GNUNET_NAMESTORE_zone_iteration_stop (namestore_iter);
@@ -1108,7 +1062,8 @@
   
   rd_payload_length = rd_count * sizeof(struct GNSRecordBlock);
   rd_payload_length += strlen(name) + 1 + sizeof(struct GNSNameRecordBlock);
-  //Calculate payload size
+  
+  /* calculate payload size */
   for (i=0; i<rd_count; i++)
   {
     rd_payload_length += rd[i].data_size;
@@ -1125,7 +1080,7 @@
 
   nrb->rd_count = htonl(rd_count);
 
-  memcpy(&nrb[1], name, strlen(name) + 1); //FIXME is this 0 terminated??-sure 
hope so for we use strlen
+  memcpy(&nrb[1], name, strlen(name) + 1); //FIXME is this 0 terminated??
 
   rb = (struct GNSRecordBlock *)((char*)&nrb[1] + strlen(name) + 1);
 
@@ -1273,6 +1228,8 @@
       GNUNET_CONFIGURATION_get_value_yesno (c, "gns",
                                             "HIJACK_DNS"))
   {
+    GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+               "DNS hijacking enabled... connecting to service.\n");
     /**
      * Do gnunet dns init here
      */

Modified: gnunet/src/gns/test_gns_twopeer.c
===================================================================
--- gnunet/src/gns/test_gns_twopeer.c   2012-02-27 17:31:20 UTC (rev 20079)
+++ gnunet/src/gns/test_gns_twopeer.c   2012-02-27 18:33:49 UTC (rev 20080)
@@ -187,6 +187,7 @@
   }
   if (d == d1)
   {
+    /* start gns for bob */
     GNUNET_log (GNUNET_ERROR_TYPE_INFO, "GNS started on alice\n");
     GNUNET_TESTING_daemon_start_service (d2, "gns", TIMEOUT, &gns_started,
                                         NULL);
@@ -195,6 +196,7 @@
 
   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "GNS started on bob\n");
 
+  /* start the lookup tests */
   GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
                                   (GNUNET_TIME_UNIT_SECONDS, 1),
                                   &do_lookup, NULL);
@@ -247,6 +249,8 @@
     GNUNET_SCHEDULER_cancel (die_task);
     die_task =
         GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from test lookup");
+    
+    /* start gns for alice */
     GNUNET_TESTING_daemon_start_service (d1, "gns", TIMEOUT, &gns_started, 
NULL);
     
   }
@@ -266,6 +270,7 @@
 alice_idle (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   
+  alice_online = 1;
   if (!bob_online)
   {
     GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
@@ -282,10 +287,10 @@
 static void
 bob_idle (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  
+  /* he's lazy FIXME forever */
   bob_online = 1;
   bob_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
-                                  (GNUNET_TIME_UNIT_SECONDS, 2),
+                                  (GNUNET_TIME_UNIT_SECONDS, 20),
                                    &bob_idle, NULL);
 }
 
@@ -316,7 +321,6 @@
   }
   GNUNET_assert (id != NULL);
   
-  alice_online = 1;
   GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
                                 (GNUNET_TIME_UNIT_SECONDS, 2),
                                 &alice_idle, NULL);
@@ -335,7 +339,6 @@
   }
   GNUNET_assert (id != NULL);
   
-  alice_online = 1;
   GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
                                 (GNUNET_TIME_UNIT_SECONDS, 2),
                                 &bob_idle, NULL);
@@ -368,25 +371,39 @@
   die_task =
       GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly,
                                     "didn't start all daemons in reasonable 
amount of time!!!");
+  
   alice_online = 0;
   bob_online = 0;
+  expected_connections = 1;
+  
+  /* Start alice */
   d1 = GNUNET_TESTING_daemon_start(cfg, TIMEOUT, GNUNET_NO, NULL, NULL, 0,
                                    NULL, NULL, NULL, &alice_started, NULL);
+  
+  /* Somebody care to explain? */
   uint16_t port = 6000;
-  expected_connections = 1;
   uint32_t upnum = 23;
   uint32_t fdnum = 42;
+  
+  
+  /**
+   * Modify some config options for bob
+   * namely swap keys and disable dns hijacking
+   */
   struct GNUNET_CONFIGURATION_Handle *cfg2 = GNUNET_TESTING_create_cfg(cfg,
                                               23, &port, &upnum,
                                               NULL, &fdnum);
+  
   GNUNET_CONFIGURATION_set_value_string (cfg2, "paths", "servicehome",
-                                         "/tmp/peer2");
+                                         "/tmp/test-gnunetd-gns-peer-2/");
   GNUNET_CONFIGURATION_set_value_string (cfg2, "gns", "HIJACK_DNS",
                                         "NO");
   GNUNET_CONFIGURATION_set_value_string (cfg2, "gns", "ZONEKEY",
                                          "/tmp/bobkey");
   GNUNET_CONFIGURATION_set_value_string (cfg2, "gns", "TRUSTED",
-                                         "alice:/tmp/zonekey");
+                                         "alice:/tmp/alicekey");
+  
+  //Start bob
   d2 = GNUNET_TESTING_daemon_start(cfg2, TIMEOUT, GNUNET_NO, NULL, NULL, 0,
                                    NULL, NULL, NULL, &bob_started, NULL);
 

Modified: gnunet/src/gns/test_gns_twopeer.conf
===================================================================
--- gnunet/src/gns/test_gns_twopeer.conf        2012-02-27 17:31:20 UTC (rev 
20079)
+++ gnunet/src/gns/test_gns_twopeer.conf        2012-02-27 18:33:49 UTC (rev 
20080)
@@ -71,6 +71,7 @@
 [gns]
 AUTOSTART = YES
 BINARY = gnunet-service-gns
+ZONEKEY = /tmp/alicekey
 
 
 [nse]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]