1.0.8 • Published 6 years ago

brctl-wrapper v1.0.8

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

brctl-wrapper

Simple wrapper for brctl of Linux (virtual bridges).

Installation

This module is installed via npm:

npm install --save brctl-wrapper

Usage

Create bridge: Step by step

import brtcl from 'brtcl-wrapper';

brctl.createBridge('myBridge')
  .then(() => {
    Promise.all(['eth0', 'eth1'].map(i => brctl.addIfaceToBridge(i, 'miBridge')))
      .then(() => {
        brctl.enableBridge('miBridge')
          .then(() => {
            // ----- Bridge is up!
          })
          .catch(err => console.error('Impossible to enable bridge: ', err));
      })
      .catch(err => console.error('Error adding ifaces to bridge: ', err));
  })
  .catch(err => console.error('Error creating bridge: ', err));

Create bridge: Complete setup

import brtcl from 'brtcl-wrapper';

const bridgeOptions = {
  ifaces: ['eth0', 'eth1'],
  enable: true
};
brctl.createBridge('myBridge', bridgeOptions)
  .then(() => {
    // ----- Bridge is up!
  })
  .catch(err => console.error('Error creating bridge: ', err));

Set a custom ip to the bridge

import brtcl from 'brtcl-wrapper';

const bridgeOptions = {
  ifaces: ['eth0', 'eth1'],
  enable: true,
  ip: '10.255.1.22/24'
};
brctl.createBridge('myBridge', bridgeOptions)
  .then(() => {
    // ----- Bridge is up and with ip 10.255.1.22/24!
  })
  .catch(err => console.error('Error creating bridge: ', err));

Delete bridge

import brtcl from 'brtcl-wrapper';

brctl.deleteBridge('myBridge')
  .then(() => {
    // ----- Bridge is disabled and destroyed!
  })
  .catch(err => console.error('Error destroying bridge: ', err));

Enable debug of module

This module uses debug for debugging, you can enable debug messages with:

DEBUG=brctl-wrapper

Run tests

npm test

License (MIT)

In case you never heard about the MIT license.

See the LICENSE file for details.

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago