实现DNS域名验证

This commit is contained in:
刘祥超
2022-09-10 16:13:31 +08:00
parent 5414b5a8f9
commit 80ffe6c9a3
4 changed files with 24 additions and 9 deletions

View File

@@ -17,7 +17,6 @@ func ValidateDomainFormat(domain string) bool {
if piece == "-" || if piece == "-" ||
strings.HasPrefix(piece, "-") || strings.HasPrefix(piece, "-") ||
strings.HasSuffix(piece, "-") || strings.HasSuffix(piece, "-") ||
//strings.Contains(piece, "--") ||
len(piece) > 63 || len(piece) > 63 ||
!regexp.MustCompile(`^[a-z0-9-]+$`).MatchString(piece) { !regexp.MustCompile(`^[a-z0-9-]+$`).MatchString(piece) {
return false return false

View File

@@ -817,8 +817,8 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
<option value="0">[选择集群]</option> <option value="0">[选择集群]</option>
<option v-for="cluster in clusters" :value="cluster.id">{{cluster.name}}</option> <option v-for="cluster in clusters" :value="cluster.id">{{cluster.name}}</option>
</select> </select>
</div>`}),Vue.component("ns-cluster-combo-box",{props:["v-cluster-id"],data:function(){let t=this;return Tea.action("/ns/clusters/options").post().success(function(e){t.clusters=e.data.clusters}),{clusters:[]}},methods:{change:function(e){null==e?this.$emit("change",0):this.$emit("change",e.value)}},template:`<div v-if="clusters.length > 0" style="min-width: 10.4em"> </div>`}),Vue.component("ns-cluster-combo-box",{props:["v-cluster-id","name"],data:function(){let t=this,e=(Tea.action("/ns/clusters/options").post().success(function(e){t.clusters=e.data.clusters}),"clusterId");return{clusters:[],inputName:e=null!=this.name&&0<this.name.length?this.name:e}},methods:{change:function(e){null==e?this.$emit("change",0):this.$emit("change",e.value)}},template:`<div v-if="clusters.length > 0" style="min-width: 10.4em">
<combo-box title="集群" placeholder="集群名称" :v-items="clusters" name="clusterId" :v-value="vClusterId" @change="change"></combo-box> <combo-box title="集群" placeholder="集群名称" :v-items="clusters" :name="inputName" :v-value="vClusterId" @change="change"></combo-box>
</div>`}),Vue.component("plan-user-selector",{props:["v-user-id"],data:function(){return{}},methods:{change:function(e){this.$emit("change",e)}},template:`<div> </div>`}),Vue.component("plan-user-selector",{props:["v-user-id"],data:function(){return{}},methods:{change:function(e){this.$emit("change",e)}},template:`<div>
<user-selector :v-user-id="vUserId" data-url="/plans/users/options" @change="change"></user-selector> <user-selector :v-user-id="vUserId" data-url="/plans/users/options" @change="change"></user-selector>
</div>`}),Vue.component("plan-price-view",{props:["v-plan"],data:function(){return{plan:this.vPlan}},template:`<div> </div>`}),Vue.component("plan-price-view",{props:["v-plan"],data:function(){return{plan:this.vPlan}},template:`<div>

View File

@@ -2451,7 +2451,7 @@ Vue.component("ns-cluster-selector", {
}) })
Vue.component("ns-cluster-combo-box", { Vue.component("ns-cluster-combo-box", {
props: ["v-cluster-id"], props: ["v-cluster-id", "name"],
data: function () { data: function () {
let that = this let that = this
Tea.action("/ns/clusters/options") Tea.action("/ns/clusters/options")
@@ -2459,8 +2459,16 @@ Vue.component("ns-cluster-combo-box", {
.success(function (resp) { .success(function (resp) {
that.clusters = resp.data.clusters that.clusters = resp.data.clusters
}) })
let inputName = "clusterId"
if (this.name != null && this.name.length > 0) {
inputName = this.name
}
return { return {
clusters: [] clusters: [],
inputName: inputName
} }
}, },
methods: { methods: {
@@ -2473,7 +2481,7 @@ Vue.component("ns-cluster-combo-box", {
} }
}, },
template: `<div v-if="clusters.length > 0" style="min-width: 10.4em"> template: `<div v-if="clusters.length > 0" style="min-width: 10.4em">
<combo-box title="集群" placeholder="集群名称" :v-items="clusters" name="clusterId" :v-value="vClusterId" @change="change"></combo-box> <combo-box title="集群" placeholder="集群名称" :v-items="clusters" :name="inputName" :v-value="vClusterId" @change="change"></combo-box>
</div>` </div>`
}) })

View File

@@ -1,5 +1,5 @@
Vue.component("ns-cluster-combo-box", { Vue.component("ns-cluster-combo-box", {
props: ["v-cluster-id"], props: ["v-cluster-id", "name"],
data: function () { data: function () {
let that = this let that = this
Tea.action("/ns/clusters/options") Tea.action("/ns/clusters/options")
@@ -7,8 +7,16 @@ Vue.component("ns-cluster-combo-box", {
.success(function (resp) { .success(function (resp) {
that.clusters = resp.data.clusters that.clusters = resp.data.clusters
}) })
let inputName = "clusterId"
if (this.name != null && this.name.length > 0) {
inputName = this.name
}
return { return {
clusters: [] clusters: [],
inputName: inputName
} }
}, },
methods: { methods: {
@@ -21,6 +29,6 @@ Vue.component("ns-cluster-combo-box", {
} }
}, },
template: `<div v-if="clusters.length > 0" style="min-width: 10.4em"> template: `<div v-if="clusters.length > 0" style="min-width: 10.4em">
<combo-box title="集群" placeholder="集群名称" :v-items="clusters" name="clusterId" :v-value="vClusterId" @change="change"></combo-box> <combo-box title="集群" placeholder="集群名称" :v-items="clusters" :name="inputName" :v-value="vClusterId" @change="change"></combo-box>
</div>` </div>`
}) })