Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions dnscrypt-proxy-switcher.10s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,22 @@ ospatch=$(echo "$osversion" | awk -F. '{print $3}')

get_current_service() {
services=$(networksetup -listnetworkserviceorder | grep -F 'Hardware Port')
echo "$services" | while read -r line; do
while read -r line; do
sname=$(echo "$line" | awk -F "(, )|(: )|[)]" '{print $2}')
sdev=$(echo "$line" | awk -F "(, )|(: )|[)]" '{print $4}')
if [ -n "$sdev" ]; then
ifout="$(ifconfig "$sdev" 2>/dev/null)"
if echo "$ifout" | grep -Fq 'status: active'; then
currentservice="$sname"
break
if [ "$sname" == 'USB 10/100/1000 LAN' ]; then
currentservice="${sname} ($sdev)"
break
else
currentservice="$sname"
break
fi
fi
fi
done
done <<<"${services}"

if [ -n "$currentservice" ]; then
echo "$currentservice"
Expand Down