update 2022-05-15 07:46:44

This commit is contained in:
github-actions[bot] 2022-05-15 07:46:44 +08:00
parent 3495200824
commit 1fce514c4a
13 changed files with 639 additions and 327 deletions

View File

@ -1,57 +1,42 @@
# Copyright (C) 2016 Openwrt.org
#
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI support for Koolddns
LUCI_DEPENDS:=+curl +libcurl
LUCI_PKGARCH:=all
PKG_NAME:=luci-app-koolddns
PKG_VERSION:=20220321
PKG_RELEASE:=2
PKG_MAINTAINER:=fw867
PKG_VERSION:=1.1
PKG_RELEASE:=4
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
#PKG_USE_MIPS16:=0
include $(INCLUDE_DIR)/package.mk
define Package/$(PKG_NAME)
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=3. Applications
PKGARCH:=all
TITLE:=luci for koolddns
DEPENDS:=+koolddns
endef
define Package/$(PKG_NAME)/description
A luci app for koolddns, forked from koolshare Lede X64. Thanks to fw867.
Luci Support for koolddns.
endef
define Package/$(PKG_NAME)/preinst
endef
define Package/$(PKG_NAME)/postinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
if [ -f /etc/uci-defaults/luci-koolddns ]; then
( . /etc/uci-defaults/luci-koolddns ) && rm -f /etc/uci-defaults/luci-koolddns
fi
rm -rf /tmp/luci-indexcache
fi
exit 0
endef
define Build/Prepare
endef
define Build/Configure
$(foreach po,$(wildcard ${CURDIR}/po/zh-cn/*.po), \
po2lmo $(po) $(PKG_BUILD_DIR)/$(patsubst %.po,%.lmo,$(notdir $(po)));)
endef
define Build/Compile
endef
define Package/$(PKG_NAME)/conffiles
/etc/config/koolddns
/etc/koolddns/
endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/lib/lua/luci
cp -pR ./luasrc/* $(1)/usr/lib/lua/luci
$(INSTALL_DIR) $(1)/
cp -pR ./root/* $(1)/
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
$(INSTALL_DATA) $(PKG_BUILD_DIR)/koolddns.lmo $(1)/usr/lib/lua/luci/i18n/
endef
include $(TOPDIR)/feeds/luci/luci.mk

View File

@ -11,22 +11,14 @@ end
function act_nslookup()
local e={}
e.index=luci.http.formvalue("index")
--e.value=luci.sys.exec("nslookup %q localhost 2>&1|grep 'Address 1:'|tail -n1|cut -d' ' -f3"%luci.http.formvalue("domain"))
e.value=luci.sys.exec("dig @8.8.4.4 %q 2>&1 |grep 'IN'|awk '{print $5}'|grep -E '([0-9]{1,3}[\.]){3}[0-9]{1,3}'|head -n1"%luci.http.formvalue("domain"))
if e.value=="" then
e.value=luci.sys.exec("dig @8.8.8.8 %q 2>&1 |grep 'IN'|awk '{print $5}'|grep -E '([0-9]{1,3}[\.]){3}[0-9]{1,3}'|head -n1"%luci.http.formvalue("domain"))
if e.value=="" then
e.value="127.0.0.1"
end
end
e.value=luci.sys.exec("nslookup %q localhost 2>&1|grep 'Address:'|tail -n1|cut -d' ' -f2"%luci.http.formvalue("domain"))
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
function act_curl()
local e={}
e.index=luci.http.formvalue("index")
--e.value=luci.sys.exec("curl -s %q 2>&1"%luci.http.formvalue("url"))
e.value=luci.http.formvalue("url")
e.value=luci.sys.exec("curl -s %q 2>&1"%luci.http.formvalue("url"))
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end

View File

@ -1,10 +1,9 @@
local n="koolddns"
local i=require"luci.dispatcher"
local o=require"luci.model.network".init()
local m=require"nixio.fs"
local a,t,e
arg[1]=arg[1]or""
a=Map(n,translate("Koolddns Config"))
a=Map(n,translate("DDNS Config"))
a.redirect=i.build_url("admin","services","koolddns")
t=a:section(NamedSection,arg[1],"koolddns","")
t.addremove=false
@ -19,42 +18,14 @@ e.datatype="host"
e.rmempty=false
e=t:option(Value,"name",translate("Sub Domain"))
e.rmempty=false
e=t:option(ListValue,"record_type",translate("Record Type"))
e.rmempty=false
e.default="A"
e:value("A",translate("A Record"))
e:value("AAAA",translate("AAAA Record"))
e:depends("service","aliddns")
e=t:option(ListValue,"ttl_time",translate("TTL"))
e.rmempty=false
e.default="600"
e:value("600",translate("600s"))
e:value("120",translate("120s"))
e:value("60",translate("60s"))
e:value("10",translate("10s"))
e:depends("service","aliddns")
e=t:option(ListValue,"service",translate("Service Providers"))
if m.access("/usr/bin/klaliddns")then
e:value("aliddns",translate("AliDDNS"))
end
if m.access("/usr/bin/klcloudxns")then
e:value("cloudxns",translate("CloudXNS"))
end
if m.access("/usr/bin/kldnspod")then
e:value("dnspod",translate("DNSPOD"))
end
e.rmempty=false
e=t:option(Value,"accesskey",translate("Access Key"))
e=t:option(Value,"accesskey",translate("Token ID"))
e.rmempty=false
e:depends("service","aliddns")
e:depends("service","cloudxns")
e=t:option(Value,"signature",translate("Signature"))
e=t:option(Value,"signature",translate("Token Key"))
e.rmempty=false
e:depends("service","aliddns")
e:depends("service","cloudxns")
e=t:option(Value,"apitoken",translate("API Token"),translate("Go to dnspod.cn/console/user/security settings, (format: ID, Token), such as: 11220,2d11d8bd2711s8dr56y10564f9648523"))
e.rmempty=false
e:depends("service","dnspod")
e=t:option(Value,"interface",translate("Interface"))
e.rmempty=false
e:value("url",translate("Use the URL to obtain the public IP"))

View File

@ -12,9 +12,9 @@ t.anonymous=true
t.addremove=false
e=t:option(Flag,"enabled",translate("Enable"))
e.rmempty=false
e=t:option(Value,"time",translate("Update Time"),translate("0 means disable this feature, unit: min"))
e.datatype="range(0,59)"
e.default=30
e=t:option(Value,"time",translate("Update Time"))
e.datatype="uinteger"
e.default=10
e.rmempty=false
t=a:section(TypedSection,"koolddns",translate("Domain List"))
t.anonymous=true
@ -50,30 +50,15 @@ e.width="15%"
e.template="koolddns/url"
e.cfgvalue=function(t,o)
local t=a.uci:get(i,o,"interface")or""
local b=a.uci:get(i,o,"ipurl")or""
local c=a.uci:get(i,o,"urlinterface")or""
if t=="url"then
c=luci.sys.exec("uci -P /var/state get network.%s.ifname 2>/dev/null"%c)or""
if c==""then return""end
c=luci.sys.exec("curl --interface %q -s %q 2>&1"%{c,b})or""
return c end
local a=a.uci:get(i,o,"ipurl")or""
if t=="url"then return a end
if t==""then return""end
local t=luci.sys.exec("uci -P /var/state get network.%s.ifname 2>/dev/null"%t)or""
if t==""then return""end
local t=luci.sys.exec("ifconfig %q|grep 'inet addr'|awk '{print $2}'|cut -d: -f2"%t)or""
return t
end
e=t:option(DummyValue,"nslookupip",translate("Nslookup").." IP")
e.width="15%"
e.template="koolddns/domain"
e.cfgvalue=function(t,n)
local t=a.uci:get(i,n,"domain")or""
local a=a.uci:get(i,n,"name")or""
if t==""or a==""then return""end
if a=="@" then o="%s"%{t} return o end
o="%s.%s"%{a,t}
return o
end
e=t:option(Flag,"enable",translate("Enable State"))
e.width="10%"
e.rmempty=false
@ -88,7 +73,7 @@ luci.http.redirect(luci.dispatcher.build_url("admin","services","koolddns"))
end
e=t:option(TextValue,"log")
e.rows=20
e.wrap="off"
e.wrap="on"
e.readonly=true
e.cfgvalue=function(t,t)
return s.readfile("/var/log/koolddns.log")or""

View File

@ -0,0 +1,4 @@
config global
option time '10'
option enabled '0'

View File

@ -0,0 +1,98 @@
#!/bin/sh /etc/rc.common
#copyright by koolshare.cn crwnet
START=95
STOP=10
EXTRA_COMMANDS="update"
EXTRA_HELP=" update Perform the update immediately"
LOGFILE="/var/log/koolddns.log"
DATE=$(date +'%Y-%m-%d %H:%M:%S')
Reduce_Log(){
local log=$1
[ ! -f "$log" ] && return
local sc=100
[ -n "$2" ] && sc=$2
local count=$(grep -c "" $log)
if [ $count -gt $sc ];then
let count=count-$sc
sed -i "1,$count d" $log
fi
}
get_config()
{
config_get_bool enable $1 enable 0
config_get service $1 service
config_get domain $1 domain
config_get name $1 name
config_get interface $1 interface
[ $enable -eq 0 ] || [ -z "$service" ] || [ -z "$domain" ] || [ -z "$name" ] || [ -z "$interface" ] && return
echo $DATE: -------------------------------------------------- >>$LOGFILE
echo $DATE: 目标域名: $name.$domain >>$LOGFILE
if [ "$interface" = "url" ]; then
config_get ipurl $1 ipurl
config_get urlinterface $1 urlinterface
[ -n "$urlinterface" ] && urlif=$(uci -P /var/state get network.$urlinterface.ifname 2>/dev/null)
[ -n "$urlif" ] && urlface="--interface $urlif"
ip=$(curl $urlface -s $ipurl 2>&1)
[ -z $(echo $ip|grep -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}") ] && echo $DATE: "通过URL获取公网IP出错" >>$LOGFILE && echo >>$LOGFILE && return
else
ifname=`uci -P /var/state get network.$interface.ifname 2>/dev/null`
[ $? -eq 1 ] && echo $DATE: "获取网络 $interface 信息出错" >>$LOGFILE && echo >>$LOGFILE && return
ip=$(ifconfig $ifname 2>/dev/null | grep 'inet addr' | awk '{print $2}' | cut -d: -f2 2>/dev/null)
[ -z "$ip" ] && echo $DATE: "获取网络 $interface 接口 $ifname 信息出错" >>$LOGFILE && echo >>$LOGFILE && return
fi
config_get record_id $1 record_id
if [ "$service" = "aliddns" ]; then
config_get accesskey $1 accesskey
config_get signature $1 signature
/usr/share/koolddns/aliddns "$enable" "$accesskey" "$signature" "$domain" "$name" "$ip" "$record_id" "$1" >>$LOGFILE
fi
if [ "$service" = "dnspod" ]; then
config_get accesskey $1 accesskey
config_get signature $1 signature
/usr/share/koolddns/dnspod "$enable" "$accesskey" "$signature" "$domain" "$name" "$ip" "$record_id" "$1" >>$LOGFILE
fi
}
update(){
Reduce_Log $LOGFILE
config_load koolddns
config_foreach get_config koolddns
}
reload(){
stop
start
update
}
del_cru(){
if [ -f "/etc/crontabs/root" ] && [ $(cat /etc/crontabs/root | grep koolddns | wc -l) -ne 0 ]; then
sed -i '/koolddns/d' /etc/crontabs/root >/dev/null 2>&1
fi
}
add_cru(){
local time=$(uci get koolddns.@global[0].time)
local cmd="*/$time * * * * /etc/init.d/koolddns update"
if [ ! -f "/etc/crontabs/root" ] || [ $(cat /etc/crontabs/root | grep "$cmd" | wc -l) -eq 0 ]; then
sed -i '/koolddns/d' /etc/crontabs/root >/dev/null 2>&1
echo "$cmd" >> /etc/crontabs/root
fi
}
start() {
local enabled=$(uci get koolddns.@global[0].enabled)
[ "$enabled" -eq 0 ] && exit
add_cru
}
stop() {
del_cru
}

View File

@ -0,0 +1,98 @@
#!/bin/sh
aliddns_enable=$1
aliddns_ak=$2
aliddns_sk=$3
aliddns_domain=$4
aliddns_name=$5
ip=$6
aliddns_record_id=$7
my=$8
log_file="/var/log/koolddns.log"
DATE=$(date +'%Y-%m-%d %H:%M:%S')
timestamp=`date -u "+%Y-%m-%dT%H%%3A%M%%3A%SZ"`
check_aliddns() {
echo "$DATE: 当前路由IP: ${ip}" >> $log_file
current_ip=`echo $query_result | sed 's/.*,"Value":"\([0-9\.]*\)",.*/\1/'`
isip=`echo $current_ip | grep -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}"`
[ -n "$isip" ] && echo "$DATE: 远程解析IP: ${current_ip}" >> $log_file
if [ "$ip" = "$current_ip" ];then
echo "$DATE: IP未改变无需更新" >> $log_file
exit 0
else
echo "$DATE: 更新中..." >> $log_file
fi
}
urlencode() {
# urlencode <string>
local length="${#1}"
i=0
out=""
for i in $(awk "BEGIN { for ( i=0; i<$length; i++ ) { print i; } }")
do
local c="${1:$i:1}"
case $c in
[a-zA-Z0-9._-]) out="$out$c" ;;
*) out="$out`printf '%%%02X' "'$c"`" ;;
esac
i=$(($i + 1))
done
echo -n $out
}
send_request() {
local args="AccessKeyId=$aliddns_ak&Action=$1&Format=json&$2&Version=2015-01-09"
local hash=$(urlencode $(echo -n "GET&%2F&$(urlencode $args)" | openssl dgst -sha1 -hmac "$aliddns_sk&" -binary | openssl base64))
wget -qO- "http://alidns.aliyuncs.com/?$args&Signature=$hash" 2> /dev/null
}
get_recordid() {
grep -Eo '"RecordId":"[0-9]+"' | cut -d':' -f2 | tr -d '"'
}
query_recordid() {
send_request "DescribeSubDomainRecords" "SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&SubDomain=$(urlencode "$aliddns_name").$aliddns_domain&Timestamp=$timestamp"
}
update_record() {
send_request "UpdateDomainRecord" "RR=$(urlencode "$aliddns_name")&RecordId=$1&SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&Timestamp=$timestamp&Type=A&Value=$ip"
}
add_record() {
send_request "AddDomainRecord&DomainName=$aliddns_domain" "RR=$(urlencode "$aliddns_name")&SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&Timestamp=$timestamp&Type=A&Value=$ip"
}
go_record() {
if [ "$aliddns_record_id" = "" ];then
aliddns_record_id=`echo $query_result | get_recordid`
fi
if [ "$aliddns_record_id" = "" ];then
aliddns_record_id=`add_record | get_recordid`
else
update_record $aliddns_record_id
fi
# save to file
if [ "$aliddns_record_id" = "" ];then
echo "$DATE: 更新出错,请检查设置!" >> $log_file
exit 0
else
uci set koolddns.$my.record_id=$aliddns_record_id
uci commit
echo "$DATE: 更新成功!($ip)" >> $log_file
fi
}
if [ "$aliddns_enable" != "1" ]; then
echo "$DATE: aliddns没有开启" >> $log_file
else
query_result=$(query_recordid)
check_aliddns
go_record
fi

View File

@ -0,0 +1,109 @@
#!/bin/sh
dnspod_enable=$1
dnspod_ak=$2
dnspod_sk=$3
dnspod_domain=$4
dnspod_name=$5
ip=$6
dnspod_record_id=$7
my=$8
log_file="/var/log/koolddns.log"
DATE=$(date +'%Y-%m-%d %H:%M:%S')
timestamp=`date -u "+%Y-%m-%dT%H%%3A%M%%3A%SZ"`
check_dnspod() {
echo "$DATE: 当前路由IP: ${ip}" >> $log_file
current_ip=`echo $query_result | sed 's/.*,"Value":"\([0-9\.]*\)",.*/\1/'`
isip=`echo $current_ip | grep -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}"`
[ -n "$isip" ] && echo "$DATE: 远程解析IP: ${current_ip}" >> $log_file
if [ "$ip" = "$current_ip" ];then
echo "$DATE: IP未改变无需更新" >> $log_file
exit 0
else
echo "$DATE: 更新中..." >> $log_file
fi
}
urlencode() {
# urlencode <string>
local length="${#1}"
i=0
out=""
for i in $(awk "BEGIN { for ( i=0; i<$length; i++ ) { print i; } }")
do
local c="${1:$i:1}"
case $c in
[a-zA-Z0-9._-]) out="$out$c" ;;
*) out="$out`printf '%%%02X' "'$c"`" ;;
esac
i=$(($i + 1))
done
echo -n $out
}
send_request() {
local args="login_token=$dnspod_ak,$dnspod_sk&Format=json&$2"
/usr/bin/wget --no-check-certificate --post-data "$args" "https://dnsapi.cn/$1" -O /tmp/ddnspod
isinvalid=`cat /tmp/ddnspod | egrep -C8 "<message>" | grep "<message>" | awk -F'>' '{print $2}' | awk -F'<' '{print $1}' | grep invalid`
if [ -n "$isinvalid" ];then
echo "$DATE: token更新0" >> $log_file
exit 0
fi
}
get_recordid() {
egrep -C8 "<name>$dnspod_name</name>"|grep "<id>"|awk -F'>' '{print $2}'|awk -F'<' '{print $1}'
}
get_recordid2() {
grep 'id'|awk -F'>' '{print $2}'|awk -F'<' '{print $1}'
}
query_recordid() {
send_request "Record.List" "domain=$dnspod_domain"
}
update_record() {
send_request "Record.Ddns" "domain=$dnspod_domain&record_id=$1&record_line=默认&sub_domain=$dnspod_name&value=$ip"
}
add_record() {
send_request "Record.Create" "domain=$dnspod_domain&sub_domain=$dnspod_name&record_type=A&record_line=默认&value=$ip"
}
go_record() {
if [ "$dnspod_record_id" = "" ];then
query_recordid
dnspod_record_id=`cat /tmp/ddnspod | get_recordid`
fi
if [ "$dnspod_record_id" = "" ];then
add_record
dnspod_record_id=`cat /tmp/ddnspod | get_recordid2`
else
update_record $dnspod_record_id
fi
# save to file
if [ "$dnspod_record_id" = "" ];then
echo "$DATE: 更新出错,请检查设置!" >> $log_file
exit 0
else
uci set koolddns.$my.record_id=$dnspod_record_id
uci commit
echo "$DATE: 更新成功!($ip)" >> $log_file
fi
}
if [ "$dnspod_enable" != "1" ]; then
echo "$DATE: dnspod没有开启" >> $log_file
else
query_recordid
query_result=`cat /tmp/ddnspod`
check_dnspod
go_record
fi

