To use this API, you must declare the "dns"
permission in the manifest.
{"name":"My extension",..."permissions":["dns"],...}
The following code calls resolve()
to retrieve the IP address of example.com
.
service-worker.js:
constresolveDNS=async()=>{letrecord=awaitchrome.dns.resolve('example.com');console.log(record.address);// "192.0.2.172"};resolveDNS();
string optional
A string representing the IP address literal. Supplied only if resultCode indicates success.
number
The result code. Zero indicates success.
chrome.dns.resolve(
hostname: string,
callback?: function,
)
Resolves the given hostname or IP address literal.
string
The hostname to resolve.
function optional
The callback
parameter looks like: (resolveInfo: ResolveCallbackResolveInfo) => void
Promise<ResolveCallbackResolveInfo>
Promises are supported in Manifest V3 and later, but callbacks are provided for backward compatibility. You cannot use both on the same function call. The promise resolves with the same type that is passed to the callback.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-05-24 UTC.