Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

实现IPv6解析并更新DNS #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions tencentcloud_ddns/files/root/usr/sbin/tencentddns
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ resolve2ip() {
}

check_tencentddns() {
return 1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里为什么提早return了

echo "$DATE WAN-IP: ${ip}"
if [ "Z$ip" == "Z" ]; then
echo "$DATE ERROR, cant get WAN-IP..."
Expand Down Expand Up @@ -91,15 +92,15 @@ get_recordid2() {
}

query_recordid() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最好改成共存

send_request "Record.List" "domain=$main_dm&sub_domain=$sub_dm&record_type=A"
send_request "Record.List" "domain=$main_dm&sub_domain=$sub_dm&record_type=AAAA"
}

update_record() {
send_request "Record.Modify" "domain=$main_dm&sub_domain=$sub_dm&record_id=$1&record_type=A&record_line=%e9%bb%98%e8%ae%a4&value=$ip"
send_request "Record.Modify" "domain=$main_dm&sub_domain=$sub_dm&record_id=$1&record_type=AAAA&record_line=%e9%bb%98%e8%ae%a4&value=$ip"
}

add_record() {
send_request "Record.Create" "domain=$main_dm&sub_domain=$sub_dm&record_type=A&record_line=%e9%bb%98%e8%ae%a4&value=$ip"
send_request "Record.Create" "domain=$main_dm&sub_domain=$sub_dm&record_type=AAAA&record_line=%e9%bb%98%e8%ae%a4&value=$ip"
}

del_record() {
Expand Down Expand Up @@ -154,9 +155,12 @@ sub_dm=$(uci_get_by_name base sub_domain)

iface=$(uci_get_by_name base interface)
if [ "Z$iface" == "Zinternet" -o "Z$iface" == "Z" ]; then
ip=$(intelnetip)
ip=$(ubus call network.interface.wan6 status | grep '"source"' | awk '{print $2}' | awk -F '/' '{print $1}
' | awk -F '"' '{print $2}' | sed -n '3p' | sed 's/\\//')
else
ip=$(ubus call network.interface.$iface status | grep '"address"' | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1)
#ip=$(ubus call network.interface.$iface status | grep '"address"' | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不需要的代码可以删掉

ip=$(ubus call network.interface.wan6 status | grep '"source"' | awk '{print $2}' | awk -F '/' '{print $1}
' | awk -F '"' '{print $2}' | sed -n '3p' | sed 's/\\//')
fi

DATE=$(date +'%Y-%m-%d %H:%M:%S')
Expand Down