gobgp library - NodeJS client for gobgpd
This is a young project which allows you to manage gobgpd remotely.
- Features
- RIB management which is equivalent to
gobgp global ribin gobgp CLI
- RIB management which is equivalent to
gobgp-node is tested on Debian Linux and OSX.
npm install gobgpThis installation process builds the C-shared library from already installed gobgp in your system and links gobgp-node binary with it.
Originate a route with gobgpd:
varGobgp=require('gobgp');vargobgp=newGobgp('<gobgpd address>:50051');gobgp.addPath({family: 'ipv4-unicast'},'10.0.0.0/24');Withdraw a route from gobgpd:
varGobgp=require('gobgp');vargobgp=newGobgp('<gobgpd address>:50051');gobgp.deletePath({family: 'ipv4-unicast'},'10.0.0.0/24');Show routes in gobgpd:
varGobgp=require('gobgp');vargobgp=newGobgp('<gobgpd address>:50051');gobgp.getRib({family: 'ipv4-unicast'}).then(function(table){console.log(table);});Originate a flowspec route with gobgpd:
varGobgp=require('gobgp');vargobgp=newGobgp('<gobgpd address>:50051');gobgp.addPath({family: 'ipv4-flowspec'},'match source 10.0.0.0/24 then rate-limit 10000');Show flowspec routes in gobgpd:
varGobgp=require('gobgp');vargobgp=newGobgp('<gobgpd address>:50051');gobgp.getRib({family: 'ipv4-flowspec'}).then(function(table){console.log(table);});Originate a BGP community added route:
varGobgp=require('gobgp');vargobgp=newGobgp('<gobgpd address>:50051');varpath=gobgp.serializePath('ipv4-unicast','10.0.0.0/24');path.pattrs.push(newBuffer([0xc0,// Optional, Transitive0x08,// Type Code: Communities0x04,// Length0xff,0xff,0xff,0x02]))// NO_ADVERTISEgobgp.addPath({family: 'ipv4-unicast'},path);Or extremely easy on the latest version of gobgp,
varGobgp=require('gobgp');vargobgp=newGobgp('<gobgpd address>:50051');gobgp.addPath({family: 'ipv4-unicast'},'10.0.0.0/24 community no-advertise');Copyright (c) 2018 Shintaro Kojima. Code released under the MIT license.