-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #144 from Teifun2/dns-challenge-for-letsencrypt
DNS challenge for letsencrypt
- Loading branch information
Showing
10 changed files
with
1,793 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// This script is used to scrape the DNS providers from the https://go-acme.github.io/lego/dns/ website | ||
// It will fetch the DNS providers and their respective codes and store them in a Map object | ||
// You can copy the code into the browser console and run it to get the Map object | ||
// Dont forget to remove providers that are not supported by the current acme-lego version that is being used | ||
|
||
const providerArray = []; | ||
document.querySelectorAll('table a[href^="/lego/dns/"]').forEach((provider) => { | ||
fetch(provider.href) | ||
.then(function(response) { return response.text() }) | ||
.then(function(html) { | ||
const parser = new DOMParser(); | ||
const doc = parser.parseFromString(html, "text/html") | ||
|
||
const providerCodes = Array.from(doc.querySelector('table tbody').querySelectorAll('code')).map(code => code.innerHTML); | ||
const providerId = provider.href.match(/.*?\/dns\/(.*?)\//)[1]; | ||
const providerName = provider.innerHTML; | ||
providerArray.push({providerId, providerName, providerCodes}); | ||
}) | ||
.catch(function(err) { | ||
console.log('Failed to fetch page '+provider.href+': ', err); | ||
}); | ||
}) | ||
|
||
// After fetching all the providers, sort them by providerName. You have to run this line in the console after the fetch is done | ||
|
||
providerArray.sort((a,b) => a.providerName.localeCompare(b.providerName)) | ||
|
||
|
||
// Create Dropdown items for the providers | ||
|
||
providerDropdownItems = ""; | ||
providerArray.forEach(provider => { | ||
providerDropdownItems += '<div class="item" data-value="'+provider.providerId+'">'+provider.providerName+'</div>\n' | ||
}) | ||
console.log(providerDropdownItems); | ||
|
||
|
||
// Create Credential prefill for the providers | ||
|
||
switchCasePrefill = ""; | ||
providerArray.forEach(provider => { | ||
providerCodes = provider.providerCodes.reduce((accumulator,value) => accumulator + value + "=\\n","").slice(0, -2); | ||
switchCasePrefill += 'case "'+provider.providerId+'":\n\t$("#dnsCredentials").val("'+providerCodes+'");\n\tbreak;\n' | ||
}) | ||
console.log(switchCasePrefill); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.