1.0.0 • Published 6 years ago

@slimio/winni v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

Winni

SlimIO Windows Network Interfaces which expose low-level Microsoft APIs on Network Interfaces, Adapter Addresses and IF_ROW.

This binding expose the following methods/struct:

!! All methods are fully Asynchronous !!

Getting Started

This package is available in the Node Package Repository and can be easily installed with npm or yarn.

$ npm i @slimio/winni
# or
$ yarn add @slimio/winni

Usage example

Retrieve Adapter Addresses and for each of them retrieve the ifRow with the ifIndex of the interface!

const { getAdaptersAddresses, getIfEntry } = require("@slimio/winni");

async function main() {
    const networkInterfaces = await getAdaptersAddresses();
    for (const iNet of networkInterfaces) {
        console.log(`Interface name: ${iNet.name}`);
        const ifRow = await getIfEntry(iNet.ifIndex);
        console.log(JSON.stringify(ifRow, null, 4));
    }
}
main().catch(console.error);

API

getAdaptersAddresses(): Promise< NetworkInterface[] >

Retrieves the addresses associated with the adapters on the local computer.

export interface NetworkInterface {
    name: string;
    ifIndex: number;
    ifType: number;
    length: number;
    physicalAddress: string;
    zoneIndices: number[];
    dnsSuffix: string;
    description: string;
    friendlyName: string;
    flags: number;
    mtu: number;
    operStatus: number;
    transmitLinkSpeed: number;
    receiveLinkSpeed: number;
    ipv4Enabled: boolean;
    ipv6Enabled: boolean;
    ipv6IfIndex: number;
    dnsEnabled: boolean;
    registerAdapterSuffix: number;
    receiveOnly: boolean;
    noMulticast: boolean;
    ipv6OtherStatefulConfig: boolean;
    netbiosOverTcpipEnabled: boolean;
    ipv6ManagedAddressConfigurationSupported: boolean;
    networkGuid: string;
    connectionType: number;
    tunnelType: number;
    dhcpv6ClientDuid: string;
    ipv4Metric: number;
    ipv6Metric: number;
    dnServer: string[];
    anycast: string[];
    unicast: string[];
    multicast: string[];
}

getIfEntry(IfIndex: number): Promise< IfEntry >

Retrieves information for the specified interface on the local computer.

export interface IfEntry {
    physicalAddress: string;
    interfaceLuid: number;
    interfaceIndex: number;
    interfaceGuid: string;
    alias: string;
    description: string;
    mtu: number;
    type: number;
    tunnelType: number;
    mediaType: number;
    accessType: number;
    physicalMediumType: number;
    directionType: number;
    operStatus: number;
    adminStatus: number;
    mediaConnectState: number;
    networkGuid: string;
    connectionType: number;
    transmitLinkSpeed: number;
    receiveLinkSpeed: number;
    inOctets: number;
    inUcastPkts: number;
    inNUcastPkts: number;
    inDiscards: number;
    inErrors: number;
    inUnknownProtos: number;
    inUcastOctets: number;
    inMulticastOctets: number;
    inBroadcastOctets: number;
    outOctets: number;
    outUcastPkts: number;
    outNUcastPkts: number;
    outDiscards: number;
    outErrors: number;
    outUcastOctets: number;
    outMulticastOctets: number;
    outBroadcastOctets: number;
    outQLen: number;
}

getIfTable(): Promise< IfEntry[] >

Retrieves the MIB-II interfaces table (which contain all ifRow of all interfaces).

getNumberOfInterfaces(): Promise< number >

Retrieves the number of interfaces on the local computer.

How to build the project

Before building the project, be sure to get the following npm package installed:

Then, just run normal npm install command:

$ npm install

Available commands

All projects commands are described here:

commanddescription
npm run prebuildGenerate addon prebuild
npm run docGenerate JSDoc .HTML documentation (in the /docs root directory)
npm run coverageGenerate coverage of tests
npm run reportGenerate .HTML report of tests coverage

the report command have to be triggered after the coverage command.