|
||||||||
NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Dns
Control the way DNS resolutions are done or make DNS resolutions directly. Here's a script to change the nameserver used for all DNS lookups:
var dns = require('dns'); // Use Google's nameserver instead of the agent's default nameserver. var nameserver = "8.8.8.8"; dns.setNameServer(nameserver); var driver = test.openBrowser(); test.beginTransaction(); test.beginStep(); test.get("www.yahoo.com"); test.endStep(); test.endTransaction();And here's a script to do a DNS lookup directly and verify that a host name resolution is served up by UltraDNS:
var dns = require('dns'); var nameserver = "8.8.8.8"; var host = "home.wpm.neustar.biz"; var shouldMatch = /ultra/; var timeout = 2000; dns.setNameServer(nameserver); test.beginTransaction(); test.beginStep(); var r = dns.lookup("home.wpm.neustar.biz", "NS"); var found = false; var records = r.getRecords(); for (var i = 0; i < records.length; ++i) { var record = records[i]; if (shouldMatch.test(record.getName())) { found = true; } } if (!found) { throw "Unable to verify nameserver for: " + host + " with regex: " + shouldMatch; } if (r.getQueryTime() < timeout) { throw "DNS request took too long: " + r.getQueryTime() + " > " + timeout + " milliseconds"; } test.endStep(); test.endTransaction();
Nested Class Summary | |
---|---|
static interface |
Dns.DnsLookupResponse
|
static interface |
Dns.DnsRecord
|
Method Summary | |
---|---|
void |
clearCache()
Flushes the DNS cache. |
boolean |
isCached(java.lang.String hostname)
Returns true the if the given hostname is cached. |
Dns.DnsLookupResponse |
lookup(java.lang.String hostName)
Lookup a hostname and report back its ips |
Dns.DnsLookupResponse |
lookup(java.lang.String hostName,
java.lang.String recordType)
Lookup a hostname and report back its ips. |
Dns.DnsLookupResponse |
lookupIp4(java.lang.String hostName)
Lookup a hostname and report back its ipv4 ips |
Dns.DnsLookupResponse |
lookupIp6(java.lang.String hostName)
Lookup a hostname and report back its ipv6 ips |
Dns.DnsLookupResponse |
lookupNS(java.lang.String hostName)
Lookup a hostname and report back its ipv6 ips |
void |
remapHost(java.lang.String source,
java.lang.String target)
Provides functionality similar to editing your "hosts file" on your local computer. |
java.lang.String[] |
reverseLookup(java.lang.String ip)
Reverse lookup an ip and report back its hostname(s). |
void |
setCacheTimeout(int timeoutMS)
Sets the TTL for objects in the DNS cache in milliseconds. |
void |
setLookupMode(java.lang.String mode)
Control the lookup priority of ipv4 vs ipv6. |
void |
setNameServer(java.lang.String nameServer1)
Sets the DNS name server to use for all DNS lookups. |
void |
setNameServer(java.lang.String[] nameServers)
Sets the DNS name server to use for all DNS lookups. |
void |
setTcp(boolean bUseTcp)
Make DNS requests over TCP or switch back to using UDP. |
void |
setTimeout(int timeoutMS)
Sets the timeout to use when making a request. |
Method Detail |
---|
void setNameServer(java.lang.String nameServer1)
nameServer1
- the primary name servervoid setNameServer(java.lang.String[] nameServers)
nameServers
- the list of name serversvoid setLookupMode(java.lang.String mode)
mode
- the list of name serversDns.DnsLookupResponse lookup(java.lang.String hostName) throws java.lang.Exception
hostName
- the hostname to lookup
java.lang.Exception
- when the hostname cannot be resolvedDns.DnsLookupResponse lookup(java.lang.String hostName, java.lang.String recordType) throws java.lang.Exception
hostName
- the hostname to lookuprecordType
- the record type to lookup
java.lang.Exception
- when the hostname cannot be resolvedDns.DnsLookupResponse lookupIp4(java.lang.String hostName) throws java.lang.Exception
hostName
- the hostname to lookup
java.lang.Exception
- when the hostname cannot be resolvedDns.DnsLookupResponse lookupIp6(java.lang.String hostName) throws java.lang.Exception
hostName
- the hostname to lookup
java.lang.Exception
- when the hostname cannot be resolvedDns.DnsLookupResponse lookupNS(java.lang.String hostName) throws java.lang.Exception
hostName
- the hostname to lookup
java.lang.Exception
- when the hostname cannot be resolvedjava.lang.String[] reverseLookup(java.lang.String ip) throws java.io.IOException
ip
- the ip to lookup a hostname for.
java.io.IOException
void clearCache()
void setCacheTimeout(int timeoutMS)
timeoutMS
- timeout in millisecondsboolean isCached(java.lang.String hostname)
hostname
- the hostname to check
void remapHost(java.lang.String source, java.lang.String target)
source
- the source host to re-map from (i.e. www.example.com)target
- the target host to re-map to (i.e. new.example.com)void setTcp(boolean bUseTcp)
bUseTcp
- true if TCP, false use UDPvoid setTimeout(int timeoutMS)
timeoutMS
- The time, in milliseconds, before the call aborts
|
© 2023 Vercara, LLC. All Rights Reserved. | |||||||
NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |