Skip to content

Commit

Permalink
Fix DNS lua records
Browse files Browse the repository at this point in the history
  • Loading branch information
BitK committed Nov 3, 2021
1 parent 63ca8d6 commit dd56fbd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion dockers/manager/back/app/api/powerdns.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,15 @@ async def create_rule(self, zone_name, name, type, ttl, records):
return await self.rule_replace(zone["id"], name, type, ttl, records)

async def update_rule(self, nodeId, ttl, records):
from app.dns.rules import escape_lua
zone, name, type = validate_node_id(nodeId, "DNS_RULE")

if type == "LUA":
old_rule = await self.get_rule(zone, name, type)
real_type = old_rule["records"][0]["content"].split(" ")[0]
record = records[0]
escaped_content = escape_lua(record["content"])
formated = f'A "{escaped_content}"'
formated = f'{real_type} "{escaped_content}"'
records = [{"content": formated, "enabled": record["enabled"]}]
type = "LUA"
return await self.rule_replace(zone, name, type, ttl, records)
Expand Down
3 changes: 2 additions & 1 deletion dockers/manager/front/src/components/DNS/Rule/Create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
label="TTL"
/>
</div>
<lua-editor v-if="isLua" v-model="form.records[0].content" />
<lua-editor v-if="isLua" ref="records" v-model="form.records[0].content" />
<component
:is="formChildren.records"
v-else
Expand Down Expand Up @@ -159,6 +159,7 @@ export default {
return validators.every(x => x);
},
submit(done) {
console.log(this.form)
const input = {
...this.form,
records: this.form.records.map(r => ({ content: r.content }))
Expand Down
4 changes: 4 additions & 0 deletions dockers/manager/front/src/components/DNS/Rule/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
{{ value }}
<q-badge v-if="row.isLua" rounded label="LUA" class="q-ml-sm" />
</template>
<template #body-cell-records="{row, value}">
<pre v-if="row.isLua">{{ value }}</pre>
<span v-else>{{ value }}</span>
</template>
<template #body-cell-enabled="{row, value}">
<q-toggle
:value="value"
Expand Down

0 comments on commit dd56fbd

Please sign in to comment.