JayBrown / DNSCrypt-Menu

Manage DNSCrypt from the macOS menu bar (BitBar plugin)
MIT License
77 stars 8 forks source link

Can't switch between configurations #4

Open indeyets opened 6 years ago

indeyets commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 5 years ago

@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 commented 5 years ago

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:

https://github.com/JayBrown/DNSCrypt-Menu/blob/cba6859660a7ee2f1f35412a61e78cb17e8e3d91/DNSCryptMenu.30s.sh#L1506-L1517

And checking the results in the _displayname function:

https://github.com/JayBrown/DNSCrypt-Menu/blob/cba6859660a7ee2f1f35412a61e78cb17e8e3d91/DNSCryptMenu.30s.sh#L1519-L1536

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 commented 5 years ago

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

indeyets commented 5 years ago

@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