aboutsummaryrefslogtreecommitdiff
path: root/src/vpn
diff options
context:
space:
mode:
authorPhilipp Tölke <toelke@in.tum.de>2011-06-15 07:15:43 +0000
committerPhilipp Tölke <toelke@in.tum.de>2011-06-15 07:15:43 +0000
commit89ee30fc0e5b3091905e2cf4bf02bb5419b95152 (patch)
tree74523476360212667e998ec6d915d4208bba00c5 /src/vpn
parent79d95cd1caea9746161eb4273862ebcd6b649499 (diff)
read the service-conf from the global config-file
Diffstat (limited to 'src/vpn')
-rw-r--r--src/vpn/gnunet-daemon-exit.c43
-rw-r--r--src/vpn/gnunet-service-dns.c37
2 files changed, 29 insertions, 51 deletions
diff --git a/src/vpn/gnunet-daemon-exit.c b/src/vpn/gnunet-daemon-exit.c
index 76d653b061..975e97c87f 100644
--- a/src/vpn/gnunet-daemon-exit.c
+++ b/src/vpn/gnunet-daemon-exit.c
@@ -42,11 +42,6 @@
static const struct GNUNET_CONFIGURATION_Handle *cfg;
/**
- * The handle to the service-configuration
- */
-static struct GNUNET_CONFIGURATION_Handle *servicecfg;
-
-/**
* The handle to the helper
*/
struct GNUNET_VPN_HELPER_Handle *helper_handle;
@@ -459,9 +454,13 @@ message_token (void *cls __attribute__((unused)),
* "OFFERED-PORT:HOSTNAME:HOST-PORT" (SPACE &lt;more of those&gt;)*
*/
static void
-read_service_conf (void *cls __attribute__((unused)), const char *section, const char *option,
- const char *value)
+read_service_conf (void *cls __attribute__((unused)), const char *section)
{
+ if ((strlen(section) < 8) || (0 != strcmp (".gnunet.", section + (strlen(section) - 8))))
+ return;
+
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Parsing dns-name %d %s %s\n", strlen(section), section, section + (strlen(section) - 8));
+
char *cpy;
char *redirect;
char *hostname;
@@ -473,17 +472,15 @@ read_service_conf (void *cls __attribute__((unused)), const char *section, const
#define TCP 2
#define UDP 1
- unsigned int proto;
- if (0 == strcmp ("UDP_REDIRECTS", option))
- proto = UDP;
- else if (0 == strcmp ("TCP_REDIRECTS", option))
- proto = TCP;
- else
- proto = 0;
+ int proto = UDP;
- if (0 != proto)
+ do
{
- cpy = GNUNET_strdup (value);
+ if (proto == UDP && (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg, section, "UDP_REDIRECTS", &cpy)))
+ goto next;
+ else if (proto == TCP && (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg, section, "TCP_REDIRECTS", &cpy)))
+ goto next;
+
for (redirect = strtok (cpy, " "); redirect != NULL; redirect = strtok
(NULL, " "))
{
@@ -565,7 +562,10 @@ read_service_conf (void *cls __attribute__((unused)), const char *section, const
}
GNUNET_free (cpy);
+next:
+ proto = (proto == UDP) ? TCP : UDP;
}
+ while (proto != UDP);
}
/**
@@ -1255,16 +1255,7 @@ run (void *cls,
GNUNET_CONFIGURATION_get_value_number (cfg, "exit", "MAX_TCP_CONNECTIONS",
&max_tcp_connections);
- char *services;
- GNUNET_CONFIGURATION_get_value_filename (cfg, "dns", "SERVICES", &services);
- servicecfg = GNUNET_CONFIGURATION_create ();
- if (GNUNET_OK == GNUNET_CONFIGURATION_parse (servicecfg, services))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Parsing services %s\n", services);
- GNUNET_CONFIGURATION_iterate (servicecfg, read_service_conf, NULL);
- }
- if (NULL != services)
- GNUNET_free (services);
+ GNUNET_CONFIGURATION_iterate_sections (cfg, read_service_conf, NULL);
GNUNET_SCHEDULER_add_now (start_helper_and_schedule, NULL);
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls);
diff --git a/src/vpn/gnunet-service-dns.c b/src/vpn/gnunet-service-dns.c
index 87c24b67ff..6349e0547f 100644
--- a/src/vpn/gnunet-service-dns.c
+++ b/src/vpn/gnunet-service-dns.c
@@ -64,11 +64,6 @@ static struct GNUNET_DHT_Handle *dht;
static const struct GNUNET_CONFIGURATION_Handle *cfg;
/**
- * The handle to the service-configuration
- */
-static struct GNUNET_CONFIGURATION_Handle *servicecfg;
-
-/**
* A list of DNS-Responses that have to be sent to the requesting client
*/
static struct answer_packet_list *head;
@@ -1043,12 +1038,17 @@ publish_name (const char *name, uint64_t ports, uint32_t service_type,
void
publish_iterate (void *cls __attribute__((unused)), const char *section)
{
+ if ((strlen(section) < 8) || (0 != strcmp (".gnunet.", section + (strlen(section) - 8))))
+ return;
+
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Parsing dns-name %s\n", section);
+
char *udp_redirects, *tcp_redirects, *alternative_names, *alternative_name,
*keyfile;
- GNUNET_CONFIGURATION_get_value_string (servicecfg, section,
+ GNUNET_CONFIGURATION_get_value_string (cfg, section,
"UDP_REDIRECTS", &udp_redirects);
- GNUNET_CONFIGURATION_get_value_string (servicecfg, section, "TCP_REDIRECTS",
+ GNUNET_CONFIGURATION_get_value_string (cfg, section, "TCP_REDIRECTS",
&tcp_redirects);
if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "GNUNETD",
@@ -1080,7 +1080,7 @@ publish_iterate (void *cls __attribute__((unused)), const char *section)
publish_name (section, ports, service_type, my_private_key);
- GNUNET_CONFIGURATION_get_value_string (servicecfg, section,
+ GNUNET_CONFIGURATION_get_value_string (cfg, section,
"ALTERNATIVE_NAMES",
&alternative_names);
for (alternative_name = strtok (alternative_names, " ");
@@ -1102,32 +1102,19 @@ publish_iterate (void *cls __attribute__((unused)), const char *section)
}
/**
- * Publish a DNS-record in the DHT. This is up to now just for testing.
+ * Publish a DNS-record in the DHT.
*/
static void
publish_names (void *cls __attribute__((unused)),
const struct GNUNET_SCHEDULER_TaskContext *tc) {
- char *services;
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
- if (NULL != servicecfg)
- GNUNET_CONFIGURATION_destroy(servicecfg);
-
- GNUNET_CONFIGURATION_get_value_filename(cfg, "dns", "SERVICES", &services);
-
- servicecfg = GNUNET_CONFIGURATION_create();
- if (GNUNET_OK == GNUNET_CONFIGURATION_parse(servicecfg, services))
- {
- GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Parsing services %s\n", services);
- GNUNET_CONFIGURATION_iterate_sections(servicecfg, publish_iterate, NULL);
- }
- if (NULL != services)
- GNUNET_free(services);
+ GNUNET_CONFIGURATION_iterate_sections(cfg, publish_iterate, NULL);
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_HOURS,
- publish_names,
- NULL);
+ publish_names,
+ NULL);
}
/**