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

wifiscanner

v1.0.1

Published

A simple Node.js WiFi Scanner

Downloads

80

Readme

WiFi Scanner

Build Status Dependency Status devDependency Status

A simple Node.js WiFi Scanner for Windows, Linux and macOS. Works great on embedded devices like the Raspberry Pi.

Installation

npm install wifiscanner

Basic Usage

  1. Require wifiscanner
  2. Create an instance of a scanner
  3. Call scan with a callback with two parameters
  4. Profit?
const wifiscanner = require("wifiscanner");

//Returns appropriate instance of a wifi scanner
const scanner = wifiscanner();

scanner.scan((error, networks) => {
    if(error) {
        console.error(error);
    } else {
        console.dir(networks);
    }
});

Network is an Array of nearby networks. Each network will have the following keys:

  • ssid
  • mac
  • channel
  • security (Array e.g [ 'WPA', 'WPA2' ])

JSON Sample Output

[
    {
        ssid: 'wifi with-n0-s3cur1ty!',
        mac: '16:0d:7f:49:da:e1',
        channel: '1',
        security: ['None']
    },
    {
        ssid: 'WEP enabled',
        mac: '16:0d:7f:49:da:e2',
        channel: '1',
        security: ['WEP']
    },
    {
        ssid: 'WPA1 Enabled',
        mac: '16:0d:7f:49:da:e3',
        channel: '1',
        security: ['WPA']
    },
    {
        ssid: 'WPA1+WPA2',
        mac: '16:0d:7f:49:da:e4',
        channel: '1',
        security: ['WPA', 'WPA2'],
    },
    {
        ssid: 'WPA2 Only',
        mac: '16:0d:7f:49:da:e5',
        channel: '1',
        security: ['WPA2']
    }
]

There is a limitation on Windows. If there is a network that is both WPA and WPA2 security, only WPA2 will be reported.

Less Basic Usage

Custom binaries and arguments

You can specify binary (binaryPath) and arguments (args) in a set of options.

const wifiscanner = require("wifiscanner");


//Options
const options = {
    args: "wlan2 scan",
    binaryPath: "/path/to/iwlist"
}

const scanner = wifiscanner(options);

scanner.scan(function(error, networks){
    if(error) {
        console.error(error);
    } else {
        console.dir(networks);
    }
});

Handling stderr

Standard error can is more of a warning. For example, if you're on Linux with wlan0, en0 and lo and you run the iwlist scan command you get both the stdout of the networks on the wlan0 network interface (which is parsed in to the networks Array) and the stderr of:

lo        Interface doesn't support scanning.

eth0      Interface doesn't support scanning.

The default behavior from this module is to do nothing. However, you can pass in a second optional callback to the scan method and do what you want with it.

const wifiscanner = require("wifiscanner");


//Options
const options = {
    args: "wlan2 scan",
    binaryPath: "/path/to/iwlist"
}

const scanner = wifiscanner(options);

scanner.scan(function(error, networks){
    //...
}, function(standardError){
    console.error(standardError);
});