Support wildcard domains, instruct on CNAME value

This commit is contained in:
AJ ONeal 2018-08-19 16:25:36 +00:00
parent 2564b750e6
commit bd15f45d1d
2 changed files with 26 additions and 2 deletions

View File

@ -27,17 +27,23 @@
<button type="submit">Next</button>
</form>
<h3>Claims</h3>
<p>If your DNS host supports ANAME records, please use those instead of CNAMEs.</p>
<p>If CNAMEs are not supported, set an A record to {{ site.deviceDomainA }}.</p>
<ol>
<li v-for="claim in claims">
<span>{{ claim.value }}</span>
<br>
<span v-if="'dns' === claim.type">CNAME <span v-if="claim.wildcard">*.</span>{{ claim.value }}: {{ site.deviceDomain }}</span>
<br>
<span v-if="'dns' === claim.type">TXT _claim-challenge.{{ claim.value }}: {{ claim.challenge }}</span>
<br>
<button v-on:click.prevent="checkDns(claim)">Check</button>
</li>
</ol>
<h3>Domains</h3>
<ol>
<li v-for="domain in domains">
{{ domain }}
<span v-if="domain.wildcard">*.</span>{{ domain.name }} <span v-if="domain.hostname">- {{domain.hostname}} ({{domain.os}} {{domain.arch}})</span>
</li>
</ol>
<pre><code v-text="token"></code></pre>

View File

@ -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) {