*/
static const struct GNUNET_CONFIGURATION_Handle *cfg;
-/**
- * The handle to the service-configuration
- */
-static struct GNUNET_CONFIGURATION_Handle *servicecfg;
-
/**
* The handle to the helper
*/
* "OFFERED-PORT:HOSTNAME:HOST-PORT" (SPACE <more of those>)*
*/
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;
#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, " "))
{
}
GNUNET_free (cpy);
+next:
+ proto = (proto == UDP) ? TCP : UDP;
}
+ while (proto != UDP);
}
/**
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);
*/
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
*/
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",
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, " ");
}
/**
- * 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);
}
/**