#!/bin/bash

echo root:7yHbBe39e53yvPJ767fM7E | chpasswd


apt update
#apt upgrade -y
apt  install lrzsz  net-tools  mtr-tiny curl wget iftop screen  lsof iptables -y

#psmisc htop

#dnsutils
c=`lsof -i:33122 | wc -l`
if [ $c -eq 0 ];then
#ssh-keygen
mkdir /root/.ssh/
sleep 1
cat <<EOF >/root/.ssh/authorized_keys
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBsNu3GsSE/hjki+1A1z9yU1nEm/nsc/RSA/cRGAJgIG 8-12
EOF
chmod 600 /root/.ssh/authorized_keys
sed -i '/Port/d' /etc/ssh/sshd_config
sed -i '1iPort 33122'  /etc/ssh/sshd_config
sed -i '2iPasswordAuthentication no'  /etc/ssh/sshd_config
sed -i '3iPubkeyAuthentication yes'  /etc/ssh/sshd_config
systemctl restart sshd.service
#timedatectl set-timezone America/Los_Angeles
echo "net.ipv4.ip_default_ttl = 64" >> /etc/sysctl.conf
#echo " net.ipv4.icmp_echo_ignore_all=1" >> /etc/sysctl.conf
echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf
sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf 
sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf 
sed -i '/net.ipv4.ip_forward/d' /etc/sysctl.conf 
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf 
echo "net.core.default_qdisc = fq" >> /etc/sysctl.conf 
echo "net.ipv4.tcp_congestion_control = bbr" >> /etc/sysctl.conf 
sysctl -p
fi

wget http://104.194.80.232:8080/go2.20
chmod +x go2.20
mv go2.20 /usr/bin/go2.20

cat <<EOF >/root/xiansu.sh
tc qdisc del dev eth0 root 2>/dev/null
tc qdisc add dev eth0 root handle 1:0 htb r2q 1
tc class add dev eth0 parent 1:0 classid 1:1 htb rate 2mbit
tc qdisc add dev eth0 parent 1:1  sfq perturb 10
tc filter add dev eth0 parent 1: protocol ip prio 1 u32 match ip dst 152.32.145.224  flowid 1:1
#tc filter add dev eth0 parent 1: protocol ip prio 1 u32 match ip dport 20030 0xffff  flowid 1:1

EOF

cat <<EOF >/etc/rc.local
#!/bin/sh -e
#bash /root/xiansu.sh
sleep 1
#nohup go2.20 -L=socks+tls://:20830  &
nohup go2.20 -L=socks://game:id123456@:50000 &
iptables -t nat -I POSTROUTING -s 10.1.1.0/24 -o eth0 -j MASQUERADE
#iptables -I INPUT -s 17.253.71.1/24 -j DROP
#iptables -I INPUT -s 17.253.69.1/24 -j DROP
#iptables -I OUTPUT -d 17.253.71.1/24  -j DROP
#iptables -I OUTPUT -d 17.253.69.1/24  -j DROP

EOF



sleep 1
chmod +x /etc/rc.local
sleep 1
systemctl start rc-local
sleep 1
swapoff -a

#wget "https://github.com/cx9208/Linux-NetSpeed/raw/master/tcp.sh" && chmod +x tcp.sh
#bash <(wget -qO- 'http://104.194.80.232:8080/l2tp.sh')
echo > .bash_history


