Initial CoreDNS registration
This commit is contained in:
+22
-30
@@ -1,42 +1,34 @@
|
||||
function FQDNToCoreDNSPath(fqdn) {
|
||||
const { Etcd3 } = require("etcd3");
|
||||
const client = new Etcd3({
|
||||
hosts: 'http://127.0.0.1:2379',
|
||||
});
|
||||
|
||||
function DomainToCoreDNS(domain) {
|
||||
const prefix = "/skydns/";
|
||||
const parts = domain.split(".");
|
||||
if (parts.length < 2) return false;
|
||||
const path = parts.reverse().join("/");
|
||||
return prefix + path;
|
||||
}
|
||||
|
||||
function RegisterNewDomain(domainLabel) {
|
||||
async function GetAllRecords(domain) {
|
||||
const prefix = DomainToCoreDNS(domain) + "/";
|
||||
if (!prefix) throw new Error("Invalid domain");
|
||||
const kvs = await client.getAll().prefix(prefix).strings();
|
||||
|
||||
return kvs;
|
||||
}
|
||||
|
||||
function GetAllRecords() {
|
||||
async function RegisterNewDomain(domain) {
|
||||
const prefix = DomainToCoreDNS(domain);
|
||||
if (!domainPath) throw new Error("Invalid domain");
|
||||
|
||||
}
|
||||
|
||||
function CreateARecord(domain, host) {
|
||||
|
||||
}
|
||||
|
||||
function DeleteARecord(domain, host) {
|
||||
|
||||
}
|
||||
|
||||
function UpdateARecord(domain, host) {
|
||||
|
||||
}
|
||||
|
||||
function CreateMXRecord(domain, host) {
|
||||
|
||||
}
|
||||
|
||||
function DeleteMXRecord(domain, host) {
|
||||
|
||||
}
|
||||
|
||||
function UpdateMXRecord(domain, host) {
|
||||
const key = `${domainPath}`;
|
||||
const value = JSON.stringify({ host: '10.66.66.1' });
|
||||
|
||||
await client.put(key).value(value);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
RegisterNewDomain,
|
||||
GetAllRecords,
|
||||
CreateARecord,
|
||||
DeleteARecord
|
||||
GetAllRecords
|
||||
}
|
||||
Reference in New Issue
Block a user