From 1f9593944f3fb5edada924b544d04f877744ec5a Mon Sep 17 00:00:00 2001 From: Xinyan Lu Date: Thu, 28 Jul 2022 16:59:33 +0800 Subject: [PATCH 1/2] Fix: fix start fail problem - the reason is why it fails is the site to get public ip no longer work - replace it with an new site --- .gitignore | 2 ++ mtproxy.sh | 16 ++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..68729d6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea/ +.DS_Store \ No newline at end of file diff --git a/mtproxy.sh b/mtproxy.sh index e83d085..d3bb82f 100644 --- a/mtproxy.sh +++ b/mtproxy.sh @@ -177,8 +177,8 @@ config_mtp(){ done # config info - public_ip=$(curl -s https://api.ip.sb/ip --ipv4) - [ -z "$public_ip" ] && public_ip=$(curl -s ipinfo.io/ip --ipv4) + public_ip=$(curl -s ip.sb --ipv4) + [ -z "$public_ip" ] && public_ip=$(curl -s ip.sb --ipv4) secret=$(head -c 16 /dev/urandom | xxd -ps) # proxy tag @@ -230,8 +230,8 @@ info_mtp(){ status_mtp if [ $? == 1 ];then source ./mtp_config - public_ip=$(curl -s https://api.ip.sb/ip --ipv4) - [ -z "$public_ip" ] && public_ip=$(curl -s ipinfo.io/ip --ipv4) + public_ip=$(curl -s ip.sb --ipv4) + [ -z "$public_ip" ] && public_ip=$(curl -s ip.sb --ipv4) domain_hex=$(xxd -pu <<< $domain | sed 's/0a//g') client_secret="ee${secret}${domain_hex}" echo -e "TMProxy+TLS代理: \033[32m运行中\033[0m" @@ -255,8 +255,8 @@ run_mtp(){ curl -s https://core.telegram.org/getProxyConfig -o proxy-multi.conf source ./mtp_config nat_ip=$(echo $(ip a | grep inet | grep -v 127.0.0.1 | grep -v inet6 | awk '{print $2}' | cut -d "/" -f1 |awk 'NR==1 {print $1}')) - public_ip=`curl -s https://api.ip.sb/ip --ipv4` - [ -z "$public_ip" ] && public_ip=$(curl -s ipinfo.io/ip --ipv4) + public_ip=`curl -s ip.sb --ipv4` + [ -z "$public_ip" ] && public_ip=$(curl -s ip.sb --ipv4) nat_info="" if [[ $nat_ip != $public_ip ]];then nat_info="--nat-info ${nat_ip}:${public_ip}" @@ -264,7 +264,7 @@ run_mtp(){ tag_arg="" [[ -n "$proxy_tag" ]] && tag_arg="-P $proxy_tag" ./mtproto-proxy -u nobody -p $web_port -H $port -S $secret --aes-pwd proxy-secret proxy-multi.conf -M 1 $tag_arg --domain $domain $nat_info >/dev/null 2>&1 & - + echo $!>$pid_file sleep 2 info_mtp @@ -275,7 +275,7 @@ debug_mtp(){ cd $WORKDIR source ./mtp_config nat_ip=$(echo $(ip a | grep inet | grep -v 127.0.0.1 | grep -v inet6 | awk '{print $2}' | cut -d "/" -f1 |awk 'NR==1 {print $1}')) - public_ip=`curl -s https://api.ip.sb/ip --ipv4` + public_ip=`curl -s ip.sb --ipv4` [ -z "$public_ip" ] && public_ip=$(curl -s ipinfo.io/ip --ipv4) nat_info="" if [[ $nat_ip != $public_ip ]];then From be215947a7852104a7da92402b5f2e2651233d99 Mon Sep 17 00:00:00 2001 From: Xinyan Lu Date: Thu, 28 Jul 2022 17:11:34 +0800 Subject: [PATCH 2/2] Doc: add how to open port doc --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 1075a6a..f1bbae7 100644 --- a/README.md +++ b/README.md @@ -60,3 +60,13 @@ vi /etc/crontab @reboot root nohup bash /home/mtproxy/mtproxy.sh start > /dev/null 2>&1 & ``` + +## 服务器设置 + +如果启动后如果无法访问,请检查一下服务器的端口是否打开了 +以下以centos7 为例 +```bash +firewall-cmd --zone=public --add-port={your_port}/tcp --permanet +systemctl restart firewalld.service +firewalld-cmd --list-ports +``` \ No newline at end of file