DNS服务支持密钥管理/“域名服务”改为“自建DNS”

This commit is contained in:
GoEdgeLab
2021-07-25 09:44:29 +08:00
parent 12023f6792
commit e21e76e872
22 changed files with 621 additions and 29 deletions

View File

@@ -2,6 +2,7 @@
<menu-item href="/ns">所有域名</menu-item>
<span class="item disabled">|</span>
<menu-item :href="'/ns/domains/domain?domainId=' + domain.id" code="index">详情<span class="grey small">{{domain.name}}</span></menu-item>
<menu-item :href="'/ns/domains/records?domainId=' + domain.id" code="record">记录</menu-item>
<menu-item :href="'/ns/domains/records?domainId=' + domain.id" code="record">记录({{domain.countRecords}})</menu-item>
<menu-item :href="'/ns/domains/keys?domainId=' + domain.id" code="key">密钥({{domain.countKeys}})</menu-item>
<menu-item :href="'/ns/domains/update?domainId=' + domain.id" code="update">修改</menu-item>
</first-menu>

View File

@@ -0,0 +1,40 @@
{$layout "layout_popup"}
<h3>创建密钥</h3>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<input type="hidden" name="domainId" :value="domainId"/>
<table class="ui table definition selectable">
<tr>
<td class="title">密钥名称 *</td>
<td>
<input type="text" name="name" ref="focus"/>
</td>
</tr>
<tr>
<td>算法 *</td>
<td>
<select class="ui dropdown auto-width" name="algo">
<option value="">[选择算法]</option>
<option v-for="algo in algorithms" :value="algo.code">{{algo.name}}</option>
</select>
</td>
</tr>
<tr>
<td>密码 *</td>
<td>
<div style="margin-bottom: 1em">
<radio name="secretType" value="clear" :v-value="'clear'" v-model="secretType">明文密码</radio>
&nbsp; &nbsp;
<radio name="secretType" value="base64" :v-value="'base64'" v-model="secretType">Base64密码</radio>
</div>
<textarea name="secret" maxlength="256" v-model="secret" rows="3"></textarea>
<p class="comment" v-if="secretType == 'clear'">客户端需要将明文转换为BASE64使用。</p>
<div style="margin-top: 1em">
<a href="" @click.prevent="generateSecret">[随机生成]</a>
</div>
</td>
</tr>
</table>
<submit-btn></submit-btn>
</form>

View File

@@ -0,0 +1,20 @@
Tea.context(function () {
this.secretType = "clear"
this.secret = ""
this.$delay(function () {
this.$watch("secretType", function () {
this.secret = ""
})
})
this.generateSecret = function () {
this.$post(".generateSecret")
.params({
secretType: this.secretType
})
.success(function (resp) {
this.secret = resp.data.secret
})
}
})

View File

@@ -0,0 +1,38 @@
{$layout}
{$template "../domain_menu"}
<second-menu>
<menu-item @click.prevent="createKey">[创建密钥]</menu-item>
</second-menu>
<tip-message-box>这里的密钥可以用于TSIG通讯校验。</tip-message-box>
<p class="comment" v-if="keys.length == 0">暂时还没有密钥。</p>
<table class="ui table celled selectable" v-if="keys.length > 0">
<thead>
<tr>
<th class="two wide">密钥名称</th>
<th class="two wide">算法</th>
<th>密码</th>
<th class="two wide">密码类型</th>
<th class="two wide">状态</th>
<th class="two op">操作</th>
</tr>
</thead>
<tr v-for="key in keys">
<td>{{key.name}}</td>
<td>{{key.algoName}}</td>
<td>{{key.secret}}</td>
<td>{{key.secretTypeName}}</td>
<td>
<label-on :v-is-on="key.isOn"></label-on>
</td>
<td>
<a href="" @click.prevent="updateKey(key.id)">修改</a> &nbsp;
<a href="" @click.prevent="deleteKey(key.id)">删除</a>
</td>
</tr>
</table>
<div class="page" v-html="page"></div>

View File

@@ -0,0 +1,31 @@
Tea.context(function () {
this.createKey = function () {
teaweb.popup(Tea.url(".createPopup?domainId=" + this.domain.id), {
height: "24em",
callback: function () {
teaweb.successRefresh("保存成功")
}
})
}
this.updateKey = function (keyId) {
teaweb.popup(Tea.url(".updatePopup?keyId=" + keyId), {
height: "26em",
callback: function () {
teaweb.successRefresh("保存成功")
}
})
}
this.deleteKey = function (keyId) {
teaweb.confirm("确定要删除这个密钥吗?", function () {
this.$post(".delete")
.params({
keyId: keyId
})
.success(function () {
teaweb.successRefresh("删除成功")
})
})
}
})

View File

@@ -0,0 +1,46 @@
{$layout "layout_popup"}
<h3>修改密钥</h3>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<input type="hidden" name="keyId" :value="key.id"/>
<table class="ui table definition selectable">
<tr>
<td class="title">密钥名称 *</td>
<td>
<input type="text" name="name" ref="focus" v-model="key.name"/>
</td>
</tr>
<tr>
<td>算法 *</td>
<td>
<select class="ui dropdown auto-width" name="algo" v-model="key.algo">
<option value="">[选择算法]</option>
<option v-for="algo in algorithms" :value="algo.code">{{algo.name}}</option>
</select>
</td>
</tr>
<tr>
<td>密码 *</td>
<td>
<div style="margin-bottom: 1em">
<radio name="secretType" value="clear" :v-value="'clear'" v-model="secretType">明文密码</radio>
&nbsp; &nbsp;
<radio name="secretType" value="base64" :v-value="'base64'" v-model="secretType">Base64密码</radio>
</div>
<textarea name="secret" maxlength="256" v-model="secret" rows="3"></textarea>
<p class="comment" v-if="secretType == 'clear'">客户端需要将明文转换为BASE64使用。</p>
<div style="margin-top: 1em">
<a href="" @click.prevent="generateSecret">[随机生成]</a>
</div>
</td>
</tr>
<tr>
<td>是否启用</td>
<td>
<checkbox name="isOn" v-model="key.isOn"></checkbox>
</td>
</tr>
</table>
<submit-btn></submit-btn>
</form>

View File

@@ -0,0 +1,20 @@
Tea.context(function () {
this.secretType = this.key.secretType
this.secret = this.key.secret
this.$delay(function () {
this.$watch("secretType", function () {
this.secret = ""
})
})
this.generateSecret = function () {
this.$post(".generateSecret")
.params({
secretType: this.secretType
})
.success(function (resp) {
this.secret = resp.data.secret
})
}
})