From bd15f45d1db6f764064be21667b90b68dd98d248 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sun, 19 Aug 2018 16:25:36 +0000 Subject: [PATCH] Support wildcard domains, instruct on CNAME value --- lib/extensions/admin/account.html | 8 +++++++- lib/extensions/admin/js/account.js | 20 +++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/extensions/admin/account.html b/lib/extensions/admin/account.html index a0405a6..99537f6 100644 --- a/lib/extensions/admin/account.html +++ b/lib/extensions/admin/account.html @@ -27,17 +27,23 @@

Claims

+

If your DNS host supports ANAME records, please use those instead of CNAMEs.

+

If CNAMEs are not supported, set an A record to {{ site.deviceDomainA }}.

  1. {{ claim.value }} +
    + CNAME *.{{ claim.value }}: {{ site.deviceDomain }} +
    TXT _claim-challenge.{{ claim.value }}: {{ claim.challenge }} +

Domains

  1. - {{ domain }} + *.{{ domain.name }} - {{domain.hostname}} ({{domain.os}} {{domain.arch}})
diff --git a/lib/extensions/admin/js/account.js b/lib/extensions/admin/js/account.js index a11a38c..319b581 100644 --- a/lib/extensions/admin/js/account.js +++ b/lib/extensions/admin/js/account.js @@ -17,6 +17,10 @@ } } + var dnsRecords = { + "telebit.ppl.family": "178.128.3.196" + , "telebit.cloud": "46.101.97.218" + }; var vueData = { claims: [] , domains: [] @@ -25,17 +29,31 @@ , newEmail: null , hasAccount: false , token: null + , site: { deviceDomain: document.location.hostname, deviceDomainA: dnsRecords[document.location.hostname] } }; var app = new Vue({ el: '.v-app' , data: vueData , methods: { challengeDns: function () { + // we could do a checkbox + var wildcard = vueData.newDomainWildcard || false; + if (!/(\*\.)?[a-z0-9][a-z0-9\.\-_]\.[a-z0-9]{2,}/.test(vueData.newDomain)) { + window.alert("invalid domain name '" + vueData.newDomain + "'"); + return; + } + // we can just detect by text + if ('*.' === vueData.newDomain.slice(0, 2)) { + vueData.newDomain = vueData.newDomain.slice(2); + wildcard = true; + } return oauth3.request({ url: 'https://api.' + location.hostname + '/api/telebit.cloud/account/authorizations/new' , method: 'POST' , session: session - , data: { type: 'dns', value: vueData.newDomain, wildcard: vueData.newDomainWildcard } + , data: { type: 'dns', value: vueData.newDomain, wildcard: wildcard } + }).then(function (resp) { + vueData.claims.unshift(resp.data.claim); }); } , checkDns: function (claim) {