-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprivateinternetaccess.sh
More file actions
42 lines (38 loc) · 1.04 KB
/
privateinternetaccess.sh
File metadata and controls
42 lines (38 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
API_URL="https://serverlist.piaservers.net/vpninfo/servers/v6"
# Fetch JSON
json=$(curl -s "$API_URL")
# Print table header
echo "| Region Name | Country | Protocol | Server IP | CN | VAN |"
echo "|-------------|---------|----------|-----------|----|-----|"
# Parse JSON with jq and output markdown rows
echo "$json" | jq -r '
.regions[] as $region |
$region.name as $region_name |
$region.country as $country |
# For each protocol group in servers
(
$region.servers | to_entries[]
) |
# protocol name = key, servers = value (array)
.key as $protocol |
.value[] |
# Extract IP, CN and optional VAN
[
$region_name,
$country,
$protocol,
.ip,
.cn,
(.van // false | tostring)
] | @tsv
' | while IFS=$'\t' read -r region_name country protocol ip cn van; do
# Escape pipe chars
region_name=${region_name//|/\\|}
country=${country//|/\\|}
protocol=${protocol//|/\\|}
ip=${ip//|/\\|}
cn=${cn//|/\\|}
van=${van//|/\\|}
echo "| $region_name | $country | $protocol | $ip | $cn | $van |"
done