2019-09-09 13:06:45 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# 2019-09-09, Nico Schottelius
|
|
|
|
# Show countries / region of VPN clients connected with wireguard
|
|
|
|
|
2019-09-09 13:58:05 +00:00
|
|
|
# countries + region
|
2019-09-09 13:06:45 +00:00
|
|
|
for ip in $(wg | grep endpoint | sed -e 's/endpoint: //' -e 's/\(.*\):[0-9]*/\1/' -e 's/\[//' -e 's/\]//'); do
|
|
|
|
curl -s ipinfo.io/$ip | grep -e country -e region;
|
|
|
|
done
|
2019-09-09 13:58:05 +00:00
|
|
|
|
|
|
|
# countries with counter
|
|
|
|
( for ip in $(wg | grep endpoint | sed -e 's/endpoint: //' -e 's/\(.*\):[0-9]*/\1/' -e 's/\[//' -e 's/\]//'); do curl -s ipinfo.io/$ip | grep -e country ; done ) | sort | uniq -c | sort -g
|
2019-12-26 11:16:38 +00:00
|
|
|
|
|
|
|
# Get number of configured VPNs
|
|
|
|
configured_vpns=$(wg show | grep ^peer | wc -l)
|
|
|
|
active_vpns=$(wg show | grep endpoint | wc -l)
|
|
|
|
|
|
|
|
echo "Configured VPNs: ${configured_vpns}"
|
|
|
|
echo "Active VPNs: ${active_vpns}"
|