enable_recursive_resolver (int yes)
{
recursive_resolver = yes;
+#ifdef USE_LIBDNS
libdns_reinit_pending = 1;
+#endif
}
}
-/* Sets the module in Tor mode. Returns 0 is this is possible or an
- error code. */
-gpg_error_t
+/* Puts this module eternally into Tor mode. When called agained with
+ * NEW_CIRCUIT request a new TOR circuit for the next DNS query. */
+void
enable_dns_tormode (int new_circuit)
{
if (!*tor_socks_user || new_circuit)
counter++;
}
tor_mode = 1;
- return 0;
}
strncpy (tor_nameserver, ipaddr? ipaddr : DEFAULT_NAMESERVER,
sizeof tor_nameserver -1);
tor_nameserver[sizeof tor_nameserver -1] = 0;
+#ifdef USE_LIBDNS
libdns_reinit_pending = 1;
libdns_tor_port = 0; /* Start again with the default port. */
+#endif
}
switch (h_errno)
{
- case HOST_NOT_FOUND: ec = GPG_ERR_UNKNOWN_HOST; break;
+ case HOST_NOT_FOUND: ec = GPG_ERR_NO_NAME; break;
case TRY_AGAIN: ec = GPG_ERR_TRY_LATER; break;
case NO_RECOVERY: ec = GPG_ERR_SERVER_FAILED; break;
case NO_DATA: ec = GPG_ERR_NO_DATA; break;
/* All fine. Make the data global. */
libdns = ld;
+ if (opt_debug)
+ log_debug ("dns: libdns initialized%s\n", tor_mode?" (tor mode)":"");
+
leave:
xfree (cfgstr);
return err;
void
reload_dns_stuff (int force)
{
+#ifdef USE_LIBDNS
if (force)
{
-#ifdef USE_LIBDNS
libdns_deinit ();
-#endif
libdns_reinit_pending = 0;
}
else
- libdns_reinit_pending = 1;
+ {
+ libdns_reinit_pending = 1;
+ libdns_tor_port = 0; /* Start again with the default port. */
+ }
+#else
+ (void)force;
+#endif
}
#ifdef USE_LIBDNS
-/* Helper to test whether we need totry again after having swicthed
+/* Helper to test whether we need to try again after having switched
* the Tor port. */
static int
libdns_switch_port_p (gpg_error_t err)
err = gpg_error_from_syserror ();
goto leave;
}
+ /* Libdns appends the root zone part which is problematic
+ * for most other functions - strip it. */
+ if (**r_canonname && (*r_canonname)[strlen (*r_canonname)-1] == '.')
+ (*r_canonname)[strlen (*r_canonname)-1] = 0;
}
dai = xtrymalloc (sizeof *dai + ent->ai_addrlen -1);
*r_cname = xtrystrdup (cname.host);
if (!*r_cname)
err = gpg_error_from_syserror ();
+ else
+ {
+ /* Libdns appends the root zone part which is problematic
+ * for most other functions - strip it. */
+ if (**r_cname && (*r_cname)[strlen (*r_cname)-1] == '.')
+ (*r_cname)[strlen (*r_cname)-1] = 0;
+ }
leave:
dns_free (ans);