port-trgo.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. red='\e[1;31m'
  3. green='\e[0;32m'
  4. NC='\e[0m'
  5. MYIP=$(wget -qO- ifconfig.me/ip);
  6. echo "Checking VPS"
  7. clear
  8. tr="$(cat ~/log-install.txt | grep -w "Trojan GO" | cut -d: -f2|sed 's/ //g')"
  9. echo -e "Name : Change Port Trojan GO"
  10. echo -e "============================" | lolcat
  11. echo -e "Change Port $tr"
  12. read -p "New Port Trojan-go: " tr2
  13. if [ -z $tr2 ]; then
  14. echo "Please Input Port"
  15. exit 0
  16. fi
  17. cek=$(netstat -nutlp | grep -w $tr2)
  18. if [[ -z $cek ]]; then
  19. sed -i "s/$tr/$tr2/g" /etc/trojan-go/config.json
  20. sed -i "s/ - Trojan GO : $tr/ - Trojan GO : $tr2/g" /root/log-install.txt
  21. iptables -D INPUT -m state --state NEW -m tcp -p tcp --dport $tr -j ACCEPT
  22. iptables -D INPUT -m state --state NEW -m udp -p udp --dport $tr -j ACCEPT
  23. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport $tr2 -j ACCEPT
  24. iptables -I INPUT -m state --state NEW -m udp -p udp --dport $tr2 -j ACCEPT
  25. iptables-save > /etc/iptables.up.rules
  26. iptables-restore -t < /etc/iptables.up.rules
  27. netfilter-persistent save > /dev/null
  28. netfilter-persistent reload > /dev/null
  29. systemctl restart trojan-go > /dev/null
  30. echo -e "\e[032;1mPort $tr2 modified successfully\e[0m"
  31. else
  32. echo "Port $tr2 is used"
  33. fi