aarond10/https_dns_proxy

Support of basic authentication in URL

Mobidient opened this issue · 1 comments

My DNS provider requires basic authentication in the URL. Would it be possible to add support for this?
I created this patch.

diff -uNr https-dns-proxy-2020-04-09/src/main.c https-dns-proxy-2020-04-09.modified/src/main.c
--- https-dns-proxy-2020-04-09/src/main.c 2020-03-15 11:23:29.000000000 +0100
+++ https-dns-proxy-2020-04-09.modified/src/main.c 0000-00-00 00:00:00.000000000 +0200
@@ -62,6 +62,16 @@
}
if (end == uri) { return 0; } // empty string.
if (!isalpha(*(end - 1))) { return 0; } // last digit non-alpha.
+
+ // basic authentication in URL
+ char *tmp;
+ if ((tmp = strchr(uri, '@'))) {
+ tmp++;
+ if (tmp < end) {
+ uri = tmp;
+ }
+ }
+
strncpy(hostname, uri, end - uri);
hostname[end - uri] = 0;
return 1;

Thanks! Done. 👍