Skip to content

Commit 566f7ce

Browse files
committed
gw: Config DNS ttl and max wait in UI
1 parent 2e34259 commit 566f7ce

1 file changed

Lines changed: 35 additions & 7 deletions

File tree

gateway/templates/dashboard.html

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,14 @@ <h3>Add DNS Credential</h3>
610610
<label>Cloudflare API URL (optional)</label>
611611
<input type="text" id="dns-cred-api-url" placeholder="https://api.cloudflare.com/client/v4 (default)">
612612
</div>
613+
<div class="modal-field">
614+
<label>DNS TXT TTL (seconds, optional)</label>
615+
<input type="number" id="dns-cred-ttl" placeholder="e.g. 60 (default from config)">
616+
</div>
617+
<div class="modal-field">
618+
<label>Max DNS Wait (seconds, optional)</label>
619+
<input type="number" id="dns-cred-max-wait" placeholder="e.g. 300 (default from config)">
620+
</div>
613621
<div class="modal-field">
614622
<label>
615623
<input type="checkbox" id="dns-cred-default"> Set as default
@@ -643,6 +651,14 @@ <h3>Edit DNS Credential</h3>
643651
<label>Cloudflare API URL (optional)</label>
644652
<input type="text" id="edit-dns-cred-api-url" placeholder="https://api.cloudflare.com/client/v4 (default)">
645653
</div>
654+
<div class="modal-field">
655+
<label>DNS TXT TTL (seconds, optional)</label>
656+
<input type="number" id="edit-dns-cred-ttl" placeholder="e.g. 60 (default from config)">
657+
</div>
658+
<div class="modal-field">
659+
<label>Max DNS Wait (seconds, optional)</label>
660+
<input type="number" id="edit-dns-cred-max-wait" placeholder="e.g. 300 (default from config)">
661+
</div>
646662
<div class="modal-actions">
647663
<button class="action-btn secondary" onclick="hideModal('edit-dns-cred-modal')">Cancel</button>
648664
<button class="action-btn primary" onclick="updateDnsCredential()">Update</button>
@@ -982,6 +998,8 @@ <h3>Add ZT-Domain</h3>
982998
document.getElementById('edit-dns-cred-provider').value = cred.provider_type;
983999
document.getElementById('edit-dns-cred-token').value = '';
9841000
document.getElementById('edit-dns-cred-api-url').value = cred.cf_api_url || '';
1001+
document.getElementById('edit-dns-cred-ttl').value = cred.dns_txt_ttl || '';
1002+
document.getElementById('edit-dns-cred-max-wait').value = cred.max_dns_wait || '';
9851003
showModal('edit-dns-cred-modal');
9861004
}
9871005

@@ -990,6 +1008,8 @@ <h3>Add ZT-Domain</h3>
9901008
const name = document.getElementById('edit-dns-cred-name').value.trim();
9911009
const token = document.getElementById('edit-dns-cred-token').value.trim();
9921010
const apiUrl = document.getElementById('edit-dns-cred-api-url').value.trim();
1011+
const ttl = document.getElementById('edit-dns-cred-ttl').value.trim();
1012+
const maxWait = document.getElementById('edit-dns-cred-max-wait').value.trim();
9931013

9941014
if (!name) {
9951015
showToast('Name is required', 'error');
@@ -1001,6 +1021,8 @@ <h3>Add ZT-Domain</h3>
10011021
if (name) body.name = name;
10021022
if (token) body.cf_api_token = token;
10031023
if (apiUrl) body.cf_api_url = apiUrl;
1024+
if (ttl) body.dns_txt_ttl = parseInt(ttl);
1025+
if (maxWait) body.max_dns_wait = parseInt(maxWait);
10041026

10051027
const response = await fetch('/prpc/Admin.UpdateDnsCredential', {
10061028
method: 'POST',
@@ -1023,6 +1045,8 @@ <h3>Add ZT-Domain</h3>
10231045
const name = document.getElementById('dns-cred-name').value.trim();
10241046
const token = document.getElementById('dns-cred-token').value.trim();
10251047
const apiUrl = document.getElementById('dns-cred-api-url').value.trim();
1048+
const ttl = document.getElementById('dns-cred-ttl').value.trim();
1049+
const maxWait = document.getElementById('dns-cred-max-wait').value.trim();
10261050
const setAsDefault = document.getElementById('dns-cred-default').checked;
10271051

10281052
if (!name || !token) {
@@ -1031,16 +1055,20 @@ <h3>Add ZT-Domain</h3>
10311055
}
10321056

10331057
try {
1058+
const body = {
1059+
name: name,
1060+
provider_type: 'cloudflare',
1061+
cf_api_token: token,
1062+
cf_api_url: apiUrl || undefined,
1063+
set_as_default: setAsDefault
1064+
};
1065+
if (ttl) body.dns_txt_ttl = parseInt(ttl);
1066+
if (maxWait) body.max_dns_wait = parseInt(maxWait);
1067+
10341068
const response = await fetch('/prpc/Admin.CreateDnsCredential', {
10351069
method: 'POST',
10361070
headers: { 'Content-Type': 'application/json' },
1037-
body: JSON.stringify({
1038-
name: name,
1039-
provider_type: 'cloudflare',
1040-
cf_api_token: token,
1041-
cf_api_url: apiUrl || undefined,
1042-
set_as_default: setAsDefault
1043-
})
1071+
body: JSON.stringify(body)
10441072
});
10451073
if (!response.ok) {
10461074
const err = await response.text();

0 commit comments

Comments
 (0)