ungleich-tools/vpn-statistics.sh
2019-09-09 23:01:41 +09:00

11 lines
516 B
Bash
Executable file

#!/bin/sh
# 2019-09-09, Nico Schottelius
# Show countries / region of VPN clients connected with wireguard
# countries + region
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
# 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