diff --git a/menu.sh b/menu.sh index 2810ee8..9d6f695 100644 --- a/menu.sh +++ b/menu.sh @@ -468,26 +468,26 @@ proxy_info() { unset PROXYSOCKS5 PROXYPORT PROXYJASON PROXYIP PROXYCOUNTR PROXYASNORG ACCOUNT QUOTA AC PROXYSOCKS52 PROXYPORT2 PROXYJASON2 PROXYIP2 PROXYCOUNTR2 PROXYASNORG2 ACCOUNT2 AC2 TRACE42 if type -p warp-cli >/dev/null 2>&1; then - PROXYSOCKS5=$(ss -nltp | grep 'warp' | grep -oP '127.0*\S+') - PROXYPORT=$(echo $PROXYSOCKS5 | cut -d: -f2) - PROXYJASON=$(curl -sx socks5h://localhost:$PROXYPORT https://ip.gs/json) - PROXYIP=$(expr "$PROXYJASON" : '.*ip\":\"\([^"]*\).*') - PROXYCOUNTRY=$(expr "$PROXYJASON" : '.*country\":\"\([^"]*\).*') - [[ $L = C ]] && PROXYCOUNTRY=$(translate "$PROXYCOUNTRY") - PROXYASNORG=$(expr "$PROXYJASON" : '.*asn_org\":\"\([^"]*\).*') - ACCOUNT=$(warp-cli --accept-tos account 2>/dev/null) - [[ $ACCOUNT =~ 'Limited' ]] && AC='+' && check_quota + PROXYSOCKS5=$(ss -nltp | grep 'warp' | grep -oP '127.0*\S+') + PROXYPORT=$(echo $PROXYSOCKS5 | cut -d: -f2) + PROXYJASON=$(curl -sx socks5h://localhost:$PROXYPORT https://ip.gs/json) + PROXYIP=$(expr "$PROXYJASON" : '.*ip\":\"\([^"]*\).*') + PROXYCOUNTRY=$(expr "$PROXYJASON" : '.*country\":\"\([^"]*\).*') + [[ $L = C ]] && PROXYCOUNTRY=$(translate "$PROXYCOUNTRY") + PROXYASNORG=$(expr "$PROXYJASON" : '.*asn_org\":\"\([^"]*\).*') + ACCOUNT=$(warp-cli --accept-tos account 2>/dev/null) + [[ $ACCOUNT =~ 'Limited' ]] && AC='+' && check_quota fi if type -p wireproxy >/dev/null 2>&1; then - PROXYSOCKS52=$(ss -nltp | grep 'wireproxy' | grep -oP '127.0*\S+') - PROXYPORT2=$(echo $PROXYSOCKS52 | cut -d: -f2) - PROXYJASON2=$(curl -sx socks5h://localhost:$PROXYPORT2 https://ip.gs/json) - PROXYIP2=$(expr "$PROXYJASON2" : '.*ip\":\"\([^"]*\).*') - PROXYCOUNTRY2=$(expr "$PROXYJASON2" : '.*country\":\"\([^"]*\).*') - [[ $L = C ]] && PROXYCOUNTRY2=$(translate "$PROXYCOUNTRY2") - PROXYASNORG2=$(expr "$PROXYJASON2" : '.*asn_org\":\"\([^"]*\).*') - TRACE42=$(eval echo "\$(curl -sx socks5h://localhost:$(ss -nltp | grep wireproxy | grep -oP '127.0*\S+' | cut -d: -f2) https://www.cloudflare.com/cdn-cgi/trace)") + PROXYSOCKS52=$(ss -nltp | grep 'wireproxy' | grep -oP '127.0*\S+') + PROXYPORT2=$(echo $PROXYSOCKS52 | cut -d: -f2) + PROXYJASON2=$(curl -sx socks5h://localhost:$PROXYPORT2 https://ip.gs/json) + PROXYIP2=$(expr "$PROXYJASON2" : '.*ip\":\"\([^"]*\).*') + PROXYCOUNTRY2=$(expr "$PROXYJASON2" : '.*country\":\"\([^"]*\).*') + [[ $L = C ]] && PROXYCOUNTRY2=$(translate "$PROXYCOUNTRY2") + PROXYASNORG2=$(expr "$PROXYJASON2" : '.*asn_org\":\"\([^"]*\).*') + TRACE42=$(eval echo "\$(curl -sx socks5h://localhost:$(ss -nltp | grep wireproxy | grep -oP '127.0*\S+' | cut -d: -f2) https://www.cloudflare.com/cdn-cgi/trace)") if [[ $TRACE42 =~ plus ]]; then grep -sq 'Device name' /etc/wireguard/info.log && AC2='+' && check_quota || AC2=' Teams' fi @@ -564,9 +564,10 @@ change_ip() { grep -q "^#.*0\.\0\/0" /etc/wireguard/wgcf.conf && T4=0 || T4=1 grep -q "^#.*\:\:\/0" /etc/wireguard/wgcf.conf && T6=0 || T6=1 case "$T4$T6" in - 01 ) NF='6';; 10 ) NF='4';; - 11 ) hint "\n $(text 124) \n" && reading " $(text 50) " NETFLIX - NF='4' && [[ $NETFLIX = 2 ]] && NF='6';; + 01 ) NF='6';; + 10 ) NF='4';; + 11 ) hint "\n $(text 124) \n" && reading " $(text 50) " NETFLIX + NF='4' && [[ $NETFLIX = 2 ]] && NF='6';; esac [[ -z "$EXPECT" ]] && input_region @@ -722,12 +723,13 @@ uninstall() { uninstall_wgcf() { wg-quick down wgcf >/dev/null 2>&1 systemctl disable --now wg-quick@wgcf >/dev/null 2>&1 - rpm -e wireguard-tools 2>/dev/null - [[ $(systemctl is-active systemd-resolved 2>/dev/null) != active ]] && systemctl enable --now systemd-resolved >/dev/null 2>&1 + type -p rpm >/dev/null 2>&1 && rpm -e wireguard-tools 2>/dev/null + systemctl start systemd-resolved >/dev/null 2>&1 && sleep 5 + systemctl enable --now systemd-resolved >/dev/null 2>&1 rm -rf /usr/bin/wgcf /etc/wireguard /usr/bin/wireguard-go wgcf-account.toml wgcf-profile.conf /usr/bin/warp /etc/dnsmasq.d/warp.conf /usr/bin/wireproxy /etc/local.d/wgcf.start - [[ -e /etc/gai.conf ]] && sed -i '/^precedence \:\:ffff\:0\:0/d;/^label 2002\:\:\/16/d' /etc/gai.conf - [[ -e /usr/bin/tun.sh ]] && rm -f /usr/bin/tun.sh - [[ -e /etc/crontab ]] && sed -i '/tun.sh/d' /etc/crontab + [ -e /etc/gai.conf ] && sed -i '/^precedence \:\:ffff\:0\:0/d;/^label 2002\:\:\/16/d' /etc/gai.conf + [ -e /usr/bin/tun.sh ] && rm -f /usr/bin/tun.sh + [ -e /etc/crontab ] && sed -i '/tun.sh/d' /etc/crontab sed -i "/250 warp/d" /etc/iproute2/rt_tables } @@ -747,8 +749,8 @@ uninstall() { uninstall_wireproxy() { systemctl disable --now wireproxy rm -rf /usr/bin/wgcf /etc/wireguard /usr/bin/wireguard-go wgcf-account.toml wgcf-profile.conf /usr/bin/warp /etc/dnsmasq.d/warp.conf /usr/bin/wireproxy /lib/systemd/system/wireproxy.service - [[ -e /etc/gai.conf ]] && sed -i '/^precedence \:\:ffff\:0\:0/d;/^label 2002\:\:\/16/d' /etc/gai.conf - [[ -e /usr/bin/tun.sh ]] && rm -f /usr/bin/tun.sh && sed -i '/tun.sh/d' /etc/crontab + [ -e /etc/gai.conf ] && sed -i '/^precedence \:\:ffff\:0\:0/d;/^label 2002\:\:\/16/d' /etc/gai.conf + [ -e /usr/bin/tun.sh ] && rm -f /usr/bin/tun.sh && sed -i '/tun.sh/d' /etc/crontab } # 如已安装 warp_unlock 项目,先行卸载 @@ -758,11 +760,13 @@ uninstall() { UNINSTALL_CHECK=("wg-quick" "warp-cli" "wireproxy") UNINSTALL_DO=("uninstall_wgcf" "uninstall_proxy" "uninstall_wireproxy") UNINSTALL_DEPENDENCIES=("wireguard-tools openresolv " "" " openresolv ") - UNINSTALL_NOT_ARCH=("wireguard-dkms ipset dnsmasq resolvconf " "" "wireguard-dkms resolvconf ") + UNINSTALL_NOT_ARCH=("wireguard-dkms " "" "wireguard-dkms resolvconf ") + UNINSTALL_DNSMASQ=("ipset dnsmasq resolvconf ") UNINSTALL_RESULT=("$(text 117)" "$(text 119)" "$(text 98)") for ((i=0; i<${#UNINSTALL_CHECK[@]}; i++)); do - type -p ${UNINSTALL_CHECK[i]} >/dev/null 2>&1 && UNINSTALL_DO_LIST[i]=1 && UNINSTALL_DEPENDENCIES_LIST+=${UNINSTALL_DEPENDENCIES[i]} && - [[ $SYSTEM != "Arch" ]] && UNINSTALL_DEPENDENCIES_LIST+=${UNINSTALL_NOT_ARCH[i]} + type -p ${UNINSTALL_CHECK[i]} >/dev/null 2>&1 && UNINSTALL_DO_LIST[i]=1 && UNINSTALL_DEPENDENCIES_LIST+=${UNINSTALL_DEPENDENCIES[i]} + [[ $SYSTEM != "Arch" && $(dkms status 2>/dev/null) =~ "wireguard" ]] && UNINSTALL_DEPENDENCIES_LIST+=${UNINSTALL_NOT_ARCH[i]} + [ -e /etc/dnsmasq.d/warp.conf ] && UNINSTALL_DEPENDENCIES_LIST+=${UNINSTALL_DNSMASQ[i]} done # 列出依赖,确认是手动还是自动卸载 @@ -810,12 +814,12 @@ net() { ss -nltp | grep dnsmasq >/dev/null 2>&1 && systemctl restart dnsmasq >/dev/null 2>&1 ip4_info; ip6_info if [[ $i = "$j" ]]; then - if [[ $LICENSETYPE = 2 ]]; then + if [[ $LICENSETYPE = 2 ]]; then unset LICENSETYPE && i=0 && info " $(text 129) " && cp -f /etc/wireguard/wgcf-profile.conf /etc/wireguard/wgcf.conf else wg-quick down wgcf >/dev/null 2>&1 - warning " $(text_eval 13) " + error " $(text_eval 13) " fi fi done @@ -968,7 +972,7 @@ EOF # 判断机器原生状态类型 LAN4=$(ip route get 192.168.193.10 2>/dev/null | grep -oP 'src \K\S+') LAN6=$(ip route get 2606:4700:d0::a29f:c001 2>/dev/null | grep -oP 'src \K\S+') - if [[ "$LAN6" =~ ^[0-9a-z:]+$ ]]; then + if [[ "$LAN6" != "::1" && "$LAN6" =~ ^[0-9a-z:]+$ ]]; then INET6=1 && ping6 -c2 -w10 2606:4700:d0::a29f:c001 >/dev/null 2>&1 && IPV6=1 && CDN=-6 && ip6_info else IPV6=0 @@ -1542,7 +1546,7 @@ EOF info " IPv4: $WAN4 $WARPSTATUS4 $COUNTRY4 $ASNORG4 " info " IPv6: $WAN6 $WARPSTATUS6 $COUNTRY6 $ASNORG6 " grep -sq 'Device name' /etc/wireguard/info.log 2>/dev/null && TYPE='+' || TYPE=' Teams' - [[ $TRACE4$TRACE6 =~ plus ]] && info " $(text_eval 41) " && check_quota && info " $(text_eval 133) " + [[ $TRACE4$TRACE6 =~ plus ]] && info " $(text_eval 41) " && [ $TYPE = '+' ] && check_quota && info " $(text_eval 133) " [[ $TRACE4$TRACE6 =~ on ]] && info " $(text_eval 42) " info " $PRIORITY " echo -e "\n==============================================================\n" @@ -1742,7 +1746,7 @@ wireproxy_solution() { check_quota() { if [ "$CHECK_TYPE" = 1 ]; then QUOTA=$(grep -oP 'Quota: \K\d+' <<< $ACCOUNT) - else + elif [ -e /etc/wireguard/wgcf-account.toml ]; then ACCESS_TOKEN=$(grep 'access_token' /etc/wireguard/wgcf-account.toml | cut -d \' -f2) DEVICE_ID=$(grep 'device_id' /etc/wireguard/wgcf-account.toml | cut -d \' -f2) API=$(curl -s "https://api.cloudflareclient.com/v0a884/reg/$DEVICE_ID" -H "User-Agent: okhttp/3.12.1" -H "Authorization: Bearer $ACCESS_TOKEN")