matryer / matryer/xbar-plugins

dnscrypt-proxy-switcher doesn't work if user has manually changed interface name

Open
#2,060 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Shell
Stars
2.6k
Forks
1.1k
Avg merge
9d 15h
Merged PRs (30d)
1

Description

In recent MacOS, the user is able to manually change the name of the network interface in the "Network" pane of the System Settings. If the user does this, then the **dnscrypt-proxy-switcher** script fails for that interface as the script is trying to use the hardware interface name, not the network interface name and then the '`networksetup -setdnsservers`' call fails.

Fortunately, there is a simple fix. Line 63 of the script needs to be changed.
Old line 63: `currentservice="$sname"`
New line 63: `currentservice=$(networksetup -listnetworkserviceorder | grep -B1 "Device: $sdev" | head -n1 | sed 's/^([0-9]*) //')`

This new line takes the active network interface (e.g., 'en3') and then uses the `networksetup` tool to find the interface name associated with that network interface.

In addition line 58 (`sname=$(echo "$line" | awk -F "(, )|(: )|[)]" '{print $2}')`) can now be commented out as it is unnecessary.

Contributor guide

Open the contributing guide

Research direction

Open the dnscrypt-proxy-switcher script and inspect lines 58 and 63. Verify the network service lookup with networksetup; done means manually renamed macOS interfaces no longer cause the networksetup -setdnsservers call to fail.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, shell
Domain
cli, operating-systems
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.