diff options
author | Matthias Gerstner <matthias.gerstner@suse.de> | 2022-02-17 12:31:11 +0100 |
---|---|---|
committer | Daniel Wagner <wagi@monom.org> | 2022-02-21 09:38:07 +0100 |
commit | 7d421aaebf2d5b1d95cb24b8d5b368fa7af9b1d9 (patch) | |
tree | 580ec95029101dd80fdc61b20b973d8af0dbe642 | |
parent | 0b965e03cc39afc371f637dea293756acfc7b136 (diff) | |
download | connman-7d421aaebf2d5b1d95cb24b8d5b368fa7af9b1d9.tar.gz |
dnsproxy: support programmatic configuration of the default listen port
This way a test instance of dnsproxy can be setup that listens on an
unprivileged port for easier testing as non-root.
-rw-r--r-- | src/connman.h | 1 | ||||
-rw-r--r-- | src/dnsproxy.c | 10 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/connman.h b/src/connman.h index 68176086..909b53ae 100644 --- a/src/connman.h +++ b/src/connman.h @@ -983,6 +983,7 @@ void __connman_dnsproxy_remove_listener(int index); int __connman_dnsproxy_append(int index, const char *domain, const char *server); int __connman_dnsproxy_remove(int index, const char *domain, const char *server); int __connman_dnsproxy_set_mdns(int index, bool enabled); +void __connman_dnsproxy_set_listen_port(unsigned int port); int __connman_6to4_probe(struct connman_service *service); void __connman_6to4_remove(struct connman_ipconfig *ipconfig); diff --git a/src/dnsproxy.c b/src/dnsproxy.c index 95791e67..22730047 100644 --- a/src/dnsproxy.c +++ b/src/dnsproxy.c @@ -223,6 +223,7 @@ static GHashTable *listener_table = NULL; static time_t next_refresh; static GHashTable *partial_tcp_req_table; static guint cache_timer = 0; +static in_port_t dns_listen_port = 53; static guint16 get_id(void) { @@ -3704,7 +3705,7 @@ static GIOChannel *get_listener(int family, int protocol, int index) if (family == AF_INET6) { memset(&s.sin6, 0, sizeof(s.sin6)); s.sin6.sin6_family = AF_INET6; - s.sin6.sin6_port = htons(53); + s.sin6.sin6_port = htons(dns_listen_port); slen = sizeof(s.sin6); if (__connman_inet_get_interface_address(index, @@ -3721,7 +3722,7 @@ static GIOChannel *get_listener(int family, int protocol, int index) } else if (family == AF_INET) { memset(&s.sin, 0, sizeof(s.sin)); s.sin.sin_family = AF_INET; - s.sin.sin_port = htons(53); + s.sin.sin_port = htons(dns_listen_port); slen = sizeof(s.sin); if (__connman_inet_get_interface_address(index, @@ -4050,3 +4051,8 @@ void __connman_dnsproxy_cleanup(void) if (ipv6_resolve) g_resolv_unref(ipv6_resolve); } + +void __connman_dnsproxy_set_listen_port(unsigned int port) +{ + dns_listen_port = port; +} |