Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tc-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tc-wrapper - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

2

dist/index.js

@@ -238,3 +238,3 @@ 'use strict';

try {
dstPort = rule.match(/.*srcPort=(\d+).*/)[1];
dstPort = rule.match(/.*dstPort=(\d+).*/)[1];
} catch (e) {/* ignored */}

@@ -241,0 +241,0 @@

{
"name": "tc-wrapper",
"version": "1.0.6",
"version": "1.0.7",
"description": "NodeJS wrapper for tc command (traffic control on linux)",

@@ -5,0 +5,0 @@ "author": "J. Victor Soto",

@@ -17,4 +17,93 @@ # tc-wrapper

WORK IN PROGRESS NOT USABLE YET
The library export a instantiable class that has three major methods: ```del```, ```get``` and ```set```, for deleting, fetching and setting tc rules.
Keep in mind that ```set``` method will call ```del``` before execute, so it will clean all the rules before aplying the new ones.
**Allowed targeting**
Currently tc-wrapper only supports ip traffic, and can match by network, src and dst ports.
**Allowed modificators**
* **rate**: Bandwith limitation, htb algorith will be used, tbf is not supported (yet).
* **delay**: Round trip time of packets, will be added as **additional** time.
* **jitter**: Delay variation normal-distributed.
* **loss**: Packet loss, in percentage.
* **corrupt**: Packet corruption, in percentage.
### Clean all rules for *eth0*
```js
import TCWrapper from 'tc-wrapper';
const tcWrapper = new TCWrapper('eth0');
tc.Wrapper.get().then((rules) => {
/* rules looks like:
{
"outgoing": {
"network=0.0.0.0/0,protocol=ip": {
"delay": "1.0ms",
"jitter": "0.5%",
"loss": "3%",
"corrupt": "2%",
"rate": "10Mbit"
}
},
"incoming": {
"network=192.168.1.1/32,protocol=ip": {
"loss": "9%",
},
"network=10.10.10.0/28,srcPort=80,protocol=ip": {
"rate": "100Mbit",
}
}
}
*/
});
```
### Increase output packets Round Trip Time by 20 ms
```js
import TCWrapper from 'tc-wrapper';
const tcWrapper = new TCWrapper('eth0');
const myRules = {
outgoing: {
'network=0.0.0.0/0,protocol=ip':{
delay: '20ms'
}
}
};
tc.Wrapper.set(myRules).then((rules) => {
// Rules set!
});
```
### Limit incoming bandwith of *eth0* to 20 Mbit
```js
import TCWrapper from 'tc-wrapper';
const tcWrapper = new TCWrapper('eth0');
const myRules = {
incoming: {
'network=0.0.0.0/0,protocol=ip':{
rate: '20Mbit'
}
}
};
tc.Wrapper.set(myRules).then((rules) => {
// Rules set!
});
```
## Enable debug of module

@@ -21,0 +110,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc