mirror of
https://github.com/kenzok8/openwrt-packages
synced 2025-01-05 11:36:38 +08:00
update 2024-04-22 02:00:41
This commit is contained in:
parent
ca66e67fb5
commit
c01da4d0e8
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 chenhw2
|
||||
Copyright (c) 2017-2024 honwen
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2018-2021 chenhw2 <https://github.com/chenhw2/>
|
||||
# Copyright (C) 2018-2024 honwen <https://github.com/honwen/>
|
||||
#
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
@ -7,12 +7,12 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-aliddns
|
||||
PKG_VERSION:=0.4.1
|
||||
PKG_VERSION:=0.4.2
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_LICENSE:=MIT
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
PKG_MAINTAINER:=chenhw2 <https://github.com/chenhw2/>
|
||||
PKG_MAINTAINER:=honwen <https://github.com/honwen/>
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
|
@ -53,7 +53,7 @@ tar axvf lede-sdk-17.01.*-ar71xx-generic_gcc-5.4.0_musl-1.1.16.Linux-x86_64.tar.
|
||||
cd lede-sdk-17.01.*-ar71xx-*
|
||||
# Clone 项目
|
||||
mkdir -p package/feeds
|
||||
git clone https://github.com/chenhw2/luci-app-aliddns.git package/feeds/luci-app-aliddns
|
||||
git clone https://github.com/honwen/luci-app-aliddns.git package/feeds/luci-app-aliddns
|
||||
# 编译 po2lmo (如果有po2lmo可跳过)
|
||||
pushd package/feeds/luci-app-aliddns/tools/po2lmo
|
||||
make && sudo make install
|
||||
|
@ -19,6 +19,9 @@ msgstr "启用 IPv6"
|
||||
msgid "Base"
|
||||
msgstr "基本设置"
|
||||
|
||||
msgid "Internet"
|
||||
msgstr "Internet(ip-api.com)"
|
||||
|
||||
msgid "WAN-IP Source"
|
||||
msgstr "WAN-IP来源"
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
local a = require"luci.sys"
|
||||
local a = require("luci.sys")
|
||||
local e = luci.model.uci.cursor()
|
||||
local e = require"nixio.fs"
|
||||
local e = require("nixio.fs")
|
||||
require("luci.sys")
|
||||
local t, e ,o
|
||||
local t, e, o
|
||||
|
||||
t = Map("aliddns", translate("AliDDNS"))
|
||||
|
||||
@ -15,25 +15,35 @@ enable.rmempty = false
|
||||
enable = e:option(Flag, "clean", translate("Clean Before Update"))
|
||||
enable.rmempty = false
|
||||
|
||||
ipv4 = e:option(Flag,"ipv4",translate("Enabled IPv4"))
|
||||
ipv4.rmempty=false
|
||||
ipv4 = e:option(Flag, "ipv4", translate("Enabled IPv4"))
|
||||
ipv4.rmempty = false
|
||||
|
||||
ipv6 = e:option(Flag,"ipv6",translate("Enabled IPv6"))
|
||||
ipv6.rmempty=false
|
||||
ipv6 = e:option(Flag, "ipv6", translate("Enabled IPv6"))
|
||||
ipv6.rmempty = false
|
||||
|
||||
token = e:option(Value, "app_key", translate("Access Key ID"))
|
||||
|
||||
email = e:option(Value, "app_secret", translate("Access Key Secret"))
|
||||
|
||||
iface = e:option(ListValue, "interface", translate("WAN-IP Source"), translate("Select the WAN-IP Source for AliDDNS, like wan/internet"))
|
||||
iface = e:option(
|
||||
ListValue,
|
||||
"interface",
|
||||
translate("WAN-IP Source"),
|
||||
translate("Select the WAN-IP Source for AliDDNS, like wan/internet")
|
||||
)
|
||||
iface:value("", translate("Select WAN-IP Source"))
|
||||
iface:value("internet")
|
||||
iface:value("internet", translate("Internet"))
|
||||
iface:value("wan")
|
||||
iface.rmempty = false
|
||||
|
||||
iface6 = e:option(ListValue, "interface6", translate("WAN6-IP Source"),translate("Select the WAN6-IP Source for AliDDNS, like wan6/internet"))
|
||||
iface6:value("",translate("Select WAN6-IP Source"))
|
||||
iface6:value("internet")
|
||||
iface6 = e:option(
|
||||
ListValue,
|
||||
"interface6",
|
||||
translate("WAN6-IP Source"),
|
||||
translate("Select the WAN6-IP Source for AliDDNS, like wan6/internet")
|
||||
)
|
||||
iface6:value("", translate("Select WAN6-IP Source"))
|
||||
iface6:value("internet", translate("Internet"))
|
||||
iface6:value("wan")
|
||||
iface6:value("wan6")
|
||||
iface6:value("wan_6")
|
||||
@ -51,21 +61,20 @@ time.rmempty = false
|
||||
e = t:section(TypedSection, "base", translate("Update Log"))
|
||||
e.anonymous = true
|
||||
local a = "/var/log/aliddns.log"
|
||||
tvlog = e:option(TextValue,"sylogtext")
|
||||
tvlog = e:option(TextValue, "sylogtext")
|
||||
tvlog.rows = 16
|
||||
tvlog.readonly = "readonly"
|
||||
tvlog.wrap = "off"
|
||||
|
||||
function tvlog.cfgvalue(e,e)
|
||||
function tvlog.cfgvalue(e, e)
|
||||
sylogtext = ""
|
||||
if a and nixio.fs.access(a) then
|
||||
sylogtext = luci.sys.exec("tail -n 100 %s"%a)
|
||||
sylogtext = luci.sys.exec("tail -n 100 %s" % a)
|
||||
end
|
||||
return sylogtext
|
||||
end
|
||||
|
||||
tvlog.write = function(e,e,e)
|
||||
end
|
||||
tvlog.write = function(e, e, e) end
|
||||
|
||||
local e = luci.http.formvalue("cbi.apply")
|
||||
if e then
|
||||
|
@ -10,35 +10,38 @@ uci_get_by_name() {
|
||||
|
||||
uci_bool_by_name() {
|
||||
case "$(uci_get_by_name $1 $2)" in
|
||||
1|on|true|yes|enabled) return 0;;
|
||||
1 | on | true | yes | enabled) return 0 ;;
|
||||
esac
|
||||
return 1
|
||||
}
|
||||
|
||||
intelnetip() {
|
||||
tmp_ip=`curl -sL --connect-timeout 3 members.3322.org/dyndns/getip`
|
||||
tmp_ip=$(curl -sL --connect-timeout 3 members.3322.org/dyndns/getip)
|
||||
if [ "Z$tmp_ip" == "Z" ]; then
|
||||
tmp_ip=`curl -sL --connect-timeout 3 api-ipv4.ip.sb/ip`
|
||||
tmp_ip=$(curl -sL --connect-timeout 3 api-ipv4.ip.sb/ip)
|
||||
fi
|
||||
if [ "Z$tmp_ip" == "Z" ]; then
|
||||
tmp_ip=`curl -sL --connect-timeout 3 v4.myip.la`
|
||||
tmp_ip=$(curl -sL --connect-timeout 3 v4.myip.la)
|
||||
fi
|
||||
if [ "Z$tmp_ip" == "Z" ]; then
|
||||
tmp_ip=`curl -sL --connect-timeout 3 whatismyip.akamai.com`
|
||||
tmp_ip=$(curl -sL --connect-timeout 3 whatismyip.akamai.com)
|
||||
fi
|
||||
echo -n $tmp_ip
|
||||
}
|
||||
|
||||
intelnetip6() {
|
||||
tmp_ip6=`curl -sL --connect-timeout 3 ipv6.whatismyip.akamai.com`
|
||||
tmp_ip6=$(curl -sL --connect-timeout 3 ipv6.testipv6.cn/ip | sed 's+"+\n+g' | grep -oE '([0-9A-Fa-f]{0,4}:){2,7}([0-9A-Fa-f]{1,4}$|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4})' | head -n1)
|
||||
if [ "Z$tmp_ip6" == "Z" ]; then
|
||||
tmp_ip6=`curl -sL --connect-timeout 3 speed.neu6.edu.cn/getIP.php`
|
||||
tmp_ip6=$(curl -sL --connect-timeout 3 ip6only.me/api | sed 's+,+\n+g' | grep -oE '([0-9A-Fa-f]{0,4}:){2,7}([0-9A-Fa-f]{1,4}$|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4})' | head -n1)
|
||||
fi
|
||||
if [ "Z$tmp_ip6" == "Z" ]; then
|
||||
tmp_ip6=`curl -sL --connect-timeout 3 v6.ident.me`
|
||||
tmp_ip6=$(curl -sL --connect-timeout 3 speed.neu6.edu.cn/getIP.php)
|
||||
fi
|
||||
if [ "Z$tmp_ip6" == "Z" ]; then
|
||||
tmp_ip6=`curl -sL --connect-timeout 3 api-ipv6.ip.sb/ip`
|
||||
tmp_ip6=$(curl -sL --connect-timeout 3 v6.ident.me)
|
||||
fi
|
||||
if [ "Z$tmp_ip6" == "Z" ]; then
|
||||
tmp_ip6=$(curl -sL --connect-timeout 3 api-ipv6.ip.sb/ip)
|
||||
fi
|
||||
echo -n $tmp_ip6
|
||||
}
|
||||
@ -46,15 +49,15 @@ intelnetip6() {
|
||||
resolve2ip() {
|
||||
# resolve2ip domain<string>
|
||||
domain=$1
|
||||
tmp_ip=`nslookup $domain ns1.alidns.com 2>/dev/null | sed '/^Server/d; /#53$/d' | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | tail -n1`
|
||||
tmp_ip=$(nslookup $domain ns1.alidns.com 2>/dev/null | sed '/^Server/d; /#53$/d' | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | tail -n1)
|
||||
if [ "Z$tmp_ip" == "Z" ]; then
|
||||
tmp_ip=`nslookup $domain ns2.alidns.com 2>/dev/null | sed '/^Server/d; /#53$/d' | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | tail -n1`
|
||||
tmp_ip=$(nslookup $domain ns2.alidns.com 2>/dev/null | sed '/^Server/d; /#53$/d' | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | tail -n1)
|
||||
fi
|
||||
if [ "Z$tmp_ip" == "Z" ]; then
|
||||
tmp_ip=`nslookup $domain 114.114.115.115 2>/dev/null | sed '/^Server/d; /#53$/d' | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | tail -n1`
|
||||
tmp_ip=$(nslookup $domain 114.114.115.115 2>/dev/null | sed '/^Server/d; /#53$/d' | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | tail -n1)
|
||||
fi
|
||||
if [ "Z$tmp_ip" == "Z" ]; then
|
||||
tmp_ip=`curl -sL --connect-timeout 3 "119.29.29.29/d?dn=$domain"`
|
||||
tmp_ip=$(curl -sL --connect-timeout 3 "119.29.29.29/d?dn=$domain")
|
||||
fi
|
||||
echo -n $tmp_ip
|
||||
}
|
||||
@ -62,15 +65,15 @@ resolve2ip() {
|
||||
resolve2ip6() {
|
||||
# resolve2ip6 domain<string>
|
||||
domain=$1
|
||||
tmp_ip6=`nslookup $domain ns1.alidns.com 2>/dev/null | sed '/^Server/d; /#53$/d' | grep -oE '([0-9A-Fa-f]{0,4}:){2,7}([0-9A-Fa-f]{1,4}$|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4})' | tail -n1`
|
||||
tmp_ip6=$(nslookup $domain ns1.alidns.com 2>/dev/null | sed '/^Server/d; /#53$/d' | grep -oE '([0-9A-Fa-f]{0,4}:){2,7}([0-9A-Fa-f]{1,4}$|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4})' | tail -n1)
|
||||
if [ "Z$tmp_ip6" == "Z" ]; then
|
||||
tmp_ip6=`nslookup $domain ns2.alidns.com 2>/dev/null | sed '/^Server/d; /#53$/d' | grep -oE '([0-9A-Fa-f]{0,4}:){2,7}([0-9A-Fa-f]{1,4}$|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4})' | tail -n1`
|
||||
tmp_ip6=$(nslookup $domain ns2.alidns.com 2>/dev/null | sed '/^Server/d; /#53$/d' | grep -oE '([0-9A-Fa-f]{0,4}:){2,7}([0-9A-Fa-f]{1,4}$|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4})' | tail -n1)
|
||||
fi
|
||||
if [ "Z$tmp_ip6" == "Z" ]; then
|
||||
tmp_ip6=`nslookup $domain 114.114.115.115 2>/dev/null | sed '/^Server/d; /#53$/d' | grep -oE '([0-9A-Fa-f]{0,4}:){2,7}([0-9A-Fa-f]{1,4}$|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4})' | tail -n1`
|
||||
tmp_ip6=$(nslookup $domain 114.114.115.115 2>/dev/null | sed '/^Server/d; /#53$/d' | grep -oE '([0-9A-Fa-f]{0,4}:){2,7}([0-9A-Fa-f]{1,4}$|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4})' | tail -n1)
|
||||
fi
|
||||
if [ "Z$tmp_ip6" == "Z" ]; then
|
||||
tmp_ip6=`curl -sL --connect-timeout 3 "119.29.29.29/d?dn=$domain&type=AAAA"`
|
||||
tmp_ip6=$(curl -sL --connect-timeout 3 "119.29.29.29/d?dn=$domain&type=AAAA")
|
||||
fi
|
||||
echo -n $tmp_ip6
|
||||
}
|
||||
@ -91,6 +94,7 @@ check_aliddns() {
|
||||
return 0
|
||||
else
|
||||
echo "$DATE UPDATING..."
|
||||
ip6_escape=$(urlencode "$current_ip")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
@ -102,14 +106,12 @@ check_aliddns6() {
|
||||
return 0
|
||||
fi
|
||||
current_ip6=$(resolve2ip6 "$dm_real")
|
||||
echo "$DATE DOMAIN-IP6: ${current_ip6}"
|
||||
|
||||
#urlencode current_ip6
|
||||
current_ip6_urlencode=$(urlencode "$current_ip6")
|
||||
if [ "Z$current_ip6_urlencode" == "Z" ]; then
|
||||
if [ "Z$current_ip6" == "Z" ]; then
|
||||
rrid6='' # NO Resolve IP Means new Record_ID
|
||||
fi
|
||||
echo "$DATE DOMAIN-IP6: ${current_ip6_urlencode}"
|
||||
if [ "Z$ip6" == "Z$current_ip6_urlencode" ]; then
|
||||
if [ "Z$ip6" == "Z$current_ip6" ]; then
|
||||
echo "$DATE IPv6 dont need UPDATE..."
|
||||
return 0
|
||||
else
|
||||
@ -118,14 +120,13 @@ check_aliddns6() {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
urlencode() {
|
||||
# urlencode url<string>
|
||||
out=''
|
||||
for c in $(echo -n $1 | sed 's/[^\n]/&\n/g'); do
|
||||
case $c in
|
||||
[a-zA-Z0-9._-]) out="$out$c" ;;
|
||||
*) out="$out$(printf '%%%02X' "'$c")" ;;
|
||||
[a-zA-Z0-9._-]) out="$out$c" ;;
|
||||
*) out="$out$(printf '%%%02X' "'$c")" ;;
|
||||
esac
|
||||
done
|
||||
echo -n $out
|
||||
@ -171,7 +172,7 @@ del_record() {
|
||||
}
|
||||
|
||||
do_ddns_record() {
|
||||
if uci_bool_by_name base clean ; then
|
||||
if uci_bool_by_name base clean; then
|
||||
query_recordid | get_recordid | while read rr; do
|
||||
echo "$DATE Clean record $dm_show: $rr"
|
||||
del_record $rr >/dev/null
|
||||
@ -180,10 +181,10 @@ do_ddns_record() {
|
||||
rrid=''
|
||||
fi
|
||||
if [ "Z$rrid" == "Z" ]; then
|
||||
rrid=`query_recordid | get_recordid`
|
||||
rrid=$(query_recordid | get_recordid)
|
||||
fi
|
||||
if [ "Z$rrid" == "Z" ]; then
|
||||
rrid=`add_record | get_recordid`
|
||||
rrid=$(add_record | get_recordid)
|
||||
echo "$DATE ADD record $rrid"
|
||||
else
|
||||
update_record $rrid >/dev/null 2>&1
|
||||
@ -201,7 +202,7 @@ do_ddns_record() {
|
||||
}
|
||||
|
||||
do_ddns_record6() {
|
||||
if uci_bool_by_name base clean ; then
|
||||
if uci_bool_by_name base clean; then
|
||||
query_recordid6 | get_recordid | while read rr; do
|
||||
echo "$DATE Clean record $dm_show: $rr"
|
||||
del_record $rr >/dev/null
|
||||
@ -210,10 +211,10 @@ do_ddns_record6() {
|
||||
rrid6=''
|
||||
fi
|
||||
if [ "Z$rrid6" == "Z" ]; then
|
||||
rrid6=`query_recordid6 | get_recordid`
|
||||
rrid6=$(query_recordid6 | get_recordid)
|
||||
fi
|
||||
if [ "Z$rrid6" == "Z" ]; then
|
||||
rrid6=`add_record6 | get_recordid`
|
||||
rrid6=$(add_record6 | get_recordid)
|
||||
echo "$DATE ADD record $rrid6"
|
||||
else
|
||||
update_record6 $rrid6 >/dev/null 2>&1
|
||||
@ -231,25 +232,25 @@ do_ddns_record6() {
|
||||
}
|
||||
|
||||
clean_log() {
|
||||
if [ $(cat $log_file 2>/dev/null | wc -l) -ge 16 ]; then
|
||||
if [ $(cat $log_file 2>/dev/null | wc -l) -ge 240 ]; then
|
||||
rm -f $log_file && touch $log_file
|
||||
echo "$DATE Log Cleaned"
|
||||
fi
|
||||
}
|
||||
|
||||
[ -x /usr/bin/openssl -a -x /usr/bin/curl -a -x /bin/sed ] || {
|
||||
echo "Need [ openssl + curl + sed ]"
|
||||
exit 1
|
||||
echo "Need [ openssl + curl + sed ]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
ipv4=$(uci_get_by_name base ipv4)
|
||||
ipv6=$(uci_get_by_name base ipv6)
|
||||
ak_id=$(uci_get_by_name base app_key)
|
||||
ak_sec=$(uci_get_by_name base app_secret)
|
||||
rrid=$(uci_get_by_name base record_id)
|
||||
rrid6=$(uci_get_by_name base record_id6)
|
||||
ipv4=$(uci_get_by_name base ipv4)
|
||||
ipv6=$(uci_get_by_name base ipv6)
|
||||
ak_id=$(uci_get_by_name base app_key)
|
||||
ak_sec=$(uci_get_by_name base app_secret)
|
||||
rrid=$(uci_get_by_name base record_id)
|
||||
rrid6=$(uci_get_by_name base record_id6)
|
||||
main_dm=$(uci_get_by_name base main_domain)
|
||||
sub_dm=$(uci_get_by_name base sub_domain)
|
||||
sub_dm=$(uci_get_by_name base sub_domain)
|
||||
|
||||
if [ "Z$sub_dm" == "Z@" -o "Z$sub_dm" == "Z" ]; then
|
||||
dm_real="$main_dm"
|
||||
@ -257,9 +258,10 @@ else
|
||||
dm_real="$sub_dm.$main_dm"
|
||||
fi
|
||||
dm_show="$sub_dm.$main_dm"
|
||||
dm_escape=`urlencode "$sub_dm.$main_dm"`
|
||||
sub_dm_escape=`urlencode "$sub_dm"`
|
||||
dm_escape=$(urlencode "$sub_dm.$main_dm")
|
||||
sub_dm_escape=$(urlencode "$sub_dm")
|
||||
|
||||
# ================================================== ddns v4 ==================================================
|
||||
iface=$(uci_get_by_name base interface)
|
||||
if [ "Z$iface" == "Zinternet" -o "Z$iface" == "Z" ]; then
|
||||
ip=$(intelnetip)
|
||||
@ -270,14 +272,13 @@ fi
|
||||
DATE=$(date +'%Y-%m-%d %H:%M:%S')
|
||||
timestamp=$(date -u "+%Y-%m-%dT%H%%3A%M%%3A%SZ")
|
||||
|
||||
clean_log
|
||||
# uci_bool_by_name base ipv4 && check_aliddns || do_ddns_record
|
||||
if [ $ipv4 -eq 1 ]; then
|
||||
check_aliddns || do_ddns_record
|
||||
fi
|
||||
# ================================================== ddns v4 ==================================================
|
||||
|
||||
# exit if ipv6 not-enabled
|
||||
# uci_bool_by_name base ipv6 || exit 0
|
||||
# ================================================== ddns v6 ==================================================
|
||||
|
||||
iface6=$(uci_get_by_name base interface6)
|
||||
if [ "Z$iface6" == "Zinternet" -o "Z$iface6" == "Z" ]; then
|
||||
@ -285,10 +286,12 @@ if [ "Z$iface6" == "Zinternet" -o "Z$iface6" == "Z" ]; then
|
||||
else
|
||||
ip6=$(ubus call network.interface.$iface6 status | grep '"address"' | grep -oE '([0-9A-Fa-f]{0,4}:){2,7}([0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){4})' | head -1)
|
||||
fi
|
||||
ip6_escape=`urlencode "$ip6"`
|
||||
ip6_escape=$(urlencode "$ip6")
|
||||
|
||||
# clean_log
|
||||
# uci_bool_by_name base ipv6 && check_aliddns6 || do_ddns_record6
|
||||
if [ $ipv6 -eq 1 ]; then
|
||||
check_aliddns6 || do_ddns_record6
|
||||
fi
|
||||
# ================================================== ddns v6 ==================================================
|
||||
|
||||
clean_log
|
||||
|
Loading…
Reference in New Issue
Block a user