mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 18:28:25 +00:00
Make --clear-on-reload apply to DBus API too.
This commit is contained in:
@@ -68,6 +68,9 @@ version 2.67
|
|||||||
name to request that a FQDN option is returned in the
|
name to request that a FQDN option is returned in the
|
||||||
reply. Thanks to Roy Marples for the patch.
|
reply. Thanks to Roy Marples for the patch.
|
||||||
|
|
||||||
|
Make --clear-on-reload apply to setting upstream servers
|
||||||
|
via DBus too.
|
||||||
|
|
||||||
|
|
||||||
version 2.66
|
version 2.66
|
||||||
Add the ability to act as an authoritative DNS
|
Add the ability to act as an authoritative DNS
|
||||||
|
|||||||
@@ -338,7 +338,8 @@ by '/', like the --server syntax, eg.
|
|||||||
Don't poll /etc/resolv.conf for changes.
|
Don't poll /etc/resolv.conf for changes.
|
||||||
.TP
|
.TP
|
||||||
.B --clear-on-reload
|
.B --clear-on-reload
|
||||||
Whenever /etc/resolv.conf is re-read, clear the DNS cache.
|
Whenever /etc/resolv.conf is re-read or the upstream servers are set
|
||||||
|
via DBus, clear the DNS cache.
|
||||||
This is useful when new nameservers may have different
|
This is useful when new nameservers may have different
|
||||||
data than that held in cache.
|
data than that held in cache.
|
||||||
.TP
|
.TP
|
||||||
|
|||||||
23
src/dbus.c
23
src/dbus.c
@@ -305,8 +305,6 @@ static DBusMessage* dbus_read_servers_ex(DBusMessage *message, int strings)
|
|||||||
const char *addr_err;
|
const char *addr_err;
|
||||||
char *dup = NULL;
|
char *dup = NULL;
|
||||||
|
|
||||||
my_syslog(LOG_INFO, _("setting upstream servers from DBus"));
|
|
||||||
|
|
||||||
if (!dbus_message_iter_init(message, &iter))
|
if (!dbus_message_iter_init(message, &iter))
|
||||||
{
|
{
|
||||||
return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS,
|
return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS,
|
||||||
@@ -478,6 +476,7 @@ DBusHandlerResult message_handler(DBusConnection *connection,
|
|||||||
{
|
{
|
||||||
char *method = (char *)dbus_message_get_member(message);
|
char *method = (char *)dbus_message_get_member(message);
|
||||||
DBusMessage *reply = NULL;
|
DBusMessage *reply = NULL;
|
||||||
|
int clear_cache = 0, new_servers = 0;
|
||||||
|
|
||||||
if (dbus_message_is_method_call(message, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
|
if (dbus_message_is_method_call(message, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
|
||||||
{
|
{
|
||||||
@@ -501,25 +500,35 @@ DBusHandlerResult message_handler(DBusConnection *connection,
|
|||||||
}
|
}
|
||||||
else if (strcmp(method, "SetServers") == 0)
|
else if (strcmp(method, "SetServers") == 0)
|
||||||
{
|
{
|
||||||
my_syslog(LOG_INFO, _("setting upstream servers from DBus"));
|
|
||||||
dbus_read_servers(message);
|
dbus_read_servers(message);
|
||||||
check_servers();
|
new_servers = 1;
|
||||||
}
|
}
|
||||||
else if (strcmp(method, "SetServersEx") == 0)
|
else if (strcmp(method, "SetServersEx") == 0)
|
||||||
{
|
{
|
||||||
reply = dbus_read_servers_ex(message, 0);
|
reply = dbus_read_servers_ex(message, 0);
|
||||||
check_servers();
|
new_servers = 1;
|
||||||
}
|
}
|
||||||
else if (strcmp(method, "SetDomainServers") == 0)
|
else if (strcmp(method, "SetDomainServers") == 0)
|
||||||
{
|
{
|
||||||
reply = dbus_read_servers_ex(message, 1);
|
reply = dbus_read_servers_ex(message, 1);
|
||||||
check_servers();
|
new_servers = 1;
|
||||||
}
|
}
|
||||||
else if (strcmp(method, "ClearCache") == 0)
|
else if (strcmp(method, "ClearCache") == 0)
|
||||||
clear_cache_and_reload(dnsmasq_time());
|
clear_cache = 1;
|
||||||
else
|
else
|
||||||
return (DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
return (DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
||||||
|
|
||||||
|
if (new_servers)
|
||||||
|
{
|
||||||
|
my_syslog(LOG_INFO, _("setting upstream servers from DBus"));
|
||||||
|
check_servers();
|
||||||
|
if (option_bool(OPT_RELOAD))
|
||||||
|
clear_cache = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clear_cache)
|
||||||
|
clear_cache_and_reload(dnsmasq_time());
|
||||||
|
|
||||||
method = user_data; /* no warning */
|
method = user_data; /* no warning */
|
||||||
|
|
||||||
/* If no reply or no error, return nothing */
|
/* If no reply or no error, return nothing */
|
||||||
|
|||||||
Reference in New Issue
Block a user