mirror of
https://github.com/jeessy2/ddns-go.git
synced 2025-10-20 15:33:46 +08:00
* 增加 Makefile 优化编译脚本,并添加相应的说明 * 清除不需要的文件 * 将 binddata 加入编译脚本中 * 将第三方文件纳入本地 * update documents and some tiny modify * 增加 配置文件,统一格式 * use bootstrap.min.css * fix: indent Co-authored-by: 明城 <mingcheng@users.noreply.github.com> Co-authored-by: jeessy2 <454207171@qq.com>
403 lines
17 KiB
HTML
Executable File
403 lines
17 KiB
HTML
Executable File
<html lang="zh">
|
||
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<meta name="author" content="jie">
|
||
<title>DDNS-GO</title>
|
||
<link rel="stylesheet" href="/static/bootstrap.min.css">
|
||
<script src="/static/jquery-3.5.1.min.js"></script>
|
||
<link rel="stylesheet" href="/static/common.css">
|
||
</head>
|
||
|
||
<body>
|
||
<header>
|
||
<div class="navbar navbar-dark bg-dark shadow-sm">
|
||
<div class="container d-flex justify-content-between">
|
||
<a target="blank" href="https://github.com/jeessy2/ddns-go" class="navbar-brand d-flex align-items-center">
|
||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="none" stroke="currentColor"
|
||
stroke-linecap="round" stroke-linejoin="round" stroke-width="2" aria-hidden="true" class="mr-2"
|
||
viewBox="0 0 24 24" focusable="false">
|
||
<path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z" />
|
||
<circle cx="12" cy="13" r="4" />
|
||
</svg>
|
||
<strong>DDNS-GO</strong>
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</header>
|
||
|
||
<main role="main" style="margin-top: 15px; overflow: hidden;">
|
||
<div class="row">
|
||
<div class="col-md-6 offset-md-3">
|
||
<form>
|
||
|
||
<button class="btn btn-primary submit_btn" style="margin-bottom: 15px;">Save</button>
|
||
|
||
<div class="alert alert-success" style="display: none;">
|
||
<strong id="resultMsg">保存成功</strong>
|
||
</div>
|
||
|
||
<div class="portlet">
|
||
<h5 class="portlet__head">DNS服务商</h5>
|
||
<div class="portlet__body">
|
||
|
||
<div class="form-group row">
|
||
<label class="col-sm-2 col-form-label"></label>
|
||
<div class="col-sm-10">
|
||
<div class="form-check form-check-inline col-form-label">
|
||
<input class="form-check-input" type="radio" name="DnsName" id="alidns" value="alidns" onclick="alidnsCheckedFun()" {{if eq $.DNS.Name "alidns"}}checked{{end}}>
|
||
<label class="form-check-label" for="alidns">
|
||
Alidns(阿里云)
|
||
</label>
|
||
</div>
|
||
<div class="form-check form-check-inline col-form-label">
|
||
<input class="form-check-input" type="radio" name="DnsName" id="dnspod" value="dnspod" onclick="dnspodCheckedFun()" {{if eq $.DNS.Name "dnspod"}}checked{{end}}>
|
||
<label class="form-check-label" for="dnspod">
|
||
Dnspod(腾讯云)
|
||
</label>
|
||
</div>
|
||
<div class="form-check form-check-inline col-form-label">
|
||
<input class="form-check-input" type="radio" name="DnsName" id="cloudflare" value="cloudflare" onclick="cloudflareCheckedFun()" {{if eq $.DNS.Name "cloudflare"}}checked{{end}}>
|
||
<label class="form-check-label" for="cloudflare">
|
||
Cloudflare
|
||
</label>
|
||
</div>
|
||
<div class="form-check form-check-inline col-form-label">
|
||
<input class="form-check-input" type="radio" name="DnsName" id="huaweicloud" value="huaweicloud" onclick="huaweicloudCheckedFun()" {{if eq $.DNS.Name "huaweicloud"}}checked{{end}}>
|
||
<label class="form-check-label" for="huaweicloud">
|
||
华为云
|
||
</label>
|
||
</div>
|
||
<small id="dns_help" class="form-text text-muted"></small>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group row">
|
||
<label for="DnsID" id="dnsIdLabel" class="col-sm-2 col-form-label">ID</label>
|
||
<div class="col-sm-10">
|
||
<input class="form-control" name="DnsID" id="DnsID" value="{{.DNS.ID}}">
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group row">
|
||
<label for="DnsSecret" id="dnsSecretLabel" class="col-sm-2 col-form-label">Secret</label>
|
||
<div class="col-sm-10">
|
||
<input class="form-control" name="DnsSecret" id="DnsSecret" value="{{.DNS.Secret}}">
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="portlet">
|
||
<h5 class="portlet__head">IPV4</h5>
|
||
<div class="portlet__body">
|
||
|
||
<div class="form-group row">
|
||
<label for="ipv4_enable" class="col-sm-2">是否启用</label>
|
||
<div class="col-sm-10">
|
||
<input type="checkbox" class="form-check-inline" style="margin-top: 5px;" id="ipv4_enable" name="Ipv4Enable" {{if eq $.Ipv4.Enable true}}checked{{end}}>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group row">
|
||
<label for="ipv4_url" class="col-sm-2 col-form-label">获取IP方式</label>
|
||
<div class="col-sm-10">
|
||
<div class="form-check form-check-inline">
|
||
<input class="form-check-input" type="radio" name="Ipv4GetType" id="urlRadioIpv4" value="url" {{if ne .Ipv4.GetType "netInterface"}}checked{{end}} onclick="urlClick('ipv4')">
|
||
<label class="form-check-label" for="urlRadioIpv4">通过接口获取</label>
|
||
</div>
|
||
<div class="form-check form-check-inline">
|
||
<input class="form-check-input" type="radio" name="Ipv4GetType" id="netInterfaceRadioIpv4" value="netInterface" {{if eq .Ipv4.GetType "netInterface"}}checked{{end}} onclick="netInterfaceClick('ipv4')">
|
||
<label class="form-check-label" for="netInterfaceRadioIpv4">通过网卡获取</label>
|
||
</div>
|
||
<input type="url" class="form-control" name="Ipv4Url" id="ipv4_url" aria-describedby="ipv4_url_help" value="{{.Ipv4.URL}}">
|
||
<select class="form-control" id="ipv4_netInterface_select" name="Ipv4NetInterface"></select>
|
||
<small id="ipv4_url_help" class="form-text text-muted"></small>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group row">
|
||
<label for="ipv4_domains" class="col-sm-2 col-form-label">Domains</label>
|
||
<div class="col-sm-10">
|
||
<textarea class="form-control" id="ipv4_domains" name="Ipv4Domains" rows="3" aria-describedby="ipv4_domains_help">
|
||
{{- range $i, $v := .Ipv4.Domains}}
|
||
{{$v}}
|
||
{{- end -}}
|
||
</textarea>
|
||
<small id="ipv4_domains_help" class="form-text text-muted">一行一个域名</small>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="portlet">
|
||
<h5 class="portlet__head">IPV6</h5>
|
||
<div class="portlet__body">
|
||
|
||
<div class="form-group row">
|
||
<label for="ipv6_enable" class="col-sm-2">是否启用</label>
|
||
<div class="col-sm-10">
|
||
<input type="checkbox" class="form-check-inline" style="margin-top: 5px;" id="ipv6_enable" name="Ipv6Enable" {{if eq $.Ipv6.Enable true}}checked{{end}}>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group row">
|
||
<label for="ipv6_url" class="col-sm-2 col-form-label">获取IP方式</label>
|
||
<div class="col-sm-10">
|
||
<div class="form-check form-check-inline">
|
||
<input class="form-check-input" type="radio" name="Ipv6GetType" id="urlRadioIpv6" value="url" {{if ne .Ipv6.GetType "netInterface"}}checked{{end}} onclick="urlClick('ipv6')">
|
||
<label class="form-check-label" for="urlRadioIpv6">通过接口获取</label>
|
||
</div>
|
||
<div class="form-check form-check-inline">
|
||
<input class="form-check-input" type="radio" name="Ipv6GetType" id="netInterfaceRadioIpv6" value="netInterface" {{if eq .Ipv6.GetType "netInterface"}}checked{{end}} onclick="netInterfaceClick('ipv6')">
|
||
<label class="form-check-label" for="netInterfaceRadioIpv6">通过网卡获取</label>
|
||
</div>
|
||
<input type="url" class="form-control" id="ipv6_url" name="Ipv6Url" aria-describedby="ipv6_url_help" value="{{.Ipv6.URL}}">
|
||
<select class="form-control" id="ipv6_netInterface_select" name="Ipv6NetInterface"></select>
|
||
<small id="ipv6_url_help" class="form-text text-muted"></small>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group row">
|
||
<label for="ipv6_domains" class="col-sm-2 col-form-label">Domains</label>
|
||
<div class="col-sm-10">
|
||
<textarea class="form-control" id="ipv6_domains" name="Ipv6Domains" rows="3" aria-describedby="ipv6_domains_help">
|
||
{{- range $i, $v := .Ipv6.Domains}}
|
||
{{$v}}
|
||
{{- end -}}
|
||
</textarea>
|
||
<small id="ipv6_domains_help" class="form-text text-muted">一行一个域名</small>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="portlet">
|
||
<h5 class="portlet__head">其它配置</h5>
|
||
<div class="portlet__body">
|
||
|
||
<div class="form-group row">
|
||
<label for="Username" class="col-sm-2 col-form-label">登录用户名</label>
|
||
<div class="col-sm-10">
|
||
<input class="form-control" name="Username" id="Username" value="{{.Username}}" aria-describedby="Username_help">
|
||
<small id="Username_help" class="form-text text-muted">为保护你的信息安全, 建议输入</small>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group row">
|
||
<label for="Password" class="col-sm-2 col-form-label">登录密码</label>
|
||
<div class="col-sm-10">
|
||
<input class="form-control" type="password" name="Password" id="Password" value="{{.Password}}" aria-describedby="password_help">
|
||
<small id="password_help" class="form-text text-muted">为保护你的信息安全, 建议输入</small>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="portlet">
|
||
<h5 class="portlet__head">Webhook</h5>
|
||
<div class="portlet__body">
|
||
|
||
<div class="form-group row">
|
||
<label for="WebhookURL" class="col-sm-2 col-form-label">URL</label>
|
||
<div class="col-sm-10">
|
||
<input class="form-control" name="WebhookURL" id="WebhookURL" value="{{.WebhookURL}}" aria-describedby="WebhookURL_help">
|
||
<small id="WebhookURL_help" class="form-text text-muted">
|
||
<a target="blank" href="https://github.com/jeessy2/ddns-go#webhook">点击参考官方Webhook说明</a><br/>
|
||
支持的变量#{ipv4Addr}, #{ipv4Result}, #{ipv4Domains}, #{ipv6Addr}, #{ipv6Result}, #{ipv6Domains}
|
||
</small>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group row">
|
||
<label for="WebhookRequestBody" class="col-sm-2 col-form-label">RequestBody</label>
|
||
<div class="col-sm-10">
|
||
<textarea class="form-control" id="WebhookRequestBody" name="WebhookRequestBody" rows="3" aria-describedby="WebhookRequestBody_help">
|
||
{{- .WebhookRequestBody -}}
|
||
</textarea>
|
||
<small id="WebhookRequestBody_help" class="form-text text-muted">
|
||
RequestBody为空GET请求,不为空POST请求。支持的变量同上
|
||
</small>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<button class="btn btn-primary submit_btn" style="margin-bottom: 15px;">Save</button>
|
||
|
||
</form>
|
||
</div>
|
||
<div class="col-md-3">
|
||
<p class="font-weight-light text-break" style="margin-top: 115px;font-size: 13px;" id="logs"></p>
|
||
</div>
|
||
</div>
|
||
</main>
|
||
|
||
<script>
|
||
$(function(){
|
||
$(".submit_btn").on('click',function(e) {
|
||
e.preventDefault();
|
||
$('body').animate({ scrollTop: 0 }, 300);
|
||
$.ajax({
|
||
method: "POST",
|
||
url: "/save",
|
||
data: $('form').serialize(),
|
||
success: function (result) {
|
||
$('.alert').css("display", "block");
|
||
if (result !== "ok") {
|
||
$('.alert').addClass("alert-danger")
|
||
$('#resultMsg').html(result)
|
||
} else {
|
||
// ok
|
||
setTimeout(function(){
|
||
$('.alert').css("display", "none");
|
||
}, 3000)
|
||
}
|
||
},
|
||
error: function(jqXHR) {
|
||
alert(jqXHR.statusText);
|
||
}
|
||
})
|
||
})
|
||
|
||
})
|
||
|
||
var beforeDnsID=""
|
||
|
||
function alidnsCheckedFun() {
|
||
document.getElementById("DnsID").disabled= false
|
||
if (beforeDnsID)
|
||
document.getElementById("DnsID").value= beforeDnsID
|
||
|
||
document.getElementById("dnsIdLabel").innerHTML = "AccessKey ID"
|
||
document.getElementById("dnsSecretLabel").innerHTML = "AccessKey Secret"
|
||
document.getElementById("dns_help").innerHTML = "<a target='_blank' href='https://ram.console.aliyun.com/manage/ak?spm=5176.12818093.nav-right.dak.488716d0mHaMgg'>创建 AccessKey</a>"
|
||
}
|
||
|
||
function dnspodCheckedFun() {
|
||
document.getElementById("DnsID").disabled= false
|
||
if (beforeDnsID)
|
||
document.getElementById("DnsID").value= beforeDnsID
|
||
|
||
document.getElementById("dnsIdLabel").innerHTML = "ID"
|
||
document.getElementById("dnsSecretLabel").innerHTML = "Token"
|
||
document.getElementById("dns_help").innerHTML = "<a target='_blank' href='https://console.dnspod.cn/account/token'>创建密钥</a>"
|
||
}
|
||
|
||
function cloudflareCheckedFun() {
|
||
document.getElementById("dnsIdLabel").innerHTML = ""
|
||
beforeDnsID = document.getElementById("DnsID").value
|
||
document.getElementById("DnsID").disabled= true
|
||
document.getElementById("DnsID").value= ""
|
||
document.getElementById("dnsSecretLabel").innerHTML = "Token"
|
||
document.getElementById("dns_help").innerHTML = "<a target='_blank' href='https://dash.cloudflare.com/profile/api-tokens'>创建令牌->编辑区域 DNS(使用模板)</a>"
|
||
}
|
||
|
||
function huaweicloudCheckedFun() {
|
||
document.getElementById("DnsID").disabled= false
|
||
if (beforeDnsID)
|
||
document.getElementById("DnsID").value= beforeDnsID
|
||
|
||
document.getElementById("dnsIdLabel").innerHTML = "Access Key Id"
|
||
document.getElementById("dnsSecretLabel").innerHTML = "Secret Access Key"
|
||
document.getElementById("dns_help").innerHTML = "<a target='_blank' href='https://console.huaweicloud.com/iam/?locale=zh-cn#/mine/accessKey'>新增访问密钥</a>"
|
||
}
|
||
|
||
var dnsName = '{{$.DNS.Name}}'
|
||
|
||
switch(dnsName){
|
||
case "dnspod": {
|
||
dnspodCheckedFun()
|
||
break;
|
||
}
|
||
case "cloudflare": {
|
||
cloudflareCheckedFun()
|
||
break;
|
||
}
|
||
case "huaweicloud": {
|
||
huaweicloudCheckedFun()
|
||
break;
|
||
}
|
||
default: {
|
||
alidnsCheckedFun()
|
||
break;
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<script>
|
||
function getLogs() {
|
||
$.get("/logs", function(result){
|
||
$("#logs").html(result)
|
||
})
|
||
}
|
||
getLogs()
|
||
setInterval(getLogs, 5 * 1000)
|
||
</script>
|
||
|
||
<script>
|
||
var ipv4GetType = '{{$.Ipv4.GetType}}'
|
||
var ipv6GetType = '{{$.Ipv6.GetType}}'
|
||
if (ipv4GetType === "netInterface") {
|
||
netInterfaceClick("ipv4")
|
||
} else {
|
||
urlClick("ipv4")
|
||
}
|
||
|
||
if (ipv6GetType === "netInterface") {
|
||
netInterfaceClick("ipv6")
|
||
} else {
|
||
urlClick("ipv6")
|
||
}
|
||
|
||
// 点击接口获取
|
||
function urlClick(label) {
|
||
$("#"+label+"_netInterface_select").css("display", "none")
|
||
$("#"+label+"_url").css("display", "block")
|
||
|
||
if (label === "ipv4") {
|
||
$("#ipv4_url_help").html("填写的URL需返回公网IPV4地址。如:https://api-ipv4.ip.sb/ip、https://myip.ipip.net、https://ddns.oray.com/checkip")
|
||
} else {
|
||
$("#ipv6_url_help").html("填写的URL需返回公网IPV6地址。如:https://api-ipv6.ip.sb/ip、https://v6.myip.la/json、https://speed.neu6.edu.cn/getIP.php")
|
||
}
|
||
}
|
||
|
||
// 点击网卡获取
|
||
function netInterfaceClick(label) {
|
||
$("#"+label+"_url").css("display", "none")
|
||
$("#"+label+"_netInterface_select").css("display", "block")
|
||
if (label === "ipv4") {
|
||
$("#ipv4_url_help").html("通过网卡获取IP, 建议在多宽带的路由器中使用")
|
||
} else {
|
||
$("#ipv6_url_help").html("通过网卡获取IP, 默认使用第一个IPV6地址(一般为非临时的IPV6)")
|
||
}
|
||
|
||
$.get("/"+label+"NetInterface", function(result) {
|
||
$("#"+label+"_netInterface_select").empty()
|
||
if(result) {
|
||
var resultJson = JSON.parse(result)
|
||
for (var i=0; i<resultJson.length; i++) {
|
||
$("#"+label+"_netInterface_select").append(
|
||
`<option value='${resultJson[i].Name}'>
|
||
${resultJson[i].Name}(${resultJson[i].Address[0]})
|
||
</option>`
|
||
);
|
||
}
|
||
// 选中
|
||
if ("{{$.Ipv4.NetInterface}}" !== "") {
|
||
$("#"+label+"_netInterface_select").val("{{$.Ipv4.NetInterface}}")
|
||
}
|
||
} else {
|
||
$("#"+label+"_url_help").html("<span style='color: red'>没有找到可用的网卡</span>")
|
||
}
|
||
})
|
||
}
|
||
</script>
|
||
</html> |