From ba04476c66a8f894a14ce81fb81f03948be2b9a0 Mon Sep 17 00:00:00 2001 From: Charlot Date: Thu, 9 Apr 2020 22:11:57 +0200 Subject: [PATCH] Add dns suffix information to informative message --- src/io.c | 4 +++- src/ipv4.h | 4 ++++ src/xml.c | 1 + src/xml.h | 4 ---- tests/lint/line_length.py | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/io.c b/src/io.c index ee4f0280..a86d6ad7 100644 --- a/src/io.c +++ b/src/io.c @@ -473,7 +473,7 @@ static void *ssl_read(void *arg) if (tunnel->state == STATE_CONNECTING) { if (packet_is_ip_plus_dns(packet)) { - char line[ARRAY_SIZE("[xxx.xxx.xxx.xxx], ns [xxx.xxx.xxx.xxx, xxx.xxx.xxx.xxx]")]; + char line[ARRAY_SIZE("[xxx.xxx.xxx.xxx], ns [xxx.xxx.xxx.xxx, xxx.xxx.xxx.xxx], ns_suffix []") + MAX_DOMAIN_LENGTH]; set_tunnel_ips(tunnel, packet); strcpy(line, "["); @@ -482,6 +482,8 @@ static void *ssl_read(void *arg) strncat(line, inet_ntoa(tunnel->ipv4.ns1_addr), 15); strcat(line, ", "); strncat(line, inet_ntoa(tunnel->ipv4.ns2_addr), 15); + strcat(line, "], ns_suffix ["); + strncat(line, tunnel->ipv4.dns_suffix, MAX_DOMAIN_LENGTH); strcat(line, "]"); log_info("Got addresses: %s\n", line); } diff --git a/src/ipv4.h b/src/ipv4.h index 3c6826ee..56bf1dc9 100644 --- a/src/ipv4.h +++ b/src/ipv4.h @@ -64,6 +64,10 @@ struct rtentry { #define MAX_SPLIT_ROUTES 65535 #define STEP_SPLIT_ROUTES 32 +// see https://unix.stackexchange.com/questions/245849 +// ... /resolv-conf-limited-to-six-domains-with-a-total-of-256-characters +#define MAX_DOMAIN_LENGTH 256 + struct ipv4_config { struct in_addr ip_addr; diff --git a/src/xml.c b/src/xml.c index a4e7e140..32760dea 100644 --- a/src/xml.c +++ b/src/xml.c @@ -16,6 +16,7 @@ */ #include "xml.h" +#include "ipv4.h" #include "log.h" #include diff --git a/src/xml.h b/src/xml.h index db76a9de..aaf38027 100644 --- a/src/xml.h +++ b/src/xml.h @@ -18,10 +18,6 @@ #ifndef OPENFORTIVPN_XML_H #define OPENFORTIVPN_XML_H -#define MAX_DOMAIN_LENGTH 256 -// see https://unix.stackexchange.com/questions/245849 -// ... /resolv-conf-limited-to-six-domains-with-a-total-of-256-characters - const char *xml_find(char t, const char *tag, const char *buf, int nest); char *xml_get(const char *buf); diff --git a/tests/lint/line_length.py b/tests/lint/line_length.py index 3fc695f4..85ea9cfc 100755 --- a/tests/lint/line_length.py +++ b/tests/lint/line_length.py @@ -39,7 +39,7 @@ def endswithstring(line): True if line ends with string, False otherwise. """ - for end in ('"', '",', '");', '";', '" \\', ')];'): + for end in ('"', '",', '");', '";', '" \\', '];'): if line.endswith(end): return True return False