port-ws.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/bin/bash
  2. red='\e[1;31m'
  3. green='\e[0;32m'
  4. NC='\e[0m'
  5. MYIP=$(wget -qO- https://icanhazip.com);
  6. echo "Checking VPS"
  7. clear
  8. tls="$(cat ~/log-install.txt | grep -w "Vmess TLS" | cut -d: -f2|sed 's/ //g')"
  9. none="$(cat ~/log-install.txt | grep -w "Vmess None TLS" | cut -d: -f2|sed 's/ //g')"
  10. echo -e "======================================"
  11. echo -e ""
  12. echo -e " [1] Change Port Vmess TLS $tls"
  13. echo -e " [2] Change Port Vmess None TLS $none"
  14. echo -e " [x] Exit"
  15. echo -e "======================================"
  16. echo -e ""
  17. read -p " Select From Options [1-2 or x] : " prot
  18. echo -e ""
  19. case $prot in
  20. 1)
  21. read -p "New Port Vmess TLS: " tls1
  22. if [ -z $tls1 ]; then
  23. echo "Please Input Port"
  24. exit 0
  25. fi
  26. cek=$(netstat -nutlp | grep -w $tls1)
  27. if [[ -z $cek ]]; then
  28. sed -i "s/$tls/$tls1/g" /etc/v2ray/config.json
  29. sed -i "s/ - V2RAY Vmess TLS : $tls/ - V2RAY Vmess TLS : $tls1/g" /root/log-install.txt
  30. iptables -D INPUT -m state --state NEW -m tcp -p tcp --dport $tls -j ACCEPT
  31. iptables -D INPUT -m state --state NEW -m udp -p udp --dport $tls -j ACCEPT
  32. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport $tls1 -j ACCEPT
  33. iptables -I INPUT -m state --state NEW -m udp -p udp --dport $tls1 -j ACCEPT
  34. iptables-save > /etc/iptables.up.rules
  35. iptables-restore -t < /etc/iptables.up.rules
  36. netfilter-persistent save > /dev/null
  37. netfilter-persistent reload > /dev/null
  38. systemctl restart v2ray > /dev/null
  39. echo -e "\e[032;1mPort $tls1 modified successfully\e[0m"
  40. else
  41. echo "Port $tls1 is used"
  42. fi
  43. ;;
  44. 2)
  45. echo "Input Only 2 Character (eg : 69)"
  46. read -p "New Port Vmess None TLS: " none1
  47. if [ -z $none1 ]; then
  48. echo "Please Input Port"
  49. exit 0
  50. fi
  51. cek=$(netstat -nutlp | grep -w $none1)
  52. if [[ -z $cek ]]; then
  53. sed -i "s/$none/$none1/g" /etc/v2ray/none.json
  54. sed -i "s/ - V2RAY Vmess None TLS : $none/ - V2RAY Vmess None TLS : $none1/g" /root/log-install.txt
  55. iptables -D INPUT -m state --state NEW -m tcp -p tcp --dport $none -j ACCEPT
  56. iptables -D INPUT -m state --state NEW -m udp -p udp --dport $none -j ACCEPT
  57. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport $none1 -j ACCEPT
  58. iptables -I INPUT -m state --state NEW -m udp -p udp --dport $none1 -j ACCEPT
  59. iptables-save > /etc/iptables.up.rules
  60. iptables-restore -t < /etc/iptables.up.rules
  61. netfilter-persistent save > /dev/null
  62. netfilter-persistent reload > /dev/null
  63. systemctl restart v2ray@none > /dev/null
  64. echo -e "\e[032;1mPort $none1 modified successfully\e[0m"
  65. else
  66. echo "Port $none1 is used"
  67. fi
  68. ;;
  69. x)
  70. exit
  71. menu
  72. ;;
  73. *)
  74. echo "Please enter an correct number"
  75. ;;
  76. esac