configurable hello expiration
authorGabor X Toth <*@tg-x.net>
Sun, 18 Nov 2012 18:09:32 +0000 (18:09 +0000)
committerGabor X Toth <*@tg-x.net>
Sun, 18 Nov 2012 18:09:32 +0000 (18:09 +0000)
src/dht/gnunet-service-dht.c
src/dht/gnunet-service-dht_neighbours.c
src/transport/gnunet-service-transport.c
src/transport/gnunet-service-transport_hello.c

index 72575acaefa0b10e69fb21da4cc8536efb7bb22f..5efa9ddc6b64637eba5c65261b58c61ca4008d61 100644 (file)
@@ -66,12 +66,16 @@ struct GNUNET_MessageHeader *GDS_my_hello;
  */
 struct GNUNET_TRANSPORT_Handle *GDS_transport_handle;
 
-
 /**
  * Handle to get our current HELLO.
  */
 static struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
 
+/**
+ * Hello address expiration
+ */
+struct GNUNET_TIME_Relative hello_expiration;
+
 
 /**
  * Receive the HELLO from transport service, free current and replace
@@ -141,6 +145,11 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
      const struct GNUNET_CONFIGURATION_Handle *c)
 {
   GDS_cfg = c;
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_time (c, "transport", "HELLO_EXPIRATION", &hello_expiration))
+  {
+    hello_expiration = GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION;
+  }
   GDS_block_context = GNUNET_BLOCK_context_create (GDS_cfg);
   GDS_stats = GNUNET_STATISTICS_create ("dht", GDS_cfg);
   GDS_ROUTING_init ();
index 40b1013f3887a85f331e8b2a89eb90ef3205cb5a..4872b58a535c545eef89cea5dec15b9a6c936f32 100644 (file)
 #define LOG_ROUTE_DETAILS_STDERR GNUNET_NO
 
 
+/**
+ * Hello address expiration
+ */
+extern struct GNUNET_TIME_Relative hello_expiration;
+
+
 GNUNET_NETWORK_STRUCT_BEGIN
 
 /**
@@ -1683,7 +1689,7 @@ handle_find_peer (const struct GNUNET_PeerIdentity *sender,
     {
       GDS_NEIGHBOURS_handle_reply (sender, GNUNET_BLOCK_TYPE_DHT_HELLO,
                                    GNUNET_TIME_relative_to_absolute
-                                   (GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION),
+                                   (hello_expiration),
                                    key, 0, NULL, 0, NULL, GDS_my_hello,
                                    GNUNET_HELLO_size ((const struct
                                                        GNUNET_HELLO_Message *)
index da6812c96cc50472e00fbbab5de03ecd518754f0..0b596d0214b16f2a8c626f74679ac68d1b79cc27 100644 (file)
@@ -91,6 +91,11 @@ struct GNUNET_ATS_SchedulingHandle *GST_ats;
  */
 static int connections;
 
+/**
+ * Hello address expiration
+ */
+struct GNUNET_TIME_Relative hello_expiration;
+
 
 /**
  * Transmit our HELLO message to the given (connected) neighbour.
@@ -114,7 +119,7 @@ transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target,
   const struct GNUNET_MessageHeader *hello = cls;
 
   GST_neighbours_send (target, (const char *) hello, ntohs (hello->size),
-                       GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION, NULL, NULL);
+                       hello_expiration, NULL, NULL);
 }
 
 
@@ -675,6 +680,12 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_time (c, "transport", "HELLO_EXPIRATION",
+                                           &hello_expiration))
+  {
+    hello_expiration = GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION;
+  }
   GST_server = server;
   GNUNET_SERVER_suspend (server);
   GST_keygen = GNUNET_CRYPTO_rsa_key_create_start (keyfile, &key_generation_cb, NULL);
index 870c083d25280fbc020e505c48036c5ddd96b2a7..247fbc882322eccdb02641af98e1190562ab81e2 100644 (file)
  */
 #define HELLO_REFRESH_PERIOD GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 6)
 
+/**
+ * Hello address expiration
+ */
+extern struct GNUNET_TIME_Relative hello_expiration;
+
 
 /**
  * Entry in linked list of network addresses for ourselves.  Also
@@ -159,9 +164,7 @@ refresh_hello_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 
   hello_task = GNUNET_SCHEDULER_NO_TASK;
   gc.addr_pos = oal_head;
-  gc.expiration =
-      GNUNET_TIME_relative_to_absolute
-      (GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION);
+  gc.expiration = GNUNET_TIME_relative_to_absolute (hello_expiration);
 
   GNUNET_free (our_hello);
   our_hello = GNUNET_HELLO_create (&GST_my_public_key, &address_generator, &gc);