{"id":416,"date":"2024-10-17T10:12:58","date_gmt":"2024-10-17T02:12:58","guid":{"rendered":"https:\/\/my.di.cloudns.asia\/?p=416"},"modified":"2024-10-17T10:12:58","modified_gmt":"2024-10-17T02:12:58","slug":"cfnat-sh","status":"publish","type":"post","link":"https:\/\/my.di.cloudns.asia\/index.php\/2024\/10\/17\/416.html","title":{"rendered":"cfnat.sh"},"content":{"rendered":"<pre><code class=\"language-bash\">#!\/bin\/bash\nexport LANG=en_US.UTF-8\n\n# \u5b9a\u4e49\u989c\u8272\nre=&#039;\\e[0m&#039;\nred=&#039;\\e[1;91m&#039;\nwhite=&#039;\\e[1;97m&#039;\ngreen=&#039;\\e[1;32m&#039;\nyellow=&#039;\\e[1;33m&#039;\npurple=&#039;\\e[1;35m&#039;\nskyblue=&#039;\\e[1;96m&#039;\n\n# \u914d\u7f6e\u6587\u4ef6\u8def\u5f84\ncfnat_file=$HOME\/cfnat\nconfig_file=$cfnat_file\/cfnat.conf\nps=&quot;&quot;\nAndroidps=&quot;&quot;\ncfnatcolo=&quot;SJC,LAX,HKG&quot;\ncfnatport=&quot;1234&quot;\ncfnatdelay=&quot;300&quot;\n\n################################################################\n\n# \u5b89\u88c5\u4f9d\u8d56\u5305\ninstall() {\n    if [ $# -eq 0 ]; then\n        echo -e &quot;${red}\u672a\u63d0\u4f9b\u8f6f\u4ef6\u5305\u53c2\u6570!${re}&quot;\n        return 1\n    fi\n\n    for package in &quot;$@&quot;; do\n        if command -v &quot;$package&quot; &amp;&gt;\/dev\/null; then\n            echo -e &quot;${green}${package}\u5df2\u7ecf\u5b89\u88c5\u4e86\uff01${re}&quot;\n            continue\n        fi\n        echo -e &quot;${yellow}\u6b63\u5728\u5b89\u88c5 ${package}...${re}&quot;\n\n        if [ -n &quot;$PREFIX&quot; ] &amp;&amp; [ -d &quot;$PREFIX&quot; ] &amp;&amp; echo &quot;$PREFIX&quot; | grep -q &quot;\/data\/data\/com.termux\/files&quot;; then\n            pkg install -y &quot;$package&quot;\n        elif command -v apt &amp;&gt;\/dev\/null; then\n            apt install -y &quot;$package&quot;\n        elif command -v dnf &amp;&gt;\/dev\/null; then\n            dnf install -y &quot;$package&quot;\n        elif command -v yum &amp;&gt;\/dev\/null; then\n            yum install -y &quot;$package&quot;\n        elif command -v apk &amp;&gt;\/dev\/null; then\n            apk add &quot;$package&quot;\n        elif [ -f \/etc\/openwrt_release ]; then\n            opkg update\n            opkg install coreutils coreutils-nohup crontab\n        else\n            echo -e&quot;${red}\u6682\u4e0d\u652f\u6301\u4f60\u7684\u7cfb\u7edf!${re}&quot;\n            return 1\n        fi\n    done\n\n    return 0\n}\n\n# \u9009\u62e9\u5ba2\u6237\u7aef CPU \u67b6\u6784\narchAffix(){\n    if [ -n &quot;$PREFIX&quot; ] &amp;&amp; [ -d &quot;$PREFIX&quot; ] &amp;&amp; echo &quot;$PREFIX&quot; | grep -q &quot;\/data\/data\/com.termux\/files&quot;; then\n        echo &#039;termux&#039;\n    else\n        case &quot;$(uname -m)&quot; in\n        i386 | i686 ) echo &#039;386&#039; ;;\n        x86_64 | amd64 ) echo &#039;amd64&#039; ;;\n        armv7 ) echo &#039;arm&#039; ;;\n        armv8 | arm64 | aarch64 ) echo &#039;arm64&#039; ;;\n        s390x ) echo &#039;s390x&#039; ;;\n        * ) echo &#039;\u672a\u77e5&#039; ;;\n        esac\n    fi\n}\n\n# \u7b49\u5f85\u7528\u6237\u8fd4\u56de\nbreak_end() {\n    echo -e &quot;${green}\u6267\u884c\u5b8c\u6210${re}&quot;\n    echo -e &quot;${yellow}\u6309\u4efb\u610f\u952e\u8fd4\u56de...${re}&quot;\n    read -n 1 -s -r -p &quot;&quot;\n    echo &quot;&quot;\n    clear\n}\n\n# \u5b89\u88c5cfnat\ninstall_cfnat(){\n    if [ -n &quot;$1&quot; ]; then \n        install curl nohup crontab\n    else\n        echo -e &quot;\u811a\u672c\u6240\u9700\u4f9d\u8d56\u5305 ${yellow}curl nohup crontab${re}&quot;\n        read -p &quot;\u662f\u5426\u5141\u8bb8\u811a\u672c\u81ea\u52a8\u5b89\u88c5\u4ee5\u4e0a\u6240\u9700\u7684\u4f9d\u8d56\u5305(Y): &quot; install_apps\n        install_apps=${install_apps^^} # \u8f6c\u6362\u4e3a\u5927\u5199\n        if [ &quot;$install_apps&quot; == &quot;Y&quot; ]; then\n            install curl nohup crontab\n        fi\n    fi\n\n    # \u68c0\u6d4b $cfnat_file \u6587\u4ef6\u5939\u662f\u5426\u5b58\u5728\n    if [ ! -d $cfnat_file ]; then\n        # \u5982\u679c\u4e0d\u5b58\u5728\uff0c\u5219\u521b\u5efa\u8be5\u6587\u4ef6\u5939\n        mkdir $cfnat_file\n        echo &quot;\u76ee\u5f55 $cfnat_file \u5df2\u521b\u5efa\u3002&quot;\n    fi\n\n    # \u68c0\u6d4b $cfnat_file\/locations.json \u662f\u5426\u5b58\u5728\n    if [ ! -f $cfnat_file\/locations.json ]; then\n        # \u5982\u679c\u4e0d\u5b58\u5728\uff0c\u5219\u4f7f\u7528 curl \u4e0b\u8f7d\u6587\u4ef6\n        curl -SL https:\/\/cf.090227.xyz\/locations -o $cfnat_file\/locations.json\n        if [ ! -f $cfnat_file\/locations.json ]; then\n            curl -SL https:\/\/raw.cmliussss.com\/cfnat\/locations.json -o $cfnat_file\/locations.json\n        fi\n\n        if [ ! -f $cfnat_file\/locations.json ]; then\n            echo &quot;locations.json \u4e0b\u8f7d\u5931\u8d25\u3002&quot;\n        else\n            echo &quot;locations.json \u4e0b\u8f7d\u5b8c\u6210\u3002&quot;\n        fi\n    else\n        echo &quot;locations.json \u51c6\u5907\u5c31\u7eea\u3002&quot;\n    fi\n\n    # \u68c0\u6d4b $cfnat_file\/cfnat \u662f\u5426\u5b58\u5728\n    if [ ! -f $cfnat_file\/cfnat ]; then\n        # \u5982\u679c\u4e0d\u5b58\u5728\uff0c\u5219\u4f7f\u7528 curl \u4e0b\u8f7d\u6587\u4ef6\n        if [ ${Architecture} = &quot;termux&quot; ]; then\n            curl -SL https:\/\/raw.cmliussss.com\/cfnat\/cfnat-termux -o $cfnat_file\/cfnat\n        else\n            curl -SL https:\/\/raw.cmliussss.com\/cfnat\/cfnat-linux-${Architecture} -o $cfnat_file\/cfnat\n        fi\n        chmod +x $cfnat_file\/cfnat\n        echo &quot;cfnat\u4e3b\u7a0b\u5e8f \u4e0b\u8f7d\u5b8c\u6210\u3002&quot;\n    else\n        echo &quot;cfnat\u4e3b\u7a0b\u5e8f \u51c6\u5907\u5c31\u7eea\u3002&quot;\n    fi\n}\n\n# \u5378\u8f7dcfnat\nuninstall_cfnat(){\n    kill_cfnat\n    delete_cron\n    rm -rf $cfnat_file\n    echo &quot;cfnat \u5df2\u6e05\u9664\u3002&quot;\n}\n\ncheck_cfnat(){\n    if grep -q &quot;^release=&quot; &quot;$config_file&quot;; then\n        release=$(grep &quot;^release=&quot; &quot;$config_file&quot; | cut -d&#039;=&#039; -f2)\n    else\n        if [[ -f \/etc\/redhat-release ]]; then \n            release=&quot;Centos&quot; \n        elif grep -q -E -i &quot;alpine&quot; \/etc\/issue 2&gt;\/dev\/null; then \n            release=&quot;alpine&quot; \n        elif grep -q -E -i &quot;debian&quot; \/etc\/issue 2&gt;\/dev\/null; then \n            release=&quot;Debian&quot; \n        elif grep -q -E -i &quot;ubuntu&quot; \/etc\/issue 2&gt;\/dev\/null; then \n            release=&quot;Ubuntu&quot; \n        elif grep -q -E -i &quot;centos|red hat|redhat&quot; \/etc\/issue 2&gt;\/dev\/null; then \n            release=&quot;Centos&quot; \n        elif grep -q -E -i &quot;openwrt&quot; \/proc\/version 2&gt;\/dev\/null; then \n            release=&quot;OpenWRT&quot; \n        elif grep -q -E -i &quot;debian&quot; \/proc\/version 2&gt;\/dev\/null; then \n            release=&quot;Debian&quot; \n        elif grep -q -E -i &quot;ubuntu&quot; \/proc\/version 2&gt;\/dev\/null; then \n            release=&quot;Ubuntu&quot; \n        elif grep -q -E -i &quot;centos|red hat|redhat&quot; \/proc\/version 2&gt;\/dev\/null; then \n            release=&quot;Centos&quot; \n        else  \n            site_release\n        fi\n    fi\n\n    if grep -q &quot;^Architecture=&quot; &quot;$config_file&quot;; then\n        Architecture=$(grep &quot;^Architecture=&quot; &quot;$config_file&quot; | cut -d&#039;=&#039; -f2)\n    else\n        Architecture=$(archAffix)\n        if [ &quot;$Architecture&quot; = &quot;\u672a\u77e5&quot;  ]; then\n            site_Architecture\n        fi\n    fi\n\n    if [ ${Architecture} = &quot;termux&quot; ]; then\n        #install net-tools\n        lanip=$(ifconfig | grep -Eo &#039;inet (192\\.168|10\\.|172\\.(1[6-9]|2[0-9]|3[0-1]))[0-9.]+&#039; | awk &#039;{print $2}&#039;)\n        Androidps=&quot;${yellow} \u5b89\u5353\u624b\u673a\u63a8\u8350\u4f7f\u7528 ${green}\u8c03\u8bd5\u8fd0\u884c ${yellow}\u6765\u6267\u884c\u4efb\u52a1&quot;\n    else\n        lanip=$(ip -4 addr | grep -Eo &#039;inet (192\\.168|10\\.|172\\.(1[6-9]|2[0-9]|3[0-1]))[0-9.]+\/[0-9]+&#039; | awk &#039;{print $2}&#039; | cut -d&#039;\/&#039; -f1)\n    fi\n    # \u68c0\u6d4b $cfnat_file \u6587\u4ef6\u5939\u662f\u5426\u5b58\u5728\n    if [ -d $cfnat_file ]; then\n        # \u68c0\u6d4b $cfnat_file\/cfnat \u6587\u4ef6\u662f\u5426\u5b58\u5728\n        if [ -f $cfnat_file\/cfnat ] &amp;&amp; [ -f $cfnat_file\/locations.json ]; then\n            InstallationStatus=&quot;${green}\u5df2\u5b89\u88c5&quot;\n            OneclickInstallation=&quot;${red}\u4e00\u952e\u5378\u8f7d&quot;\n\n            if [ -f &quot;$config_file&quot; ]; then\n                # \u5982\u679c\u5b58\u5728\uff0c\u8bfb\u53d6 colo \u5b57\u6bb5\u5185\u5bb9\n                colo=$(grep &#039;^colo=&#039; &quot;$config_file&quot; | cut -d&#039;=&#039; -f2)\n                port=$(grep &#039;^port=&#039; &quot;$config_file&quot; | cut -d&#039;=&#039; -f2)\n                delay=$(grep &#039;^delay=&#039; &quot;$config_file&quot; | cut -d&#039;=&#039; -f2)\n            else\n                # \u5982\u679c\u4e0d\u5b58\u5728\uff0c\u521b\u5efa\u914d\u7f6e\u6587\u4ef6\u5e76\u5199\u5165\u5185\u5bb9\n                colo=&quot;SJC,LAX,HKG&quot;\n                echo &quot;colo=${colo}&quot; &gt;&gt; &quot;$config_file&quot;\n                port=&quot;1234&quot;\n                echo &quot;port=${port}&quot; &gt;&gt; &quot;$config_file&quot;\n                delay=&quot;300&quot;\n                echo &quot;delay=${delay}&quot; &gt;&gt; &quot;$config_file&quot;\n            fi\n            cfnatcolo=$colo\n            cfnatport=$port\n            cfnatdelay=$delay\n\n            if [ -f &quot;$cfnat_file\/ips-v4.txt&quot; ]; then\n                # \u83b7\u53d6\u6587\u4ef6\u7684\u884c\u6570\n                line_count=$(wc -l &lt; &quot;$cfnat_file\/ips-v4.txt&quot;)\n\n                # \u5224\u65ad\u884c\u6570\u662f\u5426\u8d85\u8fc75000\n                if [ &quot;$line_count&quot; -gt 7000 ]; then\n                    #echo &quot;\u6587\u4ef6\u884c\u6570\u8d85\u8fc77000\u884c&quot;\n                    IPLibrary=&quot;${skyblue}AS209242&quot;\n                else\n                    #echo &quot;\u6587\u4ef6\u884c\u6570\u672a\u8d85\u8fc77000\u884c&quot;\n                    IPLibrary=&quot;${green}AS13335&quot;\n                fi\n            else\n                up_as13335\n            fi\n\n        else\n            InstallationStatus=&quot;${red}\u672a\u5b89\u88c5&quot;\n            OneclickInstallation=&quot;${green}\u4e00\u952e\u5b89\u88c5&quot;\n        fi\n    else\n        InstallationStatus=&quot;${red}\u672a\u5b89\u88c5&quot;\n        OneclickInstallation=&quot;${green}\u4e00\u952e\u5b89\u88c5&quot;\n    fi\n\n    if [ &quot;$release&quot; = &quot;OpenWRT&quot; ]; then\n        cfnatpid=$(pgrep -f &quot;.\/cfnat -colo&quot;)\n        # \u68c0\u67e5\u662f\u5426\u627e\u5230\u4e86 PID\n        if [ -n &quot;$cfnatpid&quot; ]; then\n            statecfnat=&quot;${green}\u8fd0\u884c\u4e2d&quot;\n        else\n            statecfnat=&quot;${red}\u672a\u8fd0\u884c&quot;\n        fi\n    else\n        # \u68c0\u6d4b $cfnat_file\/cfnat \u7a0b\u5e8f\u662f\u5426\u6b63\u5728\u8fd0\u884c\n        if pgrep -x &quot;cfnat&quot; &gt; \/dev\/null; then\n            # \u5982\u679c\u6b63\u5728\u8fd0\u884c\uff0c\u8d4b\u503c\n            statecfnat=&quot;${green}\u8fd0\u884c\u4e2d&quot;\n        else\n            # \u5982\u679c\u672a\u8fd0\u884c\uff0c\u8d4b\u503c\n            statecfnat=&quot;${red}\u672a\u8fd0\u884c&quot;\n        fi\n    fi\n}\n\nadd_cron(){\n    if [ &quot;${Architecture}&quot; != &quot;termux&quot; ]; then\n        delete_cron\n        cron_cfnat=&quot;*\/5 * * * * cd ~ &amp;&amp; bash cfnat.sh $cfnatcolo&quot;\n        (crontab -l; echo &quot;$cron_cfnat&quot;) | crontab -\n        echo &quot;\u6dfb\u52a0 crontab \u5b88\u62a4\u4efb\u52a1 $cron_cfnat&quot;\n    fi\n}\n\ndelete_cron(){\n    if [ &quot;${Architecture}&quot; != &quot;termux&quot; ]; then\n        crontab -l | grep -v &#039;bash cfnat.sh&#039; | crontab -\n        echo &quot;\u6e05\u7406 crontab \u5b88\u62a4\u4efb\u52a1&quot;\n    fi\n}\n\nup_as13335(){\n    echo &quot;\u4e0b\u8f7dIP\u5e93 AS13335&quot;\n    # \u4e0b\u8f7dAS13335.txt\u6587\u4ef6\n    curl -SL https:\/\/raw.cmliussss.com\/cfnat\/ips-v4.txt -o $cfnat_file\/AS13335.txt\n    if [ &quot;$release&quot; = &quot;OpenWRT&quot; ]; then\n        mv $cfnat_file\/AS13335.txt $cfnat_file\/ips-v4.txt\n        echo &quot;IP\u5e93\u66f4\u65b0\u4e3a AS13335&quot;\n    else\n        # \u83b7\u53d6\u4e0b\u8f7d\u7684\u6587\u4ef6\u5927\u5c0f\uff08\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\uff09\n        file_size=$(stat -c%s &quot;$cfnat_file\/AS13335.txt&quot;)\n\n        # \u68c0\u6d4b\u6587\u4ef6\u662f\u5426\u5927\u4e8e10K\uff0810240\u5b57\u8282\uff09\n        if [ $file_size -gt 10240 ]; then\n            # \u6587\u4ef6\u5927\u5c0f\u8d85\u8fc710K\uff0c\u91cd\u547d\u540d\u4e3aips-v4.txt\uff0c\u8986\u76d6\u5df2\u6709\u6587\u4ef6\n            mv $cfnat_file\/AS13335.txt $cfnat_file\/ips-v4.txt\n            echo &quot;IP\u5e93\u66f4\u65b0\u4e3a AS13335&quot;\n        else\n            # \u6587\u4ef6\u5c0f\u4e8e\u6216\u7b49\u4e8e10K\uff0c\u63d0\u793a\u5931\u8d25\u5e76\u5220\u9664\u4e0b\u8f7d\u7684\u6587\u4ef6\n            echo &quot;\u66f4\u65b0IP\u5e93\u5931\u8d25&quot;\n            rm $cfnat_file\/AS13335.txt\n        fi\n    fi\n}\n\nconfig_cfnat(){\n    echo &quot;\u7535\u4fe1 \u63a8\u8350 SJC,LAX&quot;\n    echo &quot;\u79fb\u52a8\/\u8054\u901a \u63a8\u8350 HKG&quot;\n    # \u8bfb\u53d6\u5e76\u5904\u7406\u6570\u636e\u4e2d\u5fc3\u8f93\u5165\n    read -p &quot;\u8f93\u5165\u7b5b\u9009\u6570\u636e\u4e2d\u5fc3\uff08\u591a\u4e2a\u6570\u636e\u4e2d\u5fc3\u7528\u9017\u53f7\u9694\u5f00\uff0c\u7559\u7a7a\u5219\u4f7f\u7528 SJC,LAX,HKG\uff09: &quot; colo\n    colo=${colo:-&quot;SJC,LAX,HKG&quot;}\n    colo=${colo^^}\n    # \u66f4\u65b0\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684 colo \u53c2\u6570\n    if grep -q &quot;^colo=&quot; &quot;$config_file&quot;; then\n        sed -i &quot;s\/^colo=.*\/colo=${colo}\/&quot; &quot;$config_file&quot;\n    else\n        echo &quot;colo=${colo}&quot; &gt;&gt; &quot;$config_file&quot;\n    fi\n\n    # \u8bfb\u53d6\u5e76\u5904\u7406\u7aef\u53e3\u8f93\u5165\n    echo &quot;&quot;\n    read -p &quot;\u8f93\u5165\u672c\u5730\u76d1\u542c\u7aef\u53e3\uff08\u9ed8\u8ba4 1234\uff09: &quot; port\n    port=${port:-1234}\n    # \u66f4\u65b0\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684 port \u53c2\u6570\n    if grep -q &quot;^port=&quot; &quot;$config_file&quot;; then\n        sed -i &quot;s\/^port=.*\/port=${port}\/&quot; &quot;$config_file&quot;\n    else\n        echo &quot;port=${port}&quot; &gt;&gt; &quot;$config_file&quot;\n    fi\n\n    # \u8bfb\u53d6\u5e76\u5904\u7406\u5ef6\u8fdf\u8f93\u5165\n    echo &quot;&quot;\n    echo &quot;\u7535\u4fe1 \u6709\u6548\u5ef6\u8fdf\u63a8\u8350 300&quot;\n    echo &quot;\u79fb\u52a8\/\u8054\u901a \u6709\u6548\u5ef6\u8fdf\u53ef\u5c1d\u8bd5 100&quot;\n    read -p &quot;\u8f93\u5165\u6709\u6548\u5ef6\u8fdf\uff08\u6beb\u79d2\uff09\uff0c\u8d85\u8fc7\u6b64\u5ef6\u8fdf\u5c06\u65ad\u5f00\u8fde\u63a5\uff08\u9ed8\u8ba4 300\uff09: &quot; delay\n    delay=${delay:-300}\n    # \u66f4\u65b0\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684 delay \u53c2\u6570\n    if grep -q &quot;^delay=&quot; &quot;$config_file&quot;; then\n        sed -i &quot;s\/^delay=.*\/delay=${delay}\/&quot; &quot;$config_file&quot;\n    else\n        echo &quot;delay=${delay}&quot; &gt;&gt; &quot;$config_file&quot;\n    fi\n}\n\nkill_cfnat(){\n    if [ &quot;$release&quot; = &quot;OpenWRT&quot; ]; then\n        # \u67e5\u8be2 .\/cfnat \u8fdb\u7a0b\u5e76\u83b7\u53d6\u5176 PID\n        cfnatpid=$(pgrep -f &quot;.\/cfnat -colo&quot;)\n\n        # \u68c0\u67e5\u662f\u5426\u627e\u5230\u4e86 PID\n        if [ -n &quot;$cfnatpid&quot; ]; then\n            echo &quot;.\/cfnat \u8fdb\u7a0b\u6b63\u5728\u8fd0\u884c\uff0c\u51c6\u5907\u6740\u6b7b\u8fdb\u7a0b...&quot;\n            kill &quot;$cfnatpid&quot;\n            echo -e &quot;${red}.\/cfnat \u8fdb\u7a0b\u5df2\u88ab\u6740\u6b7b\u3002${re}&quot;\n        else\n            echo &quot;.\/cfnat \u8fdb\u7a0b\u672a\u5728\u8fd0\u884c\u3002&quot;\n        fi\n    else\n        # \u68c0\u6d4b $cfnat_file\/cfnat \u7a0b\u5e8f\u662f\u5426\u6b63\u5728\u8fd0\u884c\n        if pgrep -x &quot;cfnat&quot; &gt; \/dev\/null; then\n            echo &quot;cfnat \u8fdb\u7a0b\u6b63\u5728\u8fd0\u884c\uff0c\u51c6\u5907\u6740\u6b7b\u8fdb\u7a0b...&quot;\n            # \u5982\u679c\u6b63\u5728\u8fd0\u884c\uff0c\u7ed3\u675f\u8be5\u7a0b\u5e8f\n            pkill -x &quot;cfnat&quot;\n            echo -e &quot;${red}cfnat \u5df2\u7ec8\u6b62\u3002${re}&quot;\n        fi\n    fi\n}\n\ngo_cfnat(){\n    if [ &quot;$OneclickInstallation&quot; = &quot;${green}\u4e00\u952e\u5b89\u88c5&quot; ]; then\n        install_cfnat\n    fi\n    check_cfnat\n    cd $cfnat_file &amp;&amp; nohup .\/cfnat -colo $cfnatcolo -port 443 -delay $cfnatdelay -ips 4 -addr &quot;0.0.0.0:$cfnatport&quot; &gt;\/dev\/null 2&gt;&amp;1 &amp;\n}\n\nstate_cfnat(){\n    echo -e &quot;${yellow} \u7cfb\u7edf: ${re}${release}${re}&quot;\n    echo -e &quot;${yellow} \u67b6\u6784: ${re}${Architecture}${re}&quot;\n    echo -e &quot;${yellow} IP\u5e93: ${IPLibrary}${re}&quot;\n    echo -e &quot;${yellow} \u6570\u636e\u4e2d\u5fc3: ${re}${cfnatcolo}${re}&quot;\n    echo -e &quot;${yellow} \u6709\u6548\u5ef6\u8fdf: ${re}${cfnatdelay}ms${re}&quot;\n    echo -e &quot;${yellow} \u672c\u5730\u670d\u52a1: ${re}127.0.0.1:${cfnatport}${re}&quot;\n    #echo -e &quot;${yellow} \u5185\u7f51\u670d\u52a1: ${re}${lanip}:${cfnatport}${re}&quot;\n    # \u5c06lanip\u8f6c\u6210\u6570\u7ec4\n    IFS=$&#039;\\n&#039; read -rd &#039;&#039; -a ip_array &lt;&lt;&lt; &quot;$lanip&quot;\n\n    # \u8f93\u51fa\u7ed3\u679c\n    if [ ${#ip_array[@]} -eq 1 ]; then\n        echo -e &quot;${yellow} \u5185\u7f51\u670d\u52a1: ${re}${ip_array[0]}:$cfnatport${reset}&quot;\n    else\n        echo -e &quot;${yellow} \u5185\u7f51\u670d\u52a1: ${re}${ip_array[0]}:$cfnatport${reset}&quot;\n        for i in &quot;${!ip_array[@]}&quot;; do\n            if [ $i -ne 0 ]; then\n                echo &quot;           ${ip_array[$i]}:$cfnatport&quot;\n            fi\n        done\n    fi\n}\n\nsite_release(){\n    echo -e &quot;${yellow} \u8bbe\u7f6e\u7cfb\u7edf\u4fe1\u606f...${re}&quot;\n    echo -e &quot;${yellow} 1. ${re}alpine&quot;\n    echo -e &quot;${yellow} 2. ${re}Centos&quot;\n    echo -e &quot;${yellow} 3. ${re}Debian&quot;\n    echo -e &quot;${yellow} 4. ${re}Ubuntu&quot;\n    echo -e &quot;${yellow} 5. ${re}OpenWRT&quot;\n    read -p $&#039;\\033[1;91m\u8bf7\u8f93\u5165\u4f60\u7684\u9009\u62e9\uff08\u9ed8\u8ba4 OpenWRT\uff09: \\033[0m&#039; choice_release\n    # \u6839\u636e\u7528\u6237\u9009\u62e9\u8d4b\u503c\u7ed9 release \u53d8\u91cf\n    case $choice_release in\n        1)\n            release=&quot;alpine&quot;\n            ;;\n        2)\n            release=&quot;Centos&quot;\n            ;;\n        3)\n            release=&quot;Debian&quot;\n            ;;\n        4)\n            release=&quot;Ubuntu&quot;\n            ;;\n        5)\n            release=&quot;OpenWRT&quot;\n            ;;\n        *)\n            release=&quot;OpenWRT&quot;  # \u9ed8\u8ba4\u503c\n            ;;\n    esac\n    if grep -q &quot;^release=&quot; &quot;$config_file&quot;; then\n        sed -i &quot;s\/^release=.*\/release=${release}\/&quot; &quot;$config_file&quot;\n    else\n        echo &quot;release=${release}&quot; &gt;&gt; &quot;$config_file&quot;\n    fi\n    echo &quot;\u4f60\u9009\u62e9\u7684\u7cfb\u7edf\u662f: $release&quot;\n}\n\nsite_Architecture(){\n    echo -e &quot;${yellow} \u8bbe\u7f6e\u67b6\u6784\u4fe1\u606f...${re}&quot;\n    echo -e &quot;${yellow} 1. ${re}termux \uff08\u5b89\u5353termux\uff09&quot;\n    echo -e &quot;${yellow} 2. ${re}386 \uff08\u8001\u53e4\u8463 32\u4f4dx86\u8f6f\u8def\u7531\uff09&quot;\n    echo -e &quot;${yellow} 3. ${re}amd64 \uff0864\u4f4dx86\u8f6f\u8def\u7531\u865a\u62df\u673a\uff09&quot;\n    echo -e &quot;${yellow} 4. ${re}arm \uff0832\u4e3a \u8001arm\u673a\u5668\uff09&quot;\n    echo -e &quot;${yellow} 5. ${re}arm64 \uff08\u786c\u8def\u7531\u5237\u673aOpenWRT\uff09&quot;\n    echo -e &quot;${yellow} 6. ${re}s390x&quot;\n    echo -e &quot;${yellow} 7. ${re}mips64&quot;\n    read -p $&#039;\\033[1;91m\u8bf7\u8f93\u5165\u4f60\u7684\u9009\u62e9\uff08\u9ed8\u8ba4 amd64\uff09: \\033[0m&#039; choice_Architecture\n    # \u6839\u636e\u7528\u6237\u9009\u62e9\u8d4b\u503c\u7ed9 release \u53d8\u91cf\n    case $choice_Architecture in\n        1)\n            Architecture=&quot;termux&quot;\n            ;;\n        2)\n            Architecture=&quot;386&quot;\n            ;;\n        3)\n            Architecture=&quot;amd64&quot;\n            ;;\n        4)\n            Architecture=&quot;arm&quot;\n            ;;\n        5)\n            Architecture=&quot;arm64&quot;\n            ;;\n        6)\n            Architecture=&quot;s390x&quot;\n            ;;\n        7)\n            Architecture=&quot;mips64&quot;\n            ;;\n        *)\n            Architecture=&quot;amd64&quot;  # \u9ed8\u8ba4\u503c\n            ;;\n    esac\n    if grep -q &quot;^Architecture=&quot; &quot;$config_file&quot;; then\n        sed -i &quot;s\/^Architecture=.*\/Architecture=${Architecture}\/&quot; &quot;$config_file&quot;\n    else\n        echo &quot;Architecture=${Architecture}&quot; &gt;&gt; &quot;$config_file&quot;\n    fi\n    echo &quot;\u4f60\u9009\u62e9\u7684\u67b6\u6784\u662f: $Architecture&quot;\n}\n#########################\u68a6\u5f00\u59cb\u7684\u5730\u65b9##############################\n#\u65e0\u4ea4\u4e92\u6267\u884c\nif [ -n &quot;$1&quot; ]; then \n    check_cfnat\n    if [ &quot;$OneclickInstallation&quot; = &quot;${green}\u4e00\u952e\u5b89\u88c5&quot; ]; then\n        install_cfnat\n    fi\n    cfnatcolo=${1^^}\n    # \u68c0\u6d4b\u914d\u7f6e\u6587\u4ef6\u662f\u5426\u5b58\u5728\n    if [ -f &quot;$config_file&quot; ]; then\n        # \u5982\u679c\u5b58\u5728\uff0c\u8bfb\u53d6 colo \u5b57\u6bb5\u5185\u5bb9\n        colo=$(grep &#039;^colo=&#039; &quot;$config_file&quot; | cut -d&#039;=&#039; -f2)\n        if [ $cfnatcolo = $colo ] &amp;&amp; [ $statecfnat = &quot;${green}\u8fd0\u884c\u4e2d&quot; ]; then\n            state_cfnat\n            echo -e &quot;${green}cfnat \u6b63\u5728\u8fd0\u884c...${re}&quot;\n            exit\n        else\n            kill_cfnat\n        fi\n    fi\n    # \u66f4\u65b0\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684 colo \u53c2\u6570\n    if grep -q &quot;^colo=&quot; &quot;$config_file&quot;; then\n        sed -i &quot;s\/^colo=.*\/colo=${cfnatcolo}\/&quot; &quot;$config_file&quot;\n    else\n        echo &quot;colo=${cfnatcolo}&quot; &gt;&gt; &quot;$config_file&quot;\n    fi\n    cd $cfnat_file &amp;&amp; nohup .\/cfnat -colo $cfnatcolo -port 443 -delay $cfnatdelay -ips 4 -addr &quot;0.0.0.0:$cfnatport&quot; &gt;\/dev\/null 2&gt;&amp;1 &amp;\n    #echo &quot;nohup .\/cfnat -colo HKG -port 443 -delay 200 -ips 4 -addr &quot;0.0.0.0:1234&quot; &gt;\/dev\/null 2&gt;&amp;1 &amp;&quot;\n    state_cfnat\n    echo -e &quot;${green}cfnat \u5f00\u59cb\u6267\u884c...${re}&quot;\nelse\n    while true; do\n    check_cfnat\n    clear\n    echo &quot;cfnat \u539f\u4f5c\u8005: https:\/\/t.me\/CF_NAT\/38840 \u7f1d\u5408\u602a: cmliu&quot;\n    echo &quot;--------------------------------&quot;\n    echo -e &quot;${yellow} \u72b6\u6001: ${InstallationStatus} ${statecfnat} ${re}&quot;\n    state_cfnat\n    echo &quot;--------------------------------&quot;\n    echo -e &quot;${yellow} 1. ${OneclickInstallation}${re}&quot;\n    echo &quot;--------------------------------&quot;\n    echo -e &quot;${yellow} 2. \u542f\u52a8 cfnat ${re}&quot;\n    echo -e &quot;${yellow} 3. \u505c\u6b62 cfnat ${re}&quot;\n    echo -e &quot;${yellow} 4. \u91cd\u542f cfnat ${re}&quot;\n    echo -e &quot;${yellow} 5. \u914d\u7f6e cfnat ${ps}${re}&quot;\n    echo &quot;--------------------------------&quot;\n    echo -e &quot;${yellow} 6. ${green}\u8c03\u8bd5\u8fd0\u884c cfnat ${re} ${Androidps}${re}&quot;\n    echo -e &quot;${yellow} 7. \u624b\u52a8\u8bbe\u7f6e\u7cfb\u7edf\u67b6\u6784${re}&quot;\n    echo &quot;--------------------------------&quot;\n    echo -e &quot;${yellow} 8. IP\u5e93\u66f4\u65b0\u4e3a ${green}AS13335${re}&quot;\n    echo -e &quot;${yellow} 9. IP\u5e93\u66f4\u65b0\u4e3a ${skyblue}AS209242 ${re}\u4ec5\u63a8\u8350${yellow}\u7535\u4fe1${re}\u4f7f\u7528&quot;\n    echo &quot;--------------------------------&quot;\n    echo -e &quot;\\033[0;97m 0. \u9000\u51fa\u811a\u672c&quot; \n    echo -e &quot;${yellow}--------------------------------${re}&quot;\n    ps=&quot;&quot;\n    siteps=&quot;&quot;\n    read -p $&#039;\\033[1;91m\u8bf7\u8f93\u5165\u4f60\u7684\u9009\u62e9: \\033[0m&#039; choice\n    case $choice in\n        1)\n            clear\n            if [ &quot;$OneclickInstallation&quot; = &quot;${red}\u4e00\u952e\u5378\u8f7d&quot; ]; then\n                uninstall_cfnat\n            else\n                install_cfnat\n            fi\n        ;;\n        2)\n            if [ ! -f &quot;$config_file&quot; ]; then\n                config_cfnat\n            fi\n            go_cfnat\n            add_cron\n        ;;\n        3)\n            kill_cfnat\n            delete_cron\n        ;;\n        4)\n            kill_cfnat\n            go_cfnat\n            add_cron\n        ;;\n        5)\n            if [ &quot;$OneclickInstallation&quot; = &quot;${green}\u4e00\u952e\u5b89\u88c5&quot; ]; then\n                install_cfnat\n            fi\n            config_cfnat\n            ps=&quot;${red}\u5b8c\u6210\u914d\u7f6e\u540e\u9700\u91cd\u542fcfnat\u624d\u80fd\u751f\u6548\uff01&quot;\n        ;;\n        6)\n            if [ &quot;$OneclickInstallation&quot; = &quot;${green}\u4e00\u952e\u5b89\u88c5&quot; ]; then\n                install_cfnat\n            elif [ $statecfnat = &quot;${green}\u8fd0\u884c\u4e2d&quot; ]; then\n                kill_cfnat\n                delete_cron\n            fi\n            cd $cfnat_file &amp;&amp; .\/cfnat -colo $cfnatcolo -port 443 -delay $cfnatdelay -ips 4 -addr &quot;0.0.0.0:$cfnatport&quot;\n        ;;\n        7)  \n            kill_cfnat\n            uninstall_cfnat\n            mkdir $cfnat_file\n            site_release\n            site_Architecture\n            colo=&quot;SJC,LAX,HKG&quot;\n            echo &quot;colo=${colo}&quot; &gt;&gt; &quot;$config_file&quot;\n            port=&quot;1234&quot;\n            echo &quot;port=${port}&quot; &gt;&gt; &quot;$config_file&quot;\n            delay=&quot;300&quot;\n            echo &quot;delay=${delay}&quot; &gt;&gt; &quot;$config_file&quot;\n            echo -e &quot;${red}\u8bbe\u7f6e\u5b8c\u6210\u540e\u9700\u5378\u8f7d\u91cd\u88c5 cfnat \u624d\u80fd\u751f\u6548\uff01&quot;\n            install_cfnat\n        ;;\n        8)\n            up_as13335\n        ;;\n        9)\n            # \u4e0b\u8f7dAS209242.txt\u6587\u4ef6\n            curl -SL https:\/\/as209242.ip.txt.090227.xyz\/AS209242.txt -o $cfnat_file\/AS209242.txt\n\n            # \u83b7\u53d6\u4e0b\u8f7d\u7684\u6587\u4ef6\u5927\u5c0f\uff08\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\uff09\n            file_size=$(stat -c%s &quot;$cfnat_file\/AS209242.txt&quot;)\n\n            # \u68c0\u6d4b\u6587\u4ef6\u662f\u5426\u5927\u4e8e10K\uff0810240\u5b57\u8282\uff09\n            if [ $file_size -gt 10240 ]; then\n                # \u6587\u4ef6\u5927\u5c0f\u8d85\u8fc710K\uff0c\u91cd\u547d\u540d\u4e3aips-v4.txt\uff0c\u8986\u76d6\u5df2\u6709\u6587\u4ef6\n                mv $cfnat_file\/AS209242.txt $cfnat_file\/ips-v4.txt\n                echo &quot;IP\u5e93\u66f4\u65b0\u4e3a AS209242&quot;\n            else\n                # \u6587\u4ef6\u5c0f\u4e8e\u6216\u7b49\u4e8e10K\uff0c\u63d0\u793a\u5931\u8d25\u5e76\u5220\u9664\u4e0b\u8f7d\u7684\u6587\u4ef6\n                echo &quot;\u66f4\u65b0IP\u5e93\u5931\u8d25&quot;\n                rm $cfnat_file\/AS209242.txt\n            fi\n        ;;\n        0)\n            clear\n            exit\n        ;;\n        *)\n            read -p &quot;\u65e0\u6548\u7684\u8f93\u5165!&quot;\n            ps=&quot;&quot;\n        ;;\n    esac\n        break_end\n    done\nfi<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#!\/bin\/bash export LANG=en_US.UTF-8 # \u5b9a\u4e49\u989c\u8272 re=&#039;\\e[ [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-416","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/my.di.cloudns.asia\/index.php\/wp-json\/wp\/v2\/posts\/416","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/my.di.cloudns.asia\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/my.di.cloudns.asia\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/my.di.cloudns.asia\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/my.di.cloudns.asia\/index.php\/wp-json\/wp\/v2\/comments?post=416"}],"version-history":[{"count":1,"href":"https:\/\/my.di.cloudns.asia\/index.php\/wp-json\/wp\/v2\/posts\/416\/revisions"}],"predecessor-version":[{"id":417,"href":"https:\/\/my.di.cloudns.asia\/index.php\/wp-json\/wp\/v2\/posts\/416\/revisions\/417"}],"wp:attachment":[{"href":"https:\/\/my.di.cloudns.asia\/index.php\/wp-json\/wp\/v2\/media?parent=416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/my.di.cloudns.asia\/index.php\/wp-json\/wp\/v2\/categories?post=416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/my.di.cloudns.asia\/index.php\/wp-json\/wp\/v2\/tags?post=416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}