MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / resolve

Method resolve

examples/io/udp/dns/dns.js:49–76  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

47 this.#socket = this.#servers = this.#timer = this.#UDP = undefined;
48 }
49 resolve(options) {
50 let {onResolved, onError, host} = options;
51 if (!host || (!onResolved && !onError) || !this.#UDP)
52 throw new Error;
53
54 host = host.toString();
55 if ("localhost" === host)
56 host = "127.0.0.1";
57
58 const parts = host.split(".");
59 let isAddress = 4 === parts.length;
60 if (isAddress) {
61 for (let i = 0; i < 4; i++) {
62 if (parseInt(parts[i]) != parts[i])
63 isAddress = false;
64 }
65 }
66 const request = {
67 state: 0,
68 id: host.endsWith(".local") ? 0 : ((Math.random() * 65535) | 1), //@@ collision
69 host,
70 onResolved,
71 onError,
72 isAddress
73 }
74 this.#requests.push(request);
75 this.#timer ??= Timer.set(() => this.#task(), 0, 1000);
76 }
77 #send(request) {
78 const packet = new Serializer({query: true, recursionDesired: true, opcode: DNS.OPCODE.QUERY, id: request.id});
79 packet.add(DNS.SECTION.QUESTION, request.host, DNS.RR.A, DNS.CLASS.IN);

Callers 15

wow.jsFile · 0.45
main.jsFile · 0.45
resolveFunction · 0.45
callbackMethod · 0.45
resolveFunction · 0.45
#nextMethod · 0.45
constructorMethod · 0.45
queueMicrotaskFunction · 0.45
createPromiseCallbackFunction · 0.45
defaultPromiseCallbackFunction · 0.45
createResolvedPromiseFunction · 0.45
resolvePromiseFunction · 0.45

Calls 4

#taskMethod · 0.95
setMethod · 0.65
toStringMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected