port-xvless.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- ifconfig.me/ip);
  6. echo "Checking VPS"
  7. clear
  8. tls="$(cat ~/log-install.txt | grep -w "XRAY VLESS TCP" | cut -d: -f2|sed 's/ //g')"
  9. none="$(cat ~/log-install.txt | grep -w "XRAY VLESS None TCP" | cut -d: -f2|sed 's/ //g')"
  10. echo -e "======================================"
  11. echo -e " Change Port XRAY Vless"
  12. echo -e ""
  13. echo -e " [1] Change Port XRAY VLESS TCP $tls"
  14. echo -e " [2] Change Port XRAY VLESS None TCP $none"
  15. echo -e " [x] Exit"
  16. echo -e "======================================"
  17. echo -e ""
  18. read -p " Select From Options [1-2 or x] : " prot
  19. echo -e ""
  20. case $prot in
  21. 1)
  22. read -p "New Port XRAY Vless TCP: " tls1
  23. if [ -z $tls1 ]; then
  24. echo "Please Input Port"
  25. exit 0
  26. fi
  27. cek=$(netstat -nutlp | grep -w $tls1)
  28. if [[ -z $cek ]]; then
  29. sed -i "s/$tls/$tls1/g" /etc/xray/vlesstls.json
  30. sed -i "s/ - XRAY VLESS TCP : $tls/ - XRAY VLESS TCP : $tls1/g" /root/log-install.txt
  31. iptables -D INPUT -m state --state NEW -m tcp -p tcp --dport $tls -j ACCEPT
  32. iptables -D INPUT -m state --state NEW -m udp -p udp --dport $tls -j ACCEPT
  33. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport $tls1 -j ACCEPT
  34. iptables -I INPUT -m state --state NEW -m udp -p udp --dport $tls1 -j ACCEPT
  35. iptables-save > /etc/iptables.up.rules
  36. iptables-restore -t < /etc/iptables.up.rules
  37. netfilter-persistent save > /dev/null
  38. netfilter-persistent reload > /dev/null
  39. systemctl restart xray@vlesstls > /dev/null
  40. echo -e "\e[032;1mPort $tls1 modified successfully\e[0m"
  41. else
  42. echo "Port $tls1 is used"
  43. fi
  44. ;;
  45. 2)
  46. read -p "New Port XRAY VLESS None TCP: " 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/xray/vlessnone.json
  54. sed -i "s/ - XRAY VLESS None TCP : $none/ - XRAY VLESS None TCP : $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 xray@vlessnone > /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