summarylogtreecommitdiffstats
path: root/update-relays.sh
blob: 4a1dcc8c6ef9f1689fcc4c73cbb1478b48c31f7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
read -d '' JSONRPC_CODE <<-JSONRPC_CODE
	var buff = "";
	process.stdin.on('data', function (chunk) {
    	buff += chunk;
	})
	process.stdin.on('end', function () {
    	var obj = JSON.parse(buff);
    	var output = JSON.stringify(obj.result, null, '    ');
    	process.stdout.write(output);
	})
	JSONRPC_CODE

	JSONRPC_RESPONSE="$(curl -X POST \
		--fail \
     	-H "Content-Type: application/json" \
     	-d '{"jsonrpc": "2.0", "id": "0", "method": "relay_list_v3"}' \
     	https://api.mullvad.net/rpc/)"
	echo "$JSONRPC_RESPONSE" | node -e "$JSONRPC_CODE" >  dist-assets/relays.json