@blockcore/dns 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/BlockcoreDns.js +22 -2
- package/lib/BlockcoreDnsClient.js +32 -4
- package/package.json +1 -1
package/lib/BlockcoreDns.js
CHANGED
@@ -25,8 +25,28 @@ export class BlockcoreDns {
|
|
25
25
|
}
|
26
26
|
async getDnsServers() {
|
27
27
|
const url = `https://chains.blockcore.net/services/DNS.json`;
|
28
|
-
|
29
|
-
|
28
|
+
try {
|
29
|
+
const servers = await WebRequest.fetchJson(url);
|
30
|
+
return servers;
|
31
|
+
}
|
32
|
+
catch (err) {
|
33
|
+
console.warn(`Unable to retrieve DNS list, using fixed list instead. URL: ${url}`);
|
34
|
+
console.error(err);
|
35
|
+
return [
|
36
|
+
{
|
37
|
+
url: 'https://ns.blockcore.net',
|
38
|
+
contact: 'post@blockcore.net',
|
39
|
+
},
|
40
|
+
{
|
41
|
+
url: 'https://ns.coinvault.io',
|
42
|
+
contact: 'post@coinvault.io',
|
43
|
+
},
|
44
|
+
{
|
45
|
+
url: 'https://ns.seniorblockchain.io',
|
46
|
+
contact: 'post@seniorblockchain.io',
|
47
|
+
},
|
48
|
+
];
|
49
|
+
}
|
30
50
|
}
|
31
51
|
getNameServers() {
|
32
52
|
return this.nameservers;
|
@@ -14,18 +14,46 @@ export class BlockcoreDnsClient {
|
|
14
14
|
}
|
15
15
|
async getServicesByType(service) {
|
16
16
|
const url = `${this.activeServer}/api/dns/services/service/${service}`;
|
17
|
-
|
17
|
+
try {
|
18
|
+
return await WebRequest.fetchJson(url);
|
19
|
+
}
|
20
|
+
catch (err) {
|
21
|
+
console.warn(`No services found for ${url}`);
|
22
|
+
console.error(err);
|
23
|
+
return [];
|
24
|
+
}
|
18
25
|
}
|
19
26
|
async getServicesByTypeAndNetwork(service, symbol) {
|
20
27
|
const url = `${this.activeServer}/api/dns/services/symbol/${symbol}/service/${service}`;
|
21
|
-
|
28
|
+
try {
|
29
|
+
return await WebRequest.fetchJson(url);
|
30
|
+
}
|
31
|
+
catch (err) {
|
32
|
+
console.warn(`No services found for ${url}`);
|
33
|
+
console.error(err);
|
34
|
+
return [];
|
35
|
+
}
|
22
36
|
}
|
23
37
|
async getServicesByNetwork(symbol) {
|
24
38
|
const url = `${this.activeServer}/api/dns/services/symbol/${symbol}`;
|
25
|
-
|
39
|
+
try {
|
40
|
+
return await WebRequest.fetchJson(url);
|
41
|
+
}
|
42
|
+
catch (err) {
|
43
|
+
console.warn(`No services found for ${url}`);
|
44
|
+
console.error(err);
|
45
|
+
return [];
|
46
|
+
}
|
26
47
|
}
|
27
48
|
async getExternalIP() {
|
28
49
|
const url = `${this.activeServer}/api/dns/ipaddress`;
|
29
|
-
|
50
|
+
try {
|
51
|
+
return await WebRequest.fetchText(url);
|
52
|
+
}
|
53
|
+
catch (err) {
|
54
|
+
console.warn(`Unable to find external IP.`);
|
55
|
+
console.error(err);
|
56
|
+
return '';
|
57
|
+
}
|
30
58
|
}
|
31
59
|
}
|