mrodalgaard / alfred-network-workflow

Show and change your network settings
MIT License
261 stars 18 forks source link

Can't edit DNS list #15

Closed agemineye closed 4 years ago

agemineye commented 4 years ago

Thank you for your great work. I just installed the network workflow to toggle my DNS. However, I am facing the following problem. When I click on on "Edit DNS List", nothing happens. I also tried to manually edit the DNS list in /src/default-dns.conf but the DNS list does not change in Alfred. I would like to remove some of the DNS's and add my piHole to this list. I am using Alfred 4.0.9 (1144) on Catalina 10.15.4 (19E287). Thank you for your help.

jpuris commented 4 years ago

I've never used this feature, but you'd add DNS entries in your interfaces (Wifi, Ethernet etc) settings in system preferences => network => choose interface => Advanced... => DNS

Hope it helps as as a workaround, until this is looked at

agemineye commented 4 years ago

@jpuris Thank you for your reply. I am not sure if I am missing something, but the steps you mentioned above are for manually changing DNS on a Mac. This wouldn't let me save profiles such as Google, Cloudflare, pihole, etc., and switch between them using a shortcut. Also, this does not link to Alfred or network workflow. Kindly let me know if I have misunderstood something.

jpuris commented 4 years ago

You are absolutely correct. I did not realize such is your use case. Since I do not use this functionality, I feel I will be little of help to you.

Maybe over weekend I will take a look how this works and where the issue may be, but no promises.

agemineye commented 4 years ago

Thank you for your help.

mrodalgaard commented 4 years ago

Hi @agemineye, thank you for the kind words about this extension.

When the dns command runs the first time it copies the content of /src/default-dns.conf into Alfred's cache directory, normally located at /Users/<USER>/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/dk.rodalgaard.alfred.network/dns.conf. That is why you do not see any change happening when editing default-dsn.conf. You have to edit the config file in the cache directory instead.

Now the real issue is why it does not open that config file on your machine when you click "Edit DNS List". I use the open <FILE> shell command without arguments, which normally uses your machines default editing tool for this file extension. I believe it is initially the TextEdit application, but it changes when the user install other text editors or sets it with Finder ("Open with:..."). You might have an invalid default configuration for .conf files. Try to type open default-dns.conf in the Terminal, when you are in the same directory as the file and see what is outputtet. Afterwards type open -a TextEdit default-dns.conf.

agemineye commented 4 years ago

Hello @mrodalgaard Thank you for your kind reply. I was able to locate the .conf file in the cache directory and that did the trick. You are absolutely correct about the default program for opening .conf files again. My Mac did not know which program to use for opening .conf files. I made my default text editor (Sublime text) as the default program to open such files and now choosing the Edit DNS List option in the workflow works perfectly. Thank you for your help and contributions to the community. Cheers!