View File

@ -1,11 +0,0 @@
{
"luci-app-koolddns": {
"description": "Luci interface for the koolddns",
"read": {
"uci": [ "koolddns" ]
},
"write": {
"uci": [ "koolddns" ]
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -23,7 +23,7 @@ m.description=translate("Convert Subscribe function of Online is Supported By su
"<br/>"..
"<br/>"..translate("If you need to customize the external configuration file (subscription conversion template), please write it according to the instructions, upload it to the accessible location of the external network, and fill in the address correctly when using it")..
"<br/>"..
"<br/>"..translate("If you have a recommended external configuration file (subscription conversion template), you can modify by following The file format of /usr/share/opencrash/res/sub_ini.list and pr")
"<br/>"..translate("If you have a recommended external configuration file (subscription conversion template), you can modify by following The file format of /usr/share/openclash/res/sub_ini.list and pr")
m.redirect = luci.dispatcher.build_url("admin/services/openclash/config-subscribe")
if m.uci:get(openclash, sid) ~= "config_subscribe" then
luci.http.redirect(m.redirect)

View File

@ -1564,7 +1564,7 @@ msgstr "开始下载"
msgid "Download Successful, Start Pre Update Test..."
msgstr "下载成功,开始进行更新前测试..."
msgid "Pre Update Test Failed, The File is Saved in /tmp/opencrash.ipk, Please Try to Update Manually!"
msgid "Pre Update Test Failed, The File is Saved in /tmp/openclash.ipk, Please Try to Update Manually!"
msgstr "更新前测试失败,文件保存在 /tmp/openclash.ipk请尝试手动更新"
msgid "Pre Update Test Passed, Ready to Update and Please Do not Refresh The Page and Other Operations..."
@ -2113,7 +2113,7 @@ msgstr "subconverter 外部配置(订阅转换模板)说明https://github.com
msgid "If you need to customize the external configuration file (subscription conversion template), please write it according to the instructions, upload it to the accessible location of the external network, and fill in the address correctly when using it"
msgstr "如需自定义外部配置文件(订阅转换模板),请按照说明编写后上传至外部网络可访问的位置,并在使用时正确填写地址"
msgid "If you have a recommended external configuration file (subscription conversion template), you can modify by following The file format of /usr/share/opencrash/res/sub_ini.list and pr"
msgid "If you have a recommended external configuration file (subscription conversion template), you can modify by following The file format of /usr/share/openclash/res/sub_ini.list and pr"
msgstr "如您有值得推荐的外部配置文件(订阅转换模板),可以按照 /usr/share/openclash/res/sub_ini.list 的文件格式修改后提交PR"
msgid "Note: To restore the default configuration, try accessing:"
@ -2933,4 +2933,4 @@ msgid "Enable Tcp Concurrent"
msgstr "*启用 TCP 并发"
msgid "TCP Concurrent Request IPs, Choose The Lowest Latency One To Connection"
msgstr "TCP 并发请求所有 IP 地址,然后选择延迟最低的一个进行连接"
msgstr "TCP 并发请求所有 IP 地址,然后选择延迟最低的一个进行连接"

View File

@ -47,7 +47,7 @@ if [ "$(expr "$OP_LV" \> "$OP_CV")" -eq 1 ] && [ -f "$LAST_OPVER" ]; then
LOG_OUT "【OpenClash - v$LAST_VER】Download Successful, Start Pre Update Test..."
if [ -z "$(opkg install /tmp/openclash.ipk --noaction 2>/dev/null |grep 'Upgrading luci-app-openclash on root' 2>/dev/null)" ]; then
LOG_OUT "【OpenClash - v$LAST_VER】Pre Update Test Failed, The File is Saved in /tmp/opencrash.ipk, Please Try to Update Manually!"
LOG_OUT "【OpenClash - v$LAST_VER】Pre Update Test Failed, The File is Saved in /tmp/openclash.ipk, Please Try to Update Manually!"
if [ "$(uci -q get openclash.config.config_reload)" -eq 0 ]; then
/etc/init.d/openclash restart >/dev/null 2>&1 &
else
@ -123,4 +123,4 @@ else
SLOG_CLEAN
fi
fi
del_lock
del_lock