port-vless.sh 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/bin/bash
  2. red='\e[1;31m'
  3. green='\e[0;32m'
  4. NC='\e[0m'
  5. MYIP=$(wget -qO- icanhazip.com);
  6. echo "Checking VPS"
  7. clear
  8. tls="$(cat ~/log-install.txt | grep -w "Vless TLS" | cut -d: -f2|sed 's/ //g')"
  9. none="$(cat ~/log-install.txt | grep -w "Vless None TLS" | cut -d: -f2|sed 's/ //g')"
  10. echo -e "======================================"
  11. echo -e ""
  12. echo -e " [1] Change Port Vless TLS $tls"
  13. echo -e " [2] Change Port Vless 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 Vless 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/vless.json
  29. sed -i "s/ - V2RAY Vless TLS : $tls/ - V2RAY Vless 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@vless > /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. read -p "New Port Vless None TLS: " none1
  46. if [ -z $none1 ]; then
  47. echo "Please Input Port"
  48. exit 0
  49. fi
  50. cek=$(netstat -nutlp | grep -w $none1)
  51. if [[ -z $cek ]]; then
  52. sed -i "s/$none/$none1/g" /etc/v2ray/vnone.json
  53. sed -i "s/ - V2RAY Vless None TLS : $none/ - V2RAY Vless None TLS : $none1/g" /root/log-install.txt
  54. iptables -D INPUT -m state --state NEW -m tcp -p tcp --dport $none -j ACCEPT
  55. iptables -D INPUT -m state --state NEW -m udp -p udp --dport $none -j ACCEPT
  56. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport $none1 -j ACCEPT
  57. iptables -I INPUT -m state --state NEW -m udp -p udp --dport $none1 -j ACCEPT
  58. iptables-save > /etc/iptables.up.rules
  59. iptables-restore -t < /etc/iptables.up.rules
  60. netfilter-persistent save > /dev/null
  61. netfilter-persistent reload > /dev/null
  62. systemctl restart v2ray@vnone > /dev/null
  63. echo -e "\e[032;1mPort $none1 modified successfully\e[0m"
  64. else
  65. echo "Port $none1 is used"
  66. fi
  67. ;;
  68. x)
  69. exit
  70. menu
  71. ;;
  72. *)
  73. echo "Please enter an correct number"
  74. ;;
  75. esac