cordova-plugin-nslookup
This plugin implements the nslookup
software utility.
Installation
cordova plugin add cordova-plugin-nslookup
or
cordova plugin add https://github.com/t1st3/cordova-plugin-nslookup.git
Usage
This plugin defines a global NsLookup
object.
Although the object is in the global scope, it is not available until after the deviceready
event.
query a domain
By default, querying a domain will return the domains associated IPv4 address. Here is an example of a query for the domain wikipedia.org
:
document; { var n success err query; query = 'wikipedia.org'; { console; }; { console; }; n = ; n;}
A
records)
query a domain's specific record (here, You can specify which type of DNS record will be queried. Here is an example of a query on an A
record of the domain wikipedia.org
:
document; { var n success err query; query = query: 'wikipedia.org' type: 'A'; { console; }; { console; }; n = ; n;}
NOTE: The following records are currently supported:
- A
- AAAA
- CNAME
- MX
- NS
- PTR
- SOA
- SRV
- TXT
Multiple queries
You can also mix queries. Here is an example of multiple queries (for each supported record) mixed together:
document; { var n success err query; query = 'wikipedia.org' query: 'google.com' type: 'A' query: 'google.com' type: 'AAAA' query: 'www.tiste.org' type: 'CNAME' query: 'google.com' type: 'MX' query: 'google.com' type: 'NS' query: '192.174.198.91.in-addr.arpa' type: 'PTR' query: 'google.com' type: 'SOA' query: '_xmpp-server._tcp.gmail.com' type: 'SRV' query: 'google.com' type: 'TXT' ; { console; }; { console; }; n = ; n;}
Methods
- NsLookup.nslookup
NsLookup.nslookup
This method takes the following arguments:
- queries: an array of queries
- success: a callback function that handles success
- err: a callback function that handles error
The callback function for success takes one argument, which is a JSON array of results. Here a comprehensive sample of results for each type of supported record, matching the multiple queries described above:
Supported Platforms
- Android
License
This project is licensed under the MIT license. Check the LICENSE.md file.
Dependencies
For the Android part, this project depends on dnsjava, which is distributed under the BSD license.