Guest User

portforward.sh

a guest
Oct 16th, 2021
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. #!/bin/sh
  2. #sets script dir as working dir
  3. cd "$(dirname "$0")"
  4. PIA_CERT="ca.rsa.4096.crt"
  5. PIA_TOKEN=$(cat PIA_TOKEN)
  6. PIA_SERVER_IP=$(cat PIA_SERVER_IP)
  7. PIA_WG_CN=$(cat PIA_WG_CN)
  8.  
  9. PF_SIG="$(curl --interface oet1 --CAcert $PIA_CERT --get --silent --show-error --retry 5 --retry-delay 1 --max-time 2 --data-urlencode token=$PIA_TOKEN --resolve $PIA_WG_CN:19999:$PIA_SERVER_IP https://$PIA_WG_CN:19999/getSignature)"
  10.  
  11. echo $PF_SIG
  12. #various files are generated which are needed to run portforwardbind.sh
  13. echo $PF_SIG>PF_SIG
  14. PF_PAYLOAD_RAW="$(echo $PF_SIG | jq -r '.payload')"
  15. echo $PF_PAYLOAD_RAW>PF_PAYLOAD_RAW
  16. PF_PAYLOAD="$(echo $PF_PAYLOAD_RAW | base64 -d )"
  17. echo $PF_PAYLOAD
  18. #unworking expiry function
  19. #PF_TOKEN_EXPIRY_RAW=$(echo $PF_PAYLOAD | jq -r .expires_at)
  20. #PF_TOKEN_EXPIRY=$(date --date="$PF_TOKEN_EXPIRY_RAW" +%s)
  21. PF_GETSIGNATURE=$(echo $PF_SIG | jq -r .signature)
  22. echo $PF_GETSIGNATURE>PF_GETSIGNATURE
  23. #pulls the assigned port
  24. PF_PORT=$(echo $PF_PAYLOAD | jq -r .port)
  25. echo $PF_PORT
  26. echo $PF_PORT>PF_PORT
  27. ./portforwardbind.sh
Add Comment
Please, Sign In to add comment