Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't switch between configurations #4

Open
indeyets opened this issue Apr 14, 2018 · 6 comments · May be fixed by #7
Open

Can't switch between configurations #4

indeyets opened this issue Apr 14, 2018 · 6 comments · May be fixed by #7

Comments

@indeyets
Copy link

Am I correct, that click on "DNSCrypt" should switch resolving to local proxy? That doesn't work for me. Nothing happens when I click on it.

If I chose 127.0.0.1 manually in my network settings it correctly shows "DNSCrypt", but, again, I can not switch to "Default DNS".

I am not sure if it is a bug or just my misunderstanding of how it is supposed to work

@JayBrown
Copy link
Owner

It depends on whether the dnscrypt-proxy is actually running. You can check it with pgrep -U 0 dnscrypt-proxy. If you start the proxy from the menu, it should automatically switch to your DNSCrypt setting, which is either "DNSCrypt" or "DNSCrypt + Fallback", depending on your choice. (You can choose your preferred DNSCrypt setting by clicking on the menu icon for menu dropdown, pressing ALT, then clicking on one of two "Set As Default…" commands.)

If the proxy is running, then you can manually switch to "Default DNS", if you like. The proxy will continue to run in the background, but you won't use it, but since it's running, you can manually switch back to "DNSCrypt" or "DNSCrypt + Fallback". This means that switching to the latter two settings is not possible if the proxy is disabled.

If the proxy is not running (or if you stop the proxy from the menu), then DNSCrypt Menu should automatically load (or switch to) the "Default DNS" setting.

If you manually change the network settings, i.e. add 127.0.0.1 in System Preferences > Network > [Service] > Advanced > DNS, but dnscrypt-proxy is not running, then you won't resolve any domain names to IP addresses, i.e. web browsing etc. will not work. In this case you can either start the dnscrypt-proxy manually in the Terminal with sudo brew services start dnscrypt-proxy, or simply remove 127.0.0.1 (and all other resolvers) from Network Preferences: DNSCrypt Menu will then notice this as a network reset to "empty", and it will consequently load your "Default DNS" setting again.

@indeyets
Copy link
Author

dnscrypt-proxy is running (homebrew service, autostarted). And, as I originally wrote, I can't switch between configurations. No matter where I click the ticked item always stays the same.

I wonder if there's a way to debug this

@leoj3n
Copy link

leoj3n commented Apr 24, 2019

@indeyets I'm not having any issues using the latest version of DNSCryptMenu.30s.sh cloned from master with the v2 beta 10 version of BitBar (not available via Homebrew; brew only has version 1.9.2).

@leoj3n
Copy link

leoj3n commented May 19, 2019

Could it be that /etc/resolv.conf doesn't contain the IPs as expected by DNSCryptMenu.30s.sh?

On macOS Mojave 10.14.4, the contents of /etc/resolv.conf is prefaced with:

#
# macOS Notice
#
# This file is not consulted for DNS hostname resolution, address
# resolution, or the DNS query routing mechanism used by most
# processes on this system.
#
# To view the DNS configuration used by this system, use:
#   scutil --dns
#
# SEE ALSO
#   dns-sd(1), scutil(8)
#
# This file is automatically generated.
#

The DNSCryptMenu.30s.sh script is reading /etc/resolv.conf in the _current_resolvers function:

_current_resolvers () {
confrs=$(cat /etc/resolv.conf | awk '/^nameserver /{print $2}' | awk '!seen[$0]++' | sort)
[[ $confrs == "" ]] && exit 0
[[ $localdns ]] && confrs=$(echo "$confrs" | grep -v "$localdns")
ips=""
while read -r confr
do
[[ $ips ]] && ips="$ips "
ips="$ips$confr"
done < <(echo "$confrs")
echo "$ips"
}

And checking the results in the _displayname function:

_displayname () {
resolvers="$1"
if [[ $resolvers == $DNSCRYPT_PROXY_IPS ]] ; then
echo "DNSCrypt"
elif [[ $resolvers == "$DNSCRYPT_PROXY_IPS $ADDITIONAL_IPS" ]] ; then
echo "DNSCrypt + Fallback"
elif [[ $resolvers == $UDEFAULTS ]] ; then
if [[ $UDEFAULTS == $DNSCRYPT_PROXY_IPS ]] ; then
echo "DNSCrypt"
elif [[ $UDEFAULTS == "$DNSCRYPT_PROXY_IPS $ADDITIONAL_IPS" ]] ; then
echo "DNSCrypt + Fallback"
else
echo "Default DNS"
fi
else
echo "Other DNS"
fi
}

But as far as I can tell the /etc/resolv.conf file never contains the $ADDITIONAL_IPS, so the DNSCryptMenu.30s.sh script is always succeeding on the [[ $resolvers == $DNSCRYPT_PROXY_IPS ]] and assuming "DNSCrypt" and never "DNSCrypt + Fallback".

I don't really understand if and when (or by what program) /etc/resolv.conf is expected to be written to. It seems like the DNSCryptMenu.30s.sh script is relying on this file and perhaps making assumptions about what it will contain that may no longer be true, perhaps because of changes in macOS.

@leoj3n leoj3n linked a pull request May 19, 2019 that will close this issue
@leoj3n
Copy link

leoj3n commented May 19, 2019

@indeyets Can you try #7 and let me know if that solves your issue?

@indeyets
Copy link
Author

@leoj3n it does not, unfortunately.

I moved to https://github.com/jedisct1/bitbar-dnscrypt-proxy-switcher since then and it's been great for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants