npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-nslookup

v0.1.0

Published

Cordova Nslookup Plugin

Downloads

27

Readme

cordova-plugin-nslookup

NPM version

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.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady() {
  var n, success, err, query;
  query = ['wikipedia.org'];
  success = function (results) {
    console.log(results);
  };
  err = function (e) {
    console.log('Error: ' + e);
  };
  n = new NsLookup();
  n.nslookup(query, success, err);
}

query a domain's specific record (here, A records)

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.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady() {
  var n, success, err, query;
  query = [{query: 'wikipedia.org', type: 'A'}];
  success = function (results) {
    console.log(results);
  };
  err = function (e) {
    console.log('Error: ' + e);
  };
  n = new NsLookup();
  n.nslookup(query, success, err);
}

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.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady() {
  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'}
  ];
  success = function (results) {
    console.log(results);
  };
  err = function (e) {
    console.log('Error: ' + e);
  };
  n = new NsLookup();
  n.nslookup(query, success, err);
}

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:

[
  {
    "query": "wikipedia.org",
    "type": "",
    "result": "wikipedia.org/91.198.174.192"
  },
  {
    "query": "google.com",
    "type": "A",
    "result": [
      {
        "address": "google.com/216.58.211.110"
      }
    ]
  },
  {
    "query": "google.com",
    "type": "AAAA",
    "result": [
      {
        "address": "google.com/2a00:1450:4007:80b::200e"
      }
    ]
  },
  {
    "query": "www.tiste.org",
    "type": "CNAME",
    "result": [
      {
        "target": "github.map.fastly.net.",
        "alias": "github.map.fastly.net."
      }
    ]
  },
  {
    "query": "google.com",
    "type": "MX",
    "result": [
      {
        "target": "alt1.aspmx.l.google.com.",
        "priority": 20
      },
      {
        "target": "alt4.aspmx.l.google.com.",
        "priority": 50
      },
      {
        "target": "aspmx.l.google.com.",
        "priority": 10
      }
    ]
  },
  {
    "query": "google.com",
    "type": "NS",
    "result": [
      {
        "target": "ns4.google.com."
      },
      {
        "target": "ns3.google.com."
      },
      {
        "target": "ns1.google.com."
      }
    ]
  },
  {
    "query": "192.174.198.91.in-addr.arpa",
    "type": "PTR",
    "result": [
      {
        "target": "text-lb.esams.wikimedia.org."
      }
    ]
  },
  {
    "query": "google.com",
    "type": "SOA",
    "result": [
      {
        "host": "ns2.google.com.",
        "admin": "dns-admin.google.com.",
        "serial": 113752958,
        "refresh": 900,
        "retry": 900,
        "expire": 1800,
        "minimum": 60
      }
    ]
  },
  {
    "query": "_xmpp-server._tcp.gmail.com",
    "type": "SRV",
    "result": [
      {
        "target": "alt1.xmpp-server.l.google.com.",
        "port": 5269,
        "priority": 20,
        "weight": 0
      },
      {
        "target": "alt4.xmpp-server.l.google.com.",
        "port": 5269,
        "priority": 20,
        "weight": 0
      },
      {
        "target": "xmpp-server.l.google.com.",
        "port": 5269,
        "priority": 5,
        "weight": 0
      }
    ]
  },
  {
    "query": "google.com",
    "type": "TXT",
    "result": [
      {
        "strings": "v=spf1 include:_spf.google.com ~all"
      }
    ]
  }
]

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.