mirror of
https://github.com/tsingui/softcenter-1.git
synced 2024-11-14 09:55:17 +00:00
add Cloudflare ddns
This commit is contained in:
parent
a047de22e4
commit
3f70185051
25
cfddns/backup.sh
Executable file
25
cfddns/backup.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#! /bin/sh
|
||||
|
||||
# you can do something here
|
||||
# this shell scripts will run at the end of build.py scripts
|
||||
|
||||
|
||||
|
||||
mkdir -p history
|
||||
if [ ! -f ./history/version ];then
|
||||
touch ./history/version
|
||||
fi
|
||||
|
||||
version_old=`cat history/version | awk '{print $1}' | sort -rn |sed -n 1p`
|
||||
version_new=`cat config.json.js |grep "version"|cut -d"\"" -f 4`
|
||||
md5_old=`cat history/version | sort -nk1 | awk '{print $1}' |sed -n 1p`
|
||||
md5_new=` md5sum aliddns.tar.gz | awk '{print $1}'`
|
||||
|
||||
if [ -f ./aliddns.tar.gz ];then
|
||||
if [ "$version_old" != "$version_new" ];then
|
||||
mkdir ./history/$version_new/
|
||||
cp ./aliddns.tar.gz ./history/$version_new/
|
||||
echo $version_new $md5_new >> ./history/version
|
||||
fi
|
||||
fi
|
||||
|
32
cfddns/build.sh
Executable file
32
cfddns/build.sh
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
MODULE=cfddns
|
||||
VERSION=1.2
|
||||
TITLE=Cloudflare DDNS
|
||||
DESCRIPTION=Cloudflare解析自动更新IP
|
||||
HOME_URL=Module_cfddns.asp
|
||||
|
||||
# Check and include base
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
if [ "$MODULE" == "" ]; then
|
||||
echo "module not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f "$DIR/$MODULE/$MODULE/install.sh" ]; then
|
||||
echo "install script not found"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# now include build_base.sh
|
||||
. $DIR/../softcenter/build_base.sh
|
||||
|
||||
# change to module directory
|
||||
cd $DIR
|
||||
|
||||
# do something here
|
||||
|
||||
do_build_result
|
||||
|
||||
sh backup.sh $MODULE
|
BIN
cfddns/cfddns.tar.gz
Normal file
BIN
cfddns/cfddns.tar.gz
Normal file
Binary file not shown.
14
cfddns/cfddns/install.sh
Executable file
14
cfddns/cfddns/install.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
cp -r /tmp/cfddns/res/* /jffs/softcenter/res
|
||||
cp -r /tmp/cfddns/scripts/* /jffs/softcenter/scripts
|
||||
cp -r /tmp/cfddns/webs/* /jffs/softcenter/webs
|
||||
|
||||
chmod 644 /jffs/softcenter/webs/Module_cfddns.asp
|
||||
chmod 666 /jffs/softcenter/res/icon-cfddns.png
|
||||
chmod 755 /jffs/softcenter/scripts/cfddns_*
|
||||
|
||||
# add icon into softerware center
|
||||
dbus set softcenter_module_cfddns_install=1
|
||||
dbus set softcenter_module_cfddns_version=1.0.0
|
||||
dbus set softcenter_module_cfddns_description="Cloudflare DDNS"
|
BIN
cfddns/cfddns/res/icon-cfddns.png
Executable file
BIN
cfddns/cfddns/res/icon-cfddns.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
7
cfddns/cfddns/scripts/cfddns_config.sh
Executable file
7
cfddns/cfddns/scripts/cfddns_config.sh
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "`dbus get cfddns_enable`" == "1" ]; then
|
||||
dbus delay cfddns_timer `dbus get cfddns_interval` /jffs/softcenter/scripts/cfddns_update.sh
|
||||
else
|
||||
dbus remove __delay__cfddns_timer
|
||||
fi
|
64
cfddns/cfddns/scripts/cfddns_update.sh
Executable file
64
cfddns/cfddns/scripts/cfddns_update.sh
Executable file
@ -0,0 +1,64 @@
|
||||
#!/bin/sh
|
||||
|
||||
eval `dbus export cfddns_`
|
||||
|
||||
if [ "$cfddns_enable" != "1" ]; then
|
||||
echo "not enable"
|
||||
exit
|
||||
fi
|
||||
|
||||
now=`date '+%Y-%m-%d %H:%M:%S'`
|
||||
ip=`$cfddns_curl 2>&1` || die "$ip"
|
||||
record_response=`curl -kLsX GET "https://api.cloudflare.com/client/v4/zones/$cfddns_zone/dns_records?type=A&name=$cfddns_domain&order=type&direction=desc&match=all" -H "X-Auth-Email: $cfddns_email" -H "X-Auth-Key: $cfddns_key" -H "Content-type: application/json"`
|
||||
cfddns_id=`echo "$record_response" | awk -F"","" '{print $1}' | sed 's/{.*://g'`
|
||||
|
||||
[ "$cfddns_curl" = "" ] && cfddns_curl="curl -s whatismyip.akamai.com"
|
||||
[ "$cfddns_ttl" = "" ] && cfddns_ttl="600"
|
||||
|
||||
die () {
|
||||
echo $1
|
||||
dbus ram cfddns_last_act="$now: failed($1)"
|
||||
}
|
||||
|
||||
urlencode() {
|
||||
# urlencode <string>
|
||||
out=""
|
||||
while read -n1 c; do
|
||||
case $c in
|
||||
[a-zA-Z0-9._-]) out="$out$c" ;;
|
||||
*) out="$out`printf '%%%02X' "'$c"`" ;;
|
||||
esac
|
||||
done
|
||||
echo -n $out
|
||||
}
|
||||
|
||||
enc() {
|
||||
echo -n "$1" | urlencode
|
||||
}
|
||||
|
||||
update_record() {
|
||||
curl -kLsX PUT "https://api.cloudflare.com/client/v4/zones/$cfddns_zone/dns_records/$cfddns_id" \
|
||||
-H "X-Auth-Email: $cfddns_email" \
|
||||
-H "X-Auth-Key: $cfddns_key" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data '{"type":"A","name":"$cfddns_domain","content":"$ip","ttl":"$cfddns_ttl","proxied":false}'
|
||||
}
|
||||
|
||||
if [ "$?" -eq "0" ]; then
|
||||
current_ip=`echo "$record_response" | awk -F"","" '{print $4}' |grep -oE '([0-9]{1,3}\.?){4}'`
|
||||
|
||||
if [ "$ip" = "$current_ip" ]; then
|
||||
echo "skipping"
|
||||
dbus set cfddns_last_act="$now: 跳过更新,路由器IP:($ip),A记录IP:($current_ip)"
|
||||
exit 0
|
||||
else
|
||||
echo "changing"
|
||||
update_record
|
||||
new_ip=`echo "$record_response" | awk -F"","" '{print $4}' |grep -oE '([0-9]{1,3}\.?){4}'`
|
||||
if [ "$new_ip" = "$ip" ]; then
|
||||
dbus set cfddns_last_act="$now: 更新成功,路由器IP:($ip),A记录IP:($new_ip)"
|
||||
else
|
||||
dbus set cfddns_last_act="$now: 更新失败!请检查设置"
|
||||
fi
|
||||
fi
|
||||
fi
|
12
cfddns/cfddns/scripts/uninstall_cfddns.sh
Executable file
12
cfddns/cfddns/scripts/uninstall_cfddns.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
rm /jffs/softcenter/res/icon-cfddns.png > /dev/null 2>&1
|
||||
rm /jffs/softcenter/webs/Module_cfddns.asp > /dev/null 2>&1
|
||||
rm /jffs/softcenter/scripts/cfddns_config.sh > /dev/null 2>&1
|
||||
rm /jffs/softcenter/scripts/cfddns_update.sh > /dev/null 2>&1
|
||||
rm /jffs/softcenter/scripts/uninstall_cfddns.sh > /dev/null 2>&1
|
||||
|
||||
dbus remove __delay__cfddns_timer
|
||||
dbus remove softcenter_module_cfddns_install
|
||||
dbus remove softcenter_module_cfddns_version
|
||||
dbus remove softcenter_module_cfddns_description
|
212
cfddns/cfddns/webs/Module_cfddns.asp
Executable file
212
cfddns/cfddns/webs/Module_cfddns.asp
Executable file
@ -0,0 +1,212 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="-1" />
|
||||
<link rel="shortcut icon" href="images/favicon.png" />
|
||||
<link rel="icon" href="images/favicon.png" />
|
||||
<title>Cloudflare DDNS</title>
|
||||
<link rel="stylesheet" type="text/css" href="index_style.css" />
|
||||
<link rel="stylesheet" type="text/css" href="form_style.css" />
|
||||
<link rel="stylesheet" type="text/css" href="usp_style.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/element.css" />
|
||||
<script type="text/javascript" src="/js/jquery.js"></script>
|
||||
<script src="/state.js"></script>
|
||||
<script src="/help.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="TopBanner"></div>
|
||||
<div id="Loading" class="popup_bg"></div>
|
||||
<table class="content" align="center" cellpadding="0" cellspacing="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td width="17"> </td>
|
||||
<td valign="top" width="202">
|
||||
<div id="mainMenu"></div>
|
||||
<div id="subMenu"></div>
|
||||
</td>
|
||||
<td valign="top">
|
||||
<div id="tabMenu" class="submenuBlock"></div>
|
||||
<!--=====Beginning of Main Content=====-->
|
||||
<table width="98%" border="0" align="left" cellpadding="0" cellspacing="0" style="display: block;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="left" valign="top">
|
||||
<div>
|
||||
<table width="760px" border="0" cellpadding="5" cellspacing="0" bordercolor="#6b8fa3" class="FormTitle" id="FormTitle">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td bgcolor="#4D595D" colspan="3" valign="top">
|
||||
<div> </div>
|
||||
<div style="float:left;" class="formfonttitle" style="padding-top: 12px">Cloudflare DDNS - 设置</div>
|
||||
<div style="float:right; width:15px; height:25px;margin-top:10px"><img id="return_btn" onclick="reload_Soft_Center();" align="right" style="cursor:pointer;position:absolute;margin-left:-30px;margin-top:-25px;" title="返回软件中心" src="/images/backprev.png" onMouseOver="this.src='/images/backprevclick.png'" onMouseOut="this.src='/images/backprev.png'"></img></div>
|
||||
<div style="margin-left:5px;margin-top:10px;margin-bottom:10px"><img src="/images/New_ui/export/line_export.png"></div>
|
||||
<div class="SimpleNote" id="head_illustrate"><i></i><em>Cloudflare DDNS</em>是基于 Cloudflare API 实现的个人 DDNS 工具。<a href='https://github.com/mritd/koolshare-cfddns' target='_blank'><i> <u>点击查看插件详情</u></i></a></div>
|
||||
<table style="margin:20px 0px 0px 0px;" width="100%" border="1" align="center" cellpadding="4" cellspacing="0" bordercolor="#6b8fa3" class="FormTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<td colspan="2">Cloudflare DDNS - 设置面板</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr id="switch_tr">
|
||||
<th> <label>开启 Cloudflare DDNS</label> </th>
|
||||
<td colspan="2">
|
||||
<div class="switch_field" style="display:table-cell">
|
||||
<label for="switch">
|
||||
<input id="switch" class="switch" type="checkbox" style="display: none;" />
|
||||
<div class="switch_container">
|
||||
<div class="switch_bar"></div>
|
||||
<div class="switch_circle transition_style">
|
||||
<div></div>
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
<div id="koolproxy_install_show" style="padding-top:5px;margin-left:80px;margin-top:-30px;float: left;"></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="last_act_tr">
|
||||
<th>上次运行</th>
|
||||
<td> <% dbus_get_def("cfddns_last_act", "--"); %> </td>
|
||||
</tr>
|
||||
<tr id="key_tr">
|
||||
<th>API KEY</th>
|
||||
<td> <input type="password" id="cfddns_key" value="<% dbus_get_def("cfddns_key", ""); %>" class="input_ss_table"></td>
|
||||
</tr>
|
||||
<tr id="email_tr">
|
||||
<th>User Email</th>
|
||||
<td><input type="text" id="cfddns_email" value="<% dbus_get_def("cfddns_email", ""); %>" class="input_ss_table"></td>
|
||||
</tr>
|
||||
<tr id="zone_tr">
|
||||
<th>ZONE</th>
|
||||
<td><input type="password" id="cfddns_zone" value="<% dbus_get_def("cfddns_zone", ""); %>" class="input_ss_table"></td>
|
||||
</tr>
|
||||
<tr id="interval_tr">
|
||||
<th>检查周期</th>
|
||||
<td><input type="text" style="width: 2.5em" id="cfddns_interval" value="<% dbus_get_def("cfddns_interval", "120"); %>" class="input_ss_table">s</td>
|
||||
</tr>
|
||||
<tr id="domain_tr">
|
||||
<th>主域名</th>
|
||||
<td><input type="text" id="cfddns_domain" value="<% dbus_get_def("cfddns_domain", "example.com"); %>" class="input_ss_table"></td>
|
||||
</tr>
|
||||
<tr id="curl_tr">
|
||||
<th title="可自行修改命令行,以获得正确的公网IP。如添加 '--interface vlan2' 以指定多播情况下的端口支持">获得IP命令(?)</th>
|
||||
<td><textarea id="cfddns_curl" class="input_ss_table" style="width: 94%; height: 2.4em"><% dbus_get_def("cfddns_curl", "curl -s whatismyip.akamai.com"); %></textarea></td>
|
||||
</tr>
|
||||
<tr id="ttl_tr">
|
||||
<th title="设置解析TTL,默认10分钟,免费版的范围是120-86400">TTL(?)</th>
|
||||
<td><input id="cfddns_ttl" style="width: 4.5em" class="input_ss_table"value="<% dbus_get_def("cfddns_ttl", "600"); %>">s (1~86400)</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="apply_gen">
|
||||
<input class="button_gen" type="button" value="提交" />
|
||||
</div>
|
||||
<div style="margin-left:5px;margin-top:10px;margin-bottom:10px">
|
||||
<img src="/images/New_ui/export/line_export.png" />
|
||||
</div>
|
||||
<div class="KoolshareBottom" style="margin-top:540px;">
|
||||
论坛技术支持:
|
||||
<a href="http://www.koolshare.cn" target="_blank"> <i><u>www.koolshare.cn</u></i> </a><br/>
|
||||
Github项目:
|
||||
<a href="https://github.com/koolshare/koolshare.github.io/tree/acelan_softcenter_ui" target="_blank"> <i><u>github.com/koolshare</u></i> </a><br />
|
||||
Shell by: <i>kyrios</i> , Web by: <i>kyrios</i>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<!--=====end of Main Content=====-->
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div id="footer"></div>
|
||||
<script>
|
||||
$(function () {
|
||||
show_menu(menu_hook);
|
||||
var enable = "<% dbus_get_def("cfddns_enable", "0"); %>";
|
||||
$('#switch').prop('checked', enable === "1");
|
||||
buildswitch();
|
||||
update_visibility();
|
||||
var posting = false;
|
||||
var inputs = ['key', 'email', 'zone', 'domain', 'interval', 'curl', 'ttl'];
|
||||
$('.button_gen').click(function () {
|
||||
if(posting) return;
|
||||
posting = true; // save
|
||||
var data = {
|
||||
cfddns_enable: $('#switch').prop('checked') | 0,
|
||||
action_mode: ' Refresh ',
|
||||
current_page: 'Module_cfddns.asp',
|
||||
next_page: 'Module_cfddns.asp',
|
||||
action_script: 'cfddns_config.sh'
|
||||
};
|
||||
for(var i = 0; i< inputs.length; i++) {
|
||||
var key = 'cfddns_' + inputs[i];
|
||||
data[key] = $('#'+key).val()
|
||||
}
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'applydb.cgi?p=cfddns_',
|
||||
data: $.param(data)
|
||||
}).then(function () {
|
||||
posting = false;
|
||||
alert('配置保存成功...');
|
||||
}, function () {
|
||||
posting = false;
|
||||
alert('配置保存失败!');
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
function menu_hook(title, tab) {
|
||||
tabtitle[tabtitle.length -1] = new Array("", "Cloudflare DDNS");
|
||||
tablink[tablink.length -1] = new Array("", "Module_cfddns.asp");
|
||||
}
|
||||
|
||||
function reload_Soft_Center(){
|
||||
location.href = "/Main_Soft_center.asp";
|
||||
}
|
||||
|
||||
function buildswitch(){
|
||||
$("#switch").click(
|
||||
function(){
|
||||
update_visibility();
|
||||
});
|
||||
}
|
||||
|
||||
function update_visibility(){
|
||||
if (document.getElementById('switch').checked) {
|
||||
document.getElementById("last_act_tr").style.display = "";
|
||||
document.getElementById("key_tr").style.display = "";
|
||||
document.getElementById("email_tr").style.display = "";
|
||||
document.getElementById("zone_tr").style.display = "";
|
||||
document.getElementById("interval_tr").style.display = "";
|
||||
document.getElementById("domain_tr").style.display = "";
|
||||
document.getElementById("curl_tr").style.display = "";
|
||||
document.getElementById("ttl_tr").style.display = "";
|
||||
|
||||
} else {
|
||||
document.getElementById("last_act_tr").style.display = "none";
|
||||
document.getElementById("key_tr").style.display = "none";
|
||||
document.getElementById("email_tr").style.display = "none";
|
||||
document.getElementById("zone_tr").style.display = "none";
|
||||
document.getElementById("interval_tr").style.display = "none";
|
||||
document.getElementById("domain_tr").style.display = "none";
|
||||
document.getElementById("curl_tr").style.display = "none";
|
||||
document.getElementById("ttl_tr").style.display = "none";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
8
cfddns/config.json.js
Normal file
8
cfddns/config.json.js
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"version":"1.2",
|
||||
"md5":"a5412ac92b26967a619c8c458f839733",
|
||||
"home_url":"Module_cfddns.asp",
|
||||
"title":"",
|
||||
"description":"Cloudflare解析自动更新IP",
|
||||
"build_date":"2019-01-13_22:44:33"
|
||||
}
|
0
cfddns/history/version
Normal file
0
cfddns/history/version
Normal file
2
cfddns/version
Normal file
2
cfddns/version
Normal file
@ -0,0 +1,2 @@
|
||||
1.2
|
||||
a5412ac92b26967a619c8c458f839733
|
@ -10,6 +10,16 @@
|
||||
"title": "网络测速",
|
||||
"version": "0.2.3"
|
||||
},
|
||||
{
|
||||
"build_date": "2019-01-13_22:44:33",
|
||||
"description": "Cloudflare解析自动更新IP",
|
||||
"home_url": "Module_cfddns.asp",
|
||||
"md5": "a5412ac92b26967a619c8c458f839733",
|
||||
"name": "cfddns",
|
||||
"tar_url": "cfddns/cfddns.tar.gz",
|
||||
"title": "",
|
||||
"version": "1.2"
|
||||
},
|
||||
{
|
||||
"build_date": "2019-01-13_21:09:08",
|
||||
"description": "老板,来一斤虚拟内存~",
|
||||
@ -72,7 +82,7 @@
|
||||
}
|
||||
],
|
||||
"home_url": "https://raw.githubusercontent.com/paldier/softcenter/master",
|
||||
"md5": "55442664d9e425f5ce6a2a0375200c4d",
|
||||
"md5": "87f69f0f5f47b7a4a17be3f2ef39ff93",
|
||||
"tar_url": "softcenter/softcenter.tar.gz",
|
||||
"version": "1.1.6"
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"version":"1.1.6",
|
||||
"md5":"55442664d9e425f5ce6a2a0375200c4d"
|
||||
"md5":"87f69f0f5f47b7a4a17be3f2ef39ff93"
|
||||
}
|
||||
|
Binary file not shown.
@ -1,2 +1,2 @@
|
||||
1.1.6
|
||||
55442664d9e425f5ce6a2a0375200c4d
|
||||
87f69f0f5f47b7a4a17be3f2ef39ff93
|
||||
|
Loading…
Reference in New Issue
Block a user