mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-05 21:20:06 +00:00
ddns: store configuation in database (#435)
* ddns: store configuation in database Co-authored-by: nap0o <144927971+nap0o@users.noreply.github.com> * feat: split domain with soa lookup * switch to libdns interface * ddns: add unit test * ddns: skip TestSplitDomainSOA on ci network is not steady * fix error handling * fix error handling --------- Co-authored-by: nap0o <144927971+nap0o@users.noreply.github.com>
This commit is contained in:
2
resource/template/common/footer.html
vendored
2
resource/template/common/footer.html
vendored
@@ -10,7 +10,7 @@
|
||||
<script src="https://unpkg.com/semantic-ui@2.4.0/dist/semantic.min.js"></script>
|
||||
<script src="/static/semantic-ui-alerts.min.js"></script>
|
||||
<script src="https://unpkg.com/vue@2.6.14/dist/vue.min.js"></script>
|
||||
<script src="/static/main.js?v2024927"></script>
|
||||
<script src="/static/main.js?v20241011"></script>
|
||||
<script>
|
||||
(function () {
|
||||
updateLang({{.LANG }});
|
||||
|
||||
1
resource/template/common/menu.html
vendored
1
resource/template/common/menu.html
vendored
@@ -9,6 +9,7 @@
|
||||
<a class='item{{if eq .MatchedPath "/monitor"}} active{{end}}' href="/monitor"><i class="rss icon"></i>{{tr "Services"}}</a>
|
||||
<a class='item{{if eq .MatchedPath "/cron"}} active{{end}}' href="/cron"><i class="clock icon"></i>{{tr "Task"}}</a>
|
||||
<a class='item{{if eq .MatchedPath "/notification"}} active{{end}}' href="/notification"><i class="bell icon"></i>{{tr "Notification"}}</a>
|
||||
<a class='item{{if eq .MatchedPath "/ddns"}} active{{end}}' href="/ddns"><i class="globe icon"></i>{{tr "DDNS"}}</a>
|
||||
<a class='item{{if eq .MatchedPath "/nat"}} active{{end}}' href="/nat"><i class="exchange icon"></i>{{tr "NAT"}}</a>
|
||||
<a class='item{{if eq .MatchedPath "/setting"}} active{{end}}' href="/setting">
|
||||
<i class="settings icon"></i>{{tr "Settings"}}
|
||||
|
||||
79
resource/template/component/ddns.html
vendored
Normal file
79
resource/template/component/ddns.html
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
{{define "component/ddns"}}
|
||||
<div class="ui tiny ddns modal transition hidden">
|
||||
<div class="header">Add</div>
|
||||
<div class="content">
|
||||
<form id="ddnsForm" class="ui form">
|
||||
<input type="hidden" name="ID">
|
||||
<div class="field">
|
||||
<label>{{tr "Name"}}</label>
|
||||
<input type="text" name="Name">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>{{tr "DDNSProvider"}}</label>
|
||||
<select name="Provider" class="ui fluid dropdown" id="providerSelect" onchange="toggleFields()">
|
||||
{{ range $provider := .ProviderList }}
|
||||
<option value="{{ $provider.ID }}">
|
||||
{{ $provider.Name }}
|
||||
</option>
|
||||
{{ end }}
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>{{tr "DDNSDomains"}}</label>
|
||||
<input type="text" name="DomainsRaw" placeholder="www.example.com">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>{{tr "DDNSAccessID"}}</label>
|
||||
<input type="text" name="AccessID" placeholder="{{tr "DDNSTokenID"}}">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>{{tr "DDNSAccessSecret"}}</label>
|
||||
<input type="text" name="AccessSecret" placeholder="{{tr "DDNSTokenSecret"}}">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>{{tr "MaxRetries"}}</label>
|
||||
<input type="number" name="MaxRetries" placeholder="3">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>{{tr "WebhookURL"}}</label>
|
||||
<input type="text" name="WebhookURL" placeholder="https://ddns.example.com/?record=#record#">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>{{tr "WebhookMethod"}}</label>
|
||||
<select name="WebhookMethod" class="ui fluid dropdown">
|
||||
<option value="1">GET</option>
|
||||
<option value="2">POST</option>
|
||||
<option value="3">PATCH</option>
|
||||
<option value="4">DELETE</option>
|
||||
<option value="5">PUT</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>{{tr "WebhookHeaders"}}</label>
|
||||
<textarea name="WebhookHeaders" placeholder='{"User-Agent":"Nezha-Agent"}'></textarea>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>{{tr "WebhookRequestBody"}}</label>
|
||||
<textarea name="WebhookRequestBody" placeholder='{ "ip": #ip#, "domain": "#domain#" }'></textarea>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui enableipv4 checkbox">
|
||||
<input name="EnableIPv4" type="checkbox" tabindex="0" class="hidden">
|
||||
<label>{{tr "EnableIPv4"}}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui enableipv6 checkbox">
|
||||
<input name="EnableIPv6" type="checkbox" tabindex="0" class="hidden">
|
||||
<label>{{tr "EnableIPv6"}}</label>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<div class="ui negative button">{{tr "Cancel"}}</div>
|
||||
<button class="ui positive nezha-primary-btn right labeled icon button">{{tr "Confirm"}}<i class="checkmark icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
31
resource/template/component/server.html
vendored
31
resource/template/component/server.html
vendored
@@ -21,37 +21,26 @@
|
||||
<input type="text" name="secret">
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui hideforguest checkbox">
|
||||
<input name="HideForGuest" type="checkbox" tabindex="0" class="hidden" />
|
||||
<label>{{tr "HideForGuest"}}</label>
|
||||
<label>{{tr "DDNSProfiles"}}</label>
|
||||
<div class="ui fluid multiple ddns search selection dropdown">
|
||||
<input type="hidden" name="DDNSProfilesRaw">
|
||||
<i class="dropdown icon ddnsProfiles"></i>
|
||||
<div class="default text">{{tr "EnterIdAndNameToSearch"}}</div>
|
||||
<div class="menu"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui enableddns checkbox">
|
||||
<input name="EnableDDNS" type="checkbox" tabindex="0" />
|
||||
<input name="EnableDDNS" type="checkbox" tabindex="0" class="hidden" />
|
||||
<label>{{tr "EnableDDNS"}}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui enableipv4 checkbox">
|
||||
<input name="EnableIPv4" type="checkbox" tabindex="0" />
|
||||
<label>{{tr "EnableIPv4"}}</label>
|
||||
<div class="ui hideforguest checkbox">
|
||||
<input name="HideForGuest" type="checkbox" tabindex="0" class="hidden" />
|
||||
<label>{{tr "HideForGuest"}}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui enableipv6 checkbox">
|
||||
<input name="EnableIpv6" type="checkbox" tabindex="0" />
|
||||
<label>{{tr "EnableIpv6"}}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>{{tr "DDNSDomain"}}</label>
|
||||
<input type="text" name="DDNSDomain" placeholder="{{tr "DDNSDomain"}}">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>{{tr "DDNSProfile"}}</label>
|
||||
<input type="text" name="DDNSProfile" placeholder="{{tr "DDNSProfile"}}">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>{{tr "Note"}}</label>
|
||||
<textarea name="Note"></textarea>
|
||||
|
||||
58
resource/template/dashboard-default/ddns.html
vendored
Normal file
58
resource/template/dashboard-default/ddns.html
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
{{define "dashboard-default/ddns"}}
|
||||
{{template "common/header" .}}
|
||||
{{template "common/menu" .}}
|
||||
<div class="nb-container">
|
||||
<div class="ui container">
|
||||
<div class="ui grid">
|
||||
<div class="right floated right aligned twelve wide column">
|
||||
<button class="ui right labeled nezha-primary-btn icon button" onclick="addOrEditDDNS()"><i
|
||||
class="add icon"></i> {{tr "AddDDNSProfile"}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<table class="ui basic table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>{{tr "Name"}}</th>
|
||||
<th>{{tr "EnableIPv4"}}</th>
|
||||
<th>{{tr "EnableIPv6"}}</th>
|
||||
<th>{{tr "DDNSProvider"}}</th>
|
||||
<th>{{tr "DDNSDomain"}}</th>
|
||||
<th>{{tr "MaxRetries"}}</th>
|
||||
<th>{{tr "Administration"}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range $item := .DDNS}}
|
||||
<tr>
|
||||
<td>{{$item.ID}}</td>
|
||||
<td>{{$item.Name}}</td>
|
||||
<td>{{$item.EnableIPv4}}</td>
|
||||
<td>{{$item.EnableIPv6}}</td>
|
||||
<td>{{index $.ProviderMap $item.Provider}}</td>
|
||||
<td>{{$item.DomainsRaw}}</td>
|
||||
<td>{{$item.MaxRetries}}</td>
|
||||
<td>
|
||||
<div class="ui mini icon buttons">
|
||||
<button class="ui button" onclick="addOrEditDDNS({{$item}})">
|
||||
<i class="edit icon"></i>
|
||||
</button>
|
||||
<button class="ui button"
|
||||
onclick="showConfirm('确定删除DDNS配置?','确认删除',deleteRequest,'/api/ddns/'+{{$item.ID}})">
|
||||
<i class="trash alternate outline icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{{template "component/ddns" .}}
|
||||
{{template "common/footer" .}}
|
||||
<script>
|
||||
$('.checkbox').checkbox()
|
||||
</script>
|
||||
{{end}}
|
||||
@@ -28,8 +28,8 @@
|
||||
<th>{{tr "ServerGroup"}}</th>
|
||||
<th>IP</th>
|
||||
<th>{{tr "VersionNumber"}}</th>
|
||||
<th>{{tr "HideForGuest"}}</th>
|
||||
<th>{{tr "EnableDDNS"}}</th>
|
||||
<th>{{tr "HideForGuest"}}</th>
|
||||
<th>{{tr "Secret"}}</th>
|
||||
<th>{{tr "OneKeyInstall"}}</th>
|
||||
<th>{{tr "Note"}}</th>
|
||||
@@ -46,8 +46,8 @@
|
||||
<td>{{$server.Tag}}</td>
|
||||
<td>{{$server.Host.IP}}</td>
|
||||
<td>{{$server.Host.Version}}</td>
|
||||
<td>{{$server.HideForGuest}}</td>
|
||||
<td>{{$server.EnableDDNS}}</td>
|
||||
<td>{{$server.HideForGuest}}</td>
|
||||
<td>
|
||||
<button class="ui icon green mini button" data-clipboard-text="{{$server.Secret}}" data-tooltip="{{tr "ClickToCopy"}}">
|
||||
<i class="copy icon"></i>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/semantic-ui/2.4.1/semantic.min.js"></script>
|
||||
<script src="/static/semantic-ui-alerts.min.js"></script>
|
||||
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/vue/2.6.14/vue.min.js"></script>
|
||||
<script src="/static/main.js?v20240330"></script>
|
||||
<script src="/static/main.js?v20241011"></script>
|
||||
<script src="/static/theme-default/js/mixin.js?v20240302"></script>
|
||||
<script>
|
||||
(function () {
|
||||
|
||||
Reference in New Issue
Block a user