mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-11-18 19:41:03 +00:00
Make specifying nameservers by name work for DBus API.
This commit is contained in:
3 files changed
+58
-18
No files matched your search
+55
-17
@@ -379,21 +379,6 @@ static DBusMessage* dbus_read_servers_ex(DBusMessage *message, int strings)
|
|||||||
strcpy(str_addr, str);
|
strcpy(str_addr, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* parse the IP address */
|
|
||||||
if ((addr_err = parse_server(str_addr, &sdetails)) ||
|
|
||||||
(addr_err = parse_server_addr(&sdetails)))
|
|
||||||
{
|
|
||||||
error = dbus_message_new_error_printf(message, DBUS_ERROR_INVALID_ARGS,
|
|
||||||
"Invalid IP address '%s': %s",
|
|
||||||
str, addr_err);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 0.0.0.0 for server address == NULL, for Dbus */
|
|
||||||
if (addr.in.sin_family == AF_INET &&
|
|
||||||
addr.in.sin_addr.s_addr == 0)
|
|
||||||
flags |= SERV_LITERAL_ADDRESS;
|
|
||||||
|
|
||||||
if (strings)
|
if (strings)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
@@ -407,7 +392,31 @@ static DBusMessage* dbus_read_servers_ex(DBusMessage *message, int strings)
|
|||||||
else
|
else
|
||||||
p = NULL;
|
p = NULL;
|
||||||
|
|
||||||
add_update_server(flags | SERV_FROM_DBUS, &addr, &source_addr, interface, str_domain, NULL);
|
if (strings && strlen(str_addr) == 0)
|
||||||
|
add_update_server(SERV_LITERAL_ADDRESS | SERV_FROM_DBUS, &addr, &source_addr, interface, str_domain, NULL);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((addr_err = parse_server(str_addr, &sdetails)))
|
||||||
|
{
|
||||||
|
error = dbus_message_new_error_printf(message, DBUS_ERROR_INVALID_ARGS,
|
||||||
|
"Invalid IP address '%s': %s",
|
||||||
|
str, addr_err);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (parse_server_next(&sdetails))
|
||||||
|
{
|
||||||
|
if ((addr_err = parse_server_addr(&sdetails)))
|
||||||
|
{
|
||||||
|
error = dbus_message_new_error_printf(message, DBUS_ERROR_INVALID_ARGS,
|
||||||
|
"Invalid IP address '%s': %s",
|
||||||
|
str, addr_err);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
add_update_server(flags | SERV_FROM_DBUS, &addr, &source_addr, interface, str_domain, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
} while ((str_domain = p));
|
} while ((str_domain = p));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -422,10 +431,39 @@ static DBusMessage* dbus_read_servers_ex(DBusMessage *message, int strings)
|
|||||||
dbus_message_iter_get_basic(&string_iter, &str);
|
dbus_message_iter_get_basic(&string_iter, &str);
|
||||||
dbus_message_iter_next (&string_iter);
|
dbus_message_iter_next (&string_iter);
|
||||||
|
|
||||||
add_update_server(flags | SERV_FROM_DBUS, &addr, &source_addr, interface, str, NULL);
|
if ((addr_err = parse_server(str_addr, &sdetails)))
|
||||||
|
{
|
||||||
|
error = dbus_message_new_error_printf(message, DBUS_ERROR_INVALID_ARGS,
|
||||||
|
"Invalid IP address '%s': %s",
|
||||||
|
str, addr_err);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (parse_server_next(&sdetails))
|
||||||
|
{
|
||||||
|
if ((addr_err = parse_server_addr(&sdetails)))
|
||||||
|
{
|
||||||
|
error = dbus_message_new_error_printf(message, DBUS_ERROR_INVALID_ARGS,
|
||||||
|
"Invalid IP address '%s': %s",
|
||||||
|
str, addr_err);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 0.0.0.0 for server address == NULL, for Dbus */
|
||||||
|
if (addr.in.sin_family == AF_INET &&
|
||||||
|
addr.in.sin_addr.s_addr == 0)
|
||||||
|
flags |= SERV_LITERAL_ADDRESS;
|
||||||
|
else
|
||||||
|
flags &= ~SERV_LITERAL_ADDRESS;
|
||||||
|
|
||||||
|
add_update_server(flags | SERV_FROM_DBUS, &addr, &source_addr, interface, str, NULL);
|
||||||
|
}
|
||||||
} while (dbus_message_iter_get_arg_type(&string_iter) == DBUS_TYPE_STRING);
|
} while (dbus_message_iter_get_arg_type(&string_iter) == DBUS_TYPE_STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sdetails.resolved)
|
||||||
|
freeaddrinfo(sdetails.hostinfo);
|
||||||
|
|
||||||
/* jump to next element in outer array */
|
/* jump to next element in outer array */
|
||||||
dbus_message_iter_next(&array_iter);
|
dbus_message_iter_next(&array_iter);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1478,6 +1478,7 @@ void reset_option_bool(unsigned int opt);
|
|||||||
struct hostsfile *expand_filelist(struct hostsfile *list);
|
struct hostsfile *expand_filelist(struct hostsfile *list);
|
||||||
char *parse_server(char *arg, struct server_details *sdetails);
|
char *parse_server(char *arg, struct server_details *sdetails);
|
||||||
char *parse_server_addr(struct server_details *sdetails);
|
char *parse_server_addr(struct server_details *sdetails);
|
||||||
|
int parse_server_next(struct server_details *sdetails);
|
||||||
int option_read_dynfile(char *file, int flags);
|
int option_read_dynfile(char *file, int flags);
|
||||||
|
|
||||||
/* forward.c */
|
/* forward.c */
|
||||||
|
|||||||
+2
-1
@@ -1049,10 +1049,11 @@ char *parse_server_addr(struct server_details *sdetails)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
return _("bad address");
|
return _("bad address");
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_server_next(struct server_details *sdetails)
|
int parse_server_next(struct server_details *sdetails)
|
||||||
{
|
{
|
||||||
/* Looping over resolved addresses? */
|
/* Looping over resolved addresses? */
|
||||||
if (sdetails->hostinfo)
|
if (sdetails->hostinfo)
|
||||||
|
|||||||
Reference in new issue
Block a user