-
Notifications
You must be signed in to change notification settings - Fork 279
/
sample-dns-api.js
56 lines (50 loc) · 1.35 KB
/
sample-dns-api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* @fileoverview Example to deal with DNS through API $configuration.sendMessage.
*
*
* Action: dns_get_placeholder_ip
* Get the ip-domain mapping related reserved ip like 198.18.1.23. This ip-domain mapping mechanism is mostly used in the filter module and MitM module.
*
*
* Action: dns_update_cache
* This action inserts(or updates) the DNS A record to the Quantumult X Tunnel DNS module.
* If the ttl passed in is negative, the related cache will be cleared.
* Don't confuse the ip in DNS A record with the reserved ip fetched from dns_get_placeholder_ip. The ip in DNS A record is the real ip for outbound connections.
*
*
* Action: dns_clear_cache
* This action clear all DNS caches.
*
*
* @supported Quantumult X (v1.0.22-build562) iOS 13.0 +
*/
/*
const message = {
action: "dns_clear_cache"
};
*/
/*
const host = "example.com";
const message = {
action: "dns_get_placeholder_ip",
content: host
};
*/
const record = {"host": "abc.debug", "ips": ["192.168.0.1"], "ttl": 60};
const message = {
action: "dns_update_cache",
content: record
};
$configuration.sendMessage(message).then(resolve => {
if (resolve.error) {
console.log(resolve.error);
}
if (resolve.ret) {
let output=JSON.stringify(resolve.ret);
console.log(output);
}
$done();
}, reject => {
// Normally will never happen.
$done();
});