frankiejun / cvwt

Cloudflare 上建workers和pages节点及自动化优选IP的一揽子工具
https://github.com/frankiejun/cvwt
GNU General Public License v3.0
114 stars 100 forks source link

R2S(ARM64)运行错误,软路由配置多元化,请作者分析错误原因,谢谢! #11

Closed xpfcom closed 1 month ago

xpfcom commented 2 months ago

我的软路由是R2S(arm64),运行您的优选IP代码不能有效运行,用chatgpt解释了部分代码:

  1. start.sh: line 15: //for: No such file or directory 这是一个语法错误。脚本的第15行包含了一个无效的命令 //for。这通常是因为脚本中存在拼写错误或无效的注释。确认脚本中是否有误用的注释或错别字。
  2. ps: unrecognized option: e 你正在使用的 ps 命令不支持 -e 选项。这是因为你的环境中 ps 命令可能是由 BusyBox 提供的精简版,并不支持所有的选项。可以使用 ps w 作为替代。

下方是运行时的提示代码: root@R2S:~/yx# bash start.sh config.yaml configfile:config.yaml, ipfile: start.sh: line 15: //for: No such file or directory 0.读取配置文件 ps: unrecognized option: e BusyBox v1.36.1 (2024-03-22 22:09:42 UTC) multi-call binary.

Usage: ps

Show list of processes

    w       Wide output

nohup: ignoring input and redirecting stderr to stdout nohup: appending output to 'nohup.out' OpenClash Already Start! 1.Download ip file. --2024-07-22 23:11:11-- https://zip.baipiao.eu.org/ Resolving zip.baipiao.eu.org... 198.18.1.30 Connecting to zip.baipiao.eu.org|198.18.1.30|:443... connected. HTTP request sent, awaiting response... 200 OK Length: unspecified [application/zip] Saving to: 'txt.zip'

txt.zip [ <=> ] 12.89K --.-KB/s in 0.04s

2024-07-22 23:11:12 (303 KB/s) - 'txt.zip' saved [13201]

downloaded. Archive: txt.zip inflating: 31898-0-2052.txt
inflating: 31898-0-2082.txt
inflating: 31898-0-2086.txt
inflating: 31898-0-2095.txt
inflating: 31898-0-80.txt
inflating: 31898-0-8080.txt
inflating: 31898-0-8880.txt
inflating: 31898-1-2053.txt
inflating: 31898-1-2083.txt
inflating: 31898-1-2087.txt
inflating: 31898-1-2096.txt
inflating: 31898-1-443.txt
inflating: 31898-1-8443.txt
inflating: 45102-0-2052.txt
inflating: 45102-0-2082.txt
inflating: 45102-0-2086.txt
inflating: 45102-0-2095.txt
inflating: 45102-0-80.txt
inflating: 45102-0-8080.txt
inflating: 45102-0-8880.txt
inflating: 45102-1-2053.txt
inflating: 45102-1-2083.txt
inflating: 45102-1-2087.txt
inflating: 45102-1-2096.txt
inflating: 45102-1-443.txt
inflating: 45102-1-8443.txt
2.Select the ip address of the desired port. handling: ./45102-1-443.txt handling: ./31898-1-443.txt Run scripts to test speed and update dns records. 当前工作模式为ipv4 OpenClash Already Stop! 已停止openclash ./CloudflareST -url https://cs.11.us -t 1 -n 200 -dn 10 -tl 250 -tll 40 -sl 2 -p 10 -tp 443 -c -cc hk,jp 分国家测速模式

XIU2/CloudflareSpeedTest

开始延迟测速(模式:TCP, 端口:443, 范围:40 ~ 250 ms, 丢包:1.00) 298 / 298 [------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 可用: 65
开始查询IP的国家代号... 测速完毕 OpenClash Restart... OpenClash Already Stop! OpenClash Already Start! 已重启openclash 为保证cloudflareAPI连接正常 将在3秒后开始更新域名解析 true length:1 Configuration Group 1: x_email: xpfcm@gmil.com hostname: hkfd.3661.xyz,jpfd.3661.xyz domain_num:2, countryCode_num:2 cf_ddns():zone_id:576fd847af38d49c35 cf_ddns():api_key:d3e87845961a85da7 Cloudflare账号验证成功 正在更新域名,请稍后... csvfile:hk.csv csvfile:jp.csv csvfile:hk.csv csvfile:jp.csv 未配置TG推送 未配置微信推送的sendKey, 关注【方糖】公众号获取sendKey Restore background process. nohup: ignoring input and redirecting stderr to stdout nohup: appending output to 'nohup.out' OpenClash Already Start!

chatgpt改写了部分代码: start.sh

!/bin/bash

确认传入的参数个数是否正确

if [ $# -lt 1 ]; then echo "Usage: start.sh config_file_path [ipfile]" exit 0 fi

configfile=$1 ipfile=$2

echo "configfile:$configfile, ipfile:$ipfile"

ipzipfile="txt.zip"

测试使用

rm -rf *.csv if [[ -e $ipzipfile ]]; then rm -rf $ipzipfile fi

if [[ -e informlog ]]; then rm -rf informlog fi

echo "0.读取配置文件" if [[ ! -e $configfile ]]; then echo "找不到 $configfile 配置文件!" exit 1 fi

pause=$(yq eval ".pause" $configfile) clien=$(yq eval ".clien" $configfile) multip=$(yq eval ".multip" $configfile) CFST_URL=$(yq eval ".CFST_URL" $configfile) CFST_N=$(yq eval ".CFST_N" $configfile) CFST_T=$(yq eval ".CFST_T" $configfile) CFST_DN=$(yq eval ".CFST_DN" $configfile) CFST_TL=$(yq eval ".CFST_TL" $configfile) CFST_TLL=$(yq eval ".CFST_TLL" $configfile) CFST_SL=$(yq eval ".CFST_SL" $configfile) CCFLAG=$(yq eval ".CCFLAG" $configfile) CCODE=$(yq eval ".CCODE" $configfile) CF_ADDR=$(yq eval ".CF_ADDR" $configfile) telegramBotToken=$(yq eval ".telegramBotToken" $configfile) telegramBotUserId=$(yq eval ".telegramBotUserId" $configfile) sendType=$(yq eval ".sendType" $configfile) sendKey=$(yq eval ".sendKey" $configfile)

ChkHostnameAndCoutryCode() { IFS=, read -r -a domains <<<"$hostname" IFS=, read -r -a countryCodes <<<"$CCODE"

domain_num=${#domains[@]} countryCode_num=${#countryCodes[@]}

if [ ${#domains[@]} -eq 0 ]; then echo "hostname must be set in config file!" return 1 fi

检查域名和国家代码是否一一对应

if [ "$CCFLAG" = "true" ]; then echo "domain_num:$domain_num, countryCode_num:$countryCode_num" if [ $domain_num -ne $countryCode_num ]; then echo "The name and country code must correspond one to one!" return 1 fi fi return 0 }

GetProxName() { c=$1 if [ "$c" = "6" ]; then CLIEN=bypass elif [ "$c" = "5" ]; then CLIEN=openclash elif [ "$c" = "4" ]; then CLIEN=clash elif [ "$c" = "3" ]; then CLIEN=shadowsocksr elif [ "$c" = "2" ]; then CLIEN=passwall2 else CLIEN=passwall fi echo $CLIEN }

handle_err() { if [ "$pause" = "true" ] ; then echo "Restore background process." proxy=$(GetProxName $clien) /etc/init.d/$proxy start fi }

trap handle_err HUP INT TERM EXIT CLIEN=$(GetProxName $clien)

if ! pgrep -f "$CLIEN" >/dev/null; then /etc/init.d/$CLIEN start fi

if [[ -z $ipfile ]]; then echo "1. Download ip file." for i in {1..3}; do wget -O $ipzipfile https://zip.baipiao.eu.org

if [[ $? != 0 ]]; then
  echo "get ip file failed, try again"
  sleep 1
  continue
else
  echo "downloaded."
  break
fi

done

if [[ -e $ipzipfile ]]; then unzip -o $ipzipfile else echo "Can't download the ip zip file, Check whether the agent software is disabled." fi

echo "2. Select the ip address of the desired port." port=$(yq eval ".CF_ADDR" $configfile) if [[ -z $port ]]; then port=443 fi

for file in $(find . -type f -name "*-[0-1]-$port.txt"); do echo "handling: $file" cat "$file" >>tmp.txt done

if [[ -e tmp.txt ]]; then cat tmp.txt | sort -u >ip.txt rm -rf tmp.txt fi fi

echo "Run scripts to test speed and update dns records." CFST_P=$CFST_DN

判断工作模式

if [ "$IP_ADDR" = "ipv6" ]; then if [ ! -f "ipv6.txt" ]; then echo "当前工作模式为ipv6,但该目录下没有【ipv6.txt】,请配置【ipv6.txt】。下载地址:https://github.com/XIU2/CloudflareSpeedTest/releases" exit 2 else echo "当前工作模式为ipv6" fi else echo "当前工作模式为ipv4" fi

读取配置文件中的客户端

CLIEN=$(GetProxName $clien)

判断是否停止科学上网服务

if [ "$pause" = "false" ]; then echo "按要求未停止科学上网服务" else /etc/init.d/$CLIEN stop echo "已停止$CLIEN" fi

判断是否配置测速地址

if [[ "$CFST_URL" == http* ]]; then CFST_URL_R="-url $CFST_URL" else CFST_URL_R="" fi

判断是否使用国家代码来筛选

if [[ "$CCFLAG" == "true" ]]; then USECC="-c " else USECC="" fi

if [ ! -z "$CCODE" ]; then CCODE_IS="-cc $CCODE " else CCODE_IS="" fi

if [ ! -z "$CF_ADDR" ]; then CF_ADDR=" -tp $CF_ADDR" else CF_ADDR=" -tp 443" fi

if [ -z "$ipfile" ]; then ipflag="" else ipflag="-f " fi

if [ "$IP_ADDR" = "ipv6" ]; then

开始优选IPv6

./CloudflareST $CFST_URL_R -t $CFST_T -n $CFST_N -dn $CFST_DN -tl $CFST_TL -tll $CFST_TLL -sl $CFST_SL -p $CFST_P $ipflag ip.txt $USECC $CCODE_IS echo "./CloudflareST $CFST_URL_R -t $CFST_T -n $CFST_N -dn $CFST_DN -tl $CFST_TL -tll $CFST_TLL -sl $CFST_SL -p $CFST_P $ipflag ip.txt $CF_ADDR $USECC $CCODE_IS" else

开始优选IPv4

echo "./CloudflareST $CFST_URL_R -t $CFST_T -n $CFST_N -dn $CFST_DN -tl $CFST_TL -tll $CFST_TLL -sl $CFST_SL -p $CFST_P $ipflag ip.txt $CF_ADDR $USECC $CCODE_IS" ./CloudflareST $CFST_URL_R -t $CFST_T -n $CFST_N -dn $CFST_DN -tl $CFST_TL -tll $CFST_TLL -sl $CFST_SL -p $CFST_P $ipflag ip.txt $CF_ADDR $USECC $CCODE_IS fi echo "测速完毕" if [ "$pause" = "false" ]; then echo "按要求未重启科学上网服务" sleep 3s else /etc/init.d/$CLIEN restart echo "已重启$CLIEN" echo "为保证cloudflareAPI连接正常 将在3秒后开始更新域名解析" sleep 3s fi

if yq eval 'has("cloudflare")' $configfile; then

length=$(yq eval '.cloudflare | length' $config```bash length=$(yq eval '.cloudflare | length' $configfile)

echo "length:$length" for ((li = 0; li < $length; li++)); do echo "Configuration Group $((li + 1)):" x_email=$(yq eval ".cloudflare[$li].x_email" $configfile) echo "x_email: $x_email" hostname=$(yq eval ".cloudflare[$li].hostname" $configfile) echo "hostname: $hostname" zone_id=$(yq eval ".cloudflare[$li].zone_id" $configfile) api_key=$(yq eval ".cloudflare[$li].api_key" $configfile) ChkHostnameAndCoutryCode if [ $? -eq 1 ]; then echo "ChkHostnameAndCoutryCode() error!" exit 1 fi

source ./ddns/cf_ddns

done

fi

会生成一个名为informlog的临时文件作为推送的内容。

pushmessage=$(cat informlog) echo $pushmessage

if [ ! -z "$sendType" ]; then if [[ $sendType -eq 1 ]]; then source ./msg/cf_push elif [[ $sendType -eq 2 ]]; then source ./msg/wxsend_jiang.sh elif [[ $sendType -eq 3 ]]; then source ./msg/cf_push source ./msg/wxsend_jiang.sh else echo "$sendType is invalid type!" fi fi

此代码在运行时没有提示错误,但是无法解析到相应的域名,请帮忙分析下,我愿意付费解决,谢谢!

frankiejun commented 1 month ago

朋友, 1)首先你的留言暴露了你的隐私,建议你改token。 2)如果翻墙为目的,其实不必使用openwrt上的脚本,使用项目中的vless/trojan脚本部署worker,不设置PROXYIP变量,就能直接用了。这个脚本只是为了优选IP、固定IP,并非翻墙必需。 3)如有交流需要,可以加我tg群。 https://t.me/fanyousuiqun