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

linux-interfaces-config

v1.0.3

Published

Read and write the linux /etc/network/interfaces file to check and change network connectivity.

Downloads

3

Readme

linux-interfaces-config

Read, parse and write the linux /etc/network/interfaces file to check and change network connectivity.

This module is intended for use on embedded linux systems that require configuring the network interfaces and retain this configuration after system reboot.

Currently only Debian and other /etc/network/interfaces file format compatible platforms can be managed with this module.

Notes

Promise based

Node >= 6

Comments and unknown options are ignored (and lost if using a full read().then(write) cycle)

No special attempt to prevent code injection on write()

Motivation

There are multiple packages to manage the network interfaces by use of the 'ip' or 'ifconfig' commands. But these configuration is not maintained after reboot.

Although there are some packages published to achieve this by reading and writing the /etc/network/interfaces file, these are incomplete (only offering writing but not reading), or require special permissions to execute command dependencies.

The 'linux-interfaces-config' module is able to parse and write this configuration file with just making use of the standard Node.js library to get I/O access to the file.

Installation

npm install --save linux-interfaces-config

Setup

const interfacesConfig = require("linux-interfaces-config")();

You can set a different interfaces file to read/write:

const interfacesConfig = require("linux-interfaces-config")("/path/to/interfaces/file");

Or even change it on runtime:

interfacesConfig.setInputFile("/path/to/interfaces/file");

Read interfaces configuration

interfacesConfig.read().then(console.log);

Write interfaces configuration

interfacesConfig.write({
        eth0: {
            auto: true,
            hotplug: true,
            ip4: { config: 'static',
                address: '192.168.1.111',
                netmask: '255.255.255.0',
                gateway: '192.168.1.1',
                dnsNameservers: ['8.8.8.8', '8.8.8.9']
            }
        },
        wlan0: {
            auto: true,
            hotplug: true,
            ip4: {
                config: 'dhcp',
                // WPA protected Wi-Fi configuration
                wpaSsid: 'MY_WIFI_NAME',
                wpaPsk: 'WIFI-PASSWORD'
            },
            ip6: { config: 'dhcp' }
        }
    })
    .then(bytes=>console.log(`Bytes written: ${bytes}`));

When configuring a Wi-Fi with WPA security you might wish to use the PSK HASH instead of the plain password.