From f29fb21b675728cc7a263d7dc8651673cc3dc11b Mon Sep 17 00:00:00 2001 From: YMNNs Date: Mon, 7 Dec 2020 16:22:34 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=80=82=E9=85=8D380=E5=9B=BA=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 ++ ddns-start | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0a5e0eb..89ed515 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ 对荒野无灯基于[anrip](https://github.com/anrip/ArDNSPod)的脚本添加 ipv6 支持 * 2019.01.21 - 由于梅林获取ipv6有延迟,修改了下脚本,只在ddns ipv4 更新后通知梅林成功,更新ipv6后不会通知。当然实际上已经可用了 +* 2020.12.07 - 由于部分固件的wget版本过旧导致无法连接dnspod,故改为curl +* ​ - 获取ipv6的方式从ppp0改为br0,匹配`240x:xxxx:........` 荒野无灯原帖:http://koolshare.cn/thread-37553-1-1.html diff --git a/ddns-start b/ddns-start index db61410..97b08a5 100644 --- a/ddns-start +++ b/ddns-start @@ -10,8 +10,9 @@ # ReMod: 寒霜 https://www.frost.net.cn 2018-12-06 ################################################# +# 使用前请修改第15行和第149行 # 使用Token认证(推荐) 请去 https://www.dnspod.cn/console/user/security 获取 -arToken="23745,b55b4692822de38a8d0955bc66bbfc5a" +arToken="xxxxx,xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # 使用邮箱和密码认证 arMail="" arPass="" @@ -24,11 +25,11 @@ arIpAdress() { # 获得外网ipv6地址 arIpAdress_v6() { - local hostIP_v6=$(ip addr show ppp0 | grep inet6 | sed 's/\/.*//g' | awk '{print $2}' | grep 2408) + local hostIP_v6=$(ip addr show br0 | grep inet6 | sed 's/\/.*//g' | awk '{print $2}' | grep 240) while [[ -z $hostIP_v6 ]] do sleep 60 - hostIP_v6=$(ip addr show ppp0 | grep inet6 | sed 's/\/.*//g' | awk '{print $2}' | grep 2408) + hostIP_v6=$(ip addr show br0 | grep inet6 | sed 's/\/.*//g' | awk '{print $2}' | grep 240) done echo $hostIP_v6 } @@ -43,7 +44,9 @@ arApiPost() { else local param="login_token=${arToken}&format=json&${2}" fi - wget --quiet --no-check-certificate --output-document=- --user-agent=$agent --post-data $param $inter + # wget --no-check-certificate --output-document=- --user-agent=$agent --post-data $param $inter + # 此处使用curl以避免ssl错误 + curl -s --user-agent "$agent" -d $param $inter } # 获得ID与初步数据 @@ -144,5 +147,4 @@ arDdnsCheck() { ################################################### # 检查更新域名 # 指定 domain subdomain -arDdnsCheck "frostfall.cn" "" - +arDdnsCheck "xxxxxxx.xxx" "xxx" \ No newline at end of file From 1c877fa4096274135b5b764208d5a70d5bb3224f Mon Sep 17 00:00:00 2001 From: YMNNs Date: Mon, 7 Dec 2020 16:42:34 +0800 Subject: [PATCH 2/2] Update ddns-start --- ddns-start | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/ddns-start b/ddns-start index 97b08a5..a46bfad 100644 --- a/ddns-start +++ b/ddns-start @@ -8,11 +8,12 @@ # 时间: 2016-02-24 16:25:00 # Mod: 荒野无灯 http://ihacklog.com 2016-03-16 # ReMod: 寒霜 https://www.frost.net.cn 2018-12-06 +# Refine: YMNNs https://github.com/YMNNs 2020-12-7 ################################################# -# 使用前请修改第15行和第149行 +# 注意,请将第29行和第33行末尾的"240"改为公网ipv6的前3-4个字符 # 使用Token认证(推荐) 请去 https://www.dnspod.cn/console/user/security 获取 -arToken="xxxxx,xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +arToken="xxx,xxxxxxxxxxxxxxxxxxxxxxxxx" # 使用邮箱和密码认证 arMail="" arPass="" @@ -45,7 +46,6 @@ arApiPost() { local param="login_token=${arToken}&format=json&${2}" fi # wget --no-check-certificate --output-document=- --user-agent=$agent --post-data $param $inter - # 此处使用curl以避免ssl错误 curl -s --user-agent "$agent" -d $param $inter } @@ -122,17 +122,6 @@ arDdnsCheck() { lastIP=$(arNslookup) echo "lastIP: ${lastIP}" - if [ "$lastIP" != "$hostIP" ]; then - arDdnsUpdate - if [ $? -ne 0 ]; then - /sbin/ddns_custom_updated 1 - else - /sbin/ddns_custom_updated 0 - fi - else - /sbin/ddns_custom_updated 1 - fi - # ipv6 hostIP_v6=$(arIpAdress_v6) echo "hostIP_v6: ${hostIP_v6}" @@ -142,9 +131,20 @@ arDdnsCheck() { if [ "$lastIP_v6" != "$hostIP_v6" ]; then arDdnsUpdate_v6 ${hostIP_v6} fi + + if [ "$lastIP_v6" != "$hostIP_v6" ]; then + arDdnsUpdate + if [ $? -ne 0 ]; then + /sbin/ddns_custom_updated 1 + else + /sbin/ddns_custom_updated 0 + fi + else + /sbin/ddns_custom_updated 1 + fi } ################################################### # 检查更新域名 # 指定 domain subdomain -arDdnsCheck "xxxxxxx.xxx" "xxx" \ No newline at end of file +arDdnsCheck "xxxxx.xxx" "xxxx" \ No newline at end of file