Skip to content

Repository files navigation

Winni

version N-API Maintenance mit dep size Known Vulnerabilities Build Status

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:

Requirements

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.

Contribution Guidelines

To contribute to the project, please read the code of conduct and the guide for N-API compilation.

Dependencies

Name Refactoring Security Risk Usage
node-addon-api ⚠️Major Low Node.js C++ addon api
node-gyp-build ⚠️Major Low Node-gyp builder

License

MIT

About

Windows Network Interfaces - low-level C++/Node.js N-API binding

Resources

Contributing

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages