rokkonet

PC・Androidソフトウェア・アプリの開発・使い方に関するメモ

VPN Gateサーバー ポート番号の取得

2020 May 24.


CSVリスト( http://www.vpngate.net/api/iphone/ )の第15列の"OpenVPN_ConfigData_Base64"にポート番号情報が含まれている
・"OpenVPN_ConfigData_Base64"はbase64エンコードされている
・ポート番号は remote で始まる行に remote IP-ADDRESS PORT の形式で記載されている
・取得したポート番号文字列の末尾には改行(CR/LF)が含まれている

shell

$ ServerIP=VPN.GATE.SERVER.ADDRESS
$ PortNum=`wget http://www.vpngate.net/api/iphone/ -O - 2> /dev/null | grep ${ServerIP} | cut -d, -f15 | base64 -d 2> /dev/null | grep -P '^remote' | cut -d' ' -f3 |  sed -e "s/[\r\n]//"`