gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r15801 - in gnunet: contrib src/nat


From: gnunet
Subject: [GNUnet-SVN] r15801 - in gnunet: contrib src/nat
Date: Thu, 30 Jun 2011 22:32:23 +0200

Author: grothoff
Date: 2011-06-30 22:32:23 +0200 (Thu, 30 Jun 2011)
New Revision: 15801

Modified:
   gnunet/contrib/defaults.conf
   gnunet/src/nat/nat.c
Log:
make refresh frequencies configurable

Modified: gnunet/contrib/defaults.conf
===================================================================
--- gnunet/contrib/defaults.conf        2011-06-30 15:21:18 UTC (rev 15800)
+++ gnunet/contrib/defaults.conf        2011-06-30 20:32:23 UTC (rev 15801)
@@ -52,7 +52,20 @@
 # Disable IPv6 support
 DISABLEV6 = NO
 
+# How often do we query the DNS resolver
+# for our hostname (to get our own IP), in ms
+HOSTNAME_DNS_FREQUENCY = 1200000
 
+# How often do we iterate over our 
+# network interfaces to check for changes
+# in our IP address? in ms
+IFC_SCAN_FREQUENCY = 3000000
+
+# How often do we query the DNS resolver
+# for our hostname (to get our own IP), in ms
+DYNDNS_FREQUENCY = 140000
+
+
 [transport-tcp]
 # Use 0 to ONLY advertise as a peer behind NAT (no port binding)
 PORT = 2086

Modified: gnunet/src/nat/nat.c
===================================================================
--- gnunet/src/nat/nat.c        2011-06-30 15:21:18 UTC (rev 15800)
+++ gnunet/src/nat/nat.c        2011-06-30 20:32:23 UTC (rev 15801)
@@ -27,7 +27,6 @@
  *
  * TODO:
  * - implement UPnP/PMP support
- * - make frequency of checks configurable
  */
 #include "platform.h"
 #include "gnunet_util_lib.h"
@@ -37,20 +36,17 @@
 /**
  * How often do we scan for changes in our IP address from our local
  * interfaces?
- * FIXME: make this configurable...
  */
 #define IFC_SCAN_FREQUENCY GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_MINUTES, 15)
 
 /**
  * How often do we scan for changes in how our hostname resolves?
- * FIXME: make this configurable...
  */
 #define HOSTNAME_DNS_FREQUENCY GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_MINUTES, 20)
 
 
 /**
  * How often do we scan for changes in how our external (dyndns) hostname 
resolves?
- * FIXME: make this configurable...
  */
 #define DYNDNS_FREQUENCY GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_MINUTES, 7)
 
@@ -209,6 +205,22 @@
   GNUNET_SCHEDULER_TaskIdentifier dns_task;
 
   /**
+   * How often do we scan for changes in our IP address from our local
+   * interfaces?
+   */
+  struct GNUNET_TIME_Relative ifc_scan_frequency;
+
+  /**
+   * How often do we scan for changes in how our hostname resolves?
+   */
+  struct GNUNET_TIME_Relative hostname_dns_frequency;
+
+  /**
+   * How often do we scan for changes in how our external (dyndns) hostname 
resolves?
+   */
+  struct GNUNET_TIME_Relative dyndns_frequency;
+
+  /**
    * The process id of the server process (if behind NAT)
    */
   struct GNUNET_OS_Process *server_proc;
@@ -521,11 +533,16 @@
                     socklen_t addrlen)
 {
   struct GNUNET_NAT_Handle *h = cls;
+  struct in_addr dummy;
 
   if (addr == NULL)
     {    
       h->ext_dns = NULL;
-      h->dns_task = GNUNET_SCHEDULER_add_delayed (DYNDNS_FREQUENCY,
+      if (1 == inet_pton (AF_INET,
+                         h->external_address,
+                         &dummy))
+       return; /* repated lookup pointless: was numeric! */
+      h->dns_task = GNUNET_SCHEDULER_add_delayed (h->dyndns_frequency,
                                                  &resolve_dns, h);
       return;
     }
@@ -562,7 +579,7 @@
   if (addr == NULL)
     {
       h->hostname_dns = NULL;
-      h->hostname_task = GNUNET_SCHEDULER_add_delayed (HOSTNAME_DNS_FREQUENCY,
+      h->hostname_task = GNUNET_SCHEDULER_add_delayed 
(h->hostname_dns_frequency,
                                                       &resolve_hostname, h);
       return;
     }
@@ -955,7 +972,7 @@
   h->ifc_task = GNUNET_SCHEDULER_NO_TASK;
   remove_from_address_list_by_source (h, LAL_INTERFACE_ADDRESS);
   GNUNET_OS_network_interfaces_list (&process_interfaces, h); 
-  h->ifc_task = GNUNET_SCHEDULER_add_delayed (IFC_SCAN_FREQUENCY,
+  h->ifc_task = GNUNET_SCHEDULER_add_delayed (h->ifc_scan_frequency,
                                              &list_interfaces, h);
 }
 
@@ -1128,6 +1145,25 @@
   h->disable_ipv6 = GNUNET_CONFIGURATION_get_value_yesno(cfg,
                                                         "nat", 
                                                         "DISABLEV6");
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_time (cfg,
+                                          "nat",
+                                          "DYNDNS_FREQUENCY",
+                                          &h->dyndns_frequency))
+    h->dyndns_frequency = DYNDNS_FREQUENCY;
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_time (cfg,
+                                          "nat",
+                                          "IFC_SCAN_FREQUENCY",
+                                          &h->ifc_scan_frequency))
+    h->ifc_scan_frequency = IFC_SCAN_FREQUENCY;
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_time (cfg,
+                                          "nat",
+                                          "HOSTNAME_DNS_FREQUENCY",
+                                          &h->hostname_dns_frequency))
+    h->hostname_dns_frequency = HOSTNAME_DNS_FREQUENCY;
+
   if (NULL == reversal_callback)
     h->enable_nat_server = GNUNET_NO;
 




reply via email to

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