aarond10 / https_dns_proxy

A lightweight DNS-over-HTTPS proxy.
MIT License
775 stars 114 forks source link

Support of basic authentication in URL #94

Closed Mobidient closed 3 years ago

Mobidient commented 3 years ago

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;

aarond10 commented 3 years ago

Thanks! Done. 👍