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

wireguarode

v1.1.4

Published

Wireguard management tool with ACLs and 2FA

Downloads

3

Readme

Wireguarode

  • Wireguarode allows to easily manage a Wireguard installation with ACLs and 2FA (TOTP) peer authentication.
  • It works with a main JSON file as input/config, allowing to allocate peers to groups, manage ACLs, and enable 2FA TOTP authentication.
  • Wireguarode can be used both as a library and a CLI tool.
  • Leverages iptables to acomplish all this.

Features

  • Accepts JSON configuration file
  • Group-based peer allocation
  • Access Control Lists (ACL) management
  • Two-Factor Authentication (2FA) with Time-based One-Time Password (TOTP)
  • Library and CLI usage

Installation

To install Wireguarode, run the following command:

npm install -g wireguarode

You need to have Wireguard already installed, wireguarode defaults to /etc/wireguard/... but it's possible to specify a different path.

Usage

As a CLI tool

To use Wireguarode as a CLI tool, simply provide the path to your JSON configuration file as an argument:

wireguarode --help
wireguarode group --help
wireguarode peer --help

Example use case

  • Create two groups of peers one called "operator" that can only access a specific IP address and port and an unrestricted one called "god".
  • Add a new peer that belongs to the operator group.
wireguarode group add operator
wireguarode group adddestination operator tcp://192.168.1.10:443
wireguarode group adddestination operator tcp://192.168.1.10:22
wireguarode group add god
wireguarode peer add --identifier john.doe2@rainbow --key XXXXXXX --address 10.15.12.4 --group operator
wireguarode reload

2FA

wireguarode peer secret john.doe1@rainbow
> Secret generated: otpauth://totp/wireguarode:john.doe1%40rainbow?secret=XXXXXXXXXXXX&period=30&digits=6&algorithm=SHA1&issuer=wireguarode

wireguarode reload

CLI Commands

Wireguarode supports several CLI commands for different operations:

  • save: Save the configuration file to a specified optional path.
  • generate: Generate Wireguard configuration files and save them to a specified path.

Group Commands:

  • add: Add a new group.
  • remove: Remove an existing group.
  • adddestination: Add a destination (IP, port, and protocol) to an existing group.
  • removedestination: Remove a destination (IP, port, and protocol) from an existing group.

Peer Commands:

  • activate: Activate a peer using a TOTP code.
  • deactivate: Deactivate a peer.
  • secret: Activate 2FA for a peer.
  • expire: Expire peers based on the maximum minutes since their last login (default: 24 hours).
  • add: Add a new peer.

To use a command, pass it as an argument followed by the configuration file:

wireguarode <command> [arguments]

As a library

To use Wireguarode as a library, first install it as a dependency in your project:

npm install wireguarode

Then, you can import and use it in your project:

const wireguarode = require('wireguarode');

// Load your WireGuard configuration JSON
const config = require('./path/to/your/config.json');

// Instantiate Wireguarode 
var wireguard = new Wireguard();
wireguard.loadConfig(config);

Configuration

  • Wireguarode uses a JSON file for its configuration.
  • The following configuration will automatically generate the files that are in the output_example folder.
{
  "addresses": [
    "192.168.1.1"
  ],
  "enforce2fa": false,
  "debug": true,
  "path": "/etc/wireguard",
  "private_key": "XXXXXXXXXX",
  "listen_port": 12345,
  "interfaces": [
    "eth0",
    "eth1"
  ],
  "peers": [
    {
      "identifier": "john.doe1@rainbow",
      "addresses": [
        "192.168.20.1"
      ],
      "public_key": "YYYYYYYYYY",
      "group": "xpto"
    },
    {
      "identifier": "john.doe2@rainbow",
      "addresses": [
        "192.168.20.3"
      ],
      "public_key": "HHHHHHHHHHH",
      "group": "admin"
    }
  ],
  "groups": [
    {
      "name": "admin",
      "destinations": [
        "tcp://192.168.1.1:80",
        "tcp://192.168.1.1:443"
      ]
    },
    {
      "name": "admin2",
      "destinations": [
        "tcp://192.168.1.10:443",
        "tcp://192.168.1.2:22",
        "tcp://192.168.1.4:22"
      ]
    },
    {
      "name": "xpto",
      "destinations": [
        "tcp://192.168.1.2:22"
      ]
    }
  ]
}