https://github.com/hellomouse/node-tunfd
mostly incomplete: please don't use this - Node.js native module (N-API) for creating and configuring tun/tap interfaces and maybe also more things
https://github.com/hellomouse/node-tunfd
Last synced: 4 months ago
JSON representation
mostly incomplete: please don't use this - Node.js native module (N-API) for creating and configuring tun/tap interfaces and maybe also more things
- Host: GitHub
- URL: https://github.com/hellomouse/node-tunfd
- Owner: hellomouse
- Created: 2019-06-20T11:09:52.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-02-03T21:53:06.000Z (over 3 years ago)
- Last Synced: 2025-10-06T15:29:52.664Z (8 months ago)
- Language: C++
- Homepage:
- Size: 35.2 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# node-tunfd
It makes tun/tap interfaces.
## How to use
```js
const tunfd = require('tunfd');
const fs = require('fs');
let iface = new tunfd.TunInterface({
// optional, kernel will automatically assign a name if not given here
name: 'tun0',
// can be either "tun" or "tap", default is "tun"
// tun mode gets you ip packets, tap mode gets you ethernet frames
mode: 'tun',
// set to true if you want the 4-byte packet information header
// default is false, which adds IFF_NO_PI to ifr_flags
pi: false
});
// if you want to know the auto-assigned name of the interface
console.log(iface.name);
// the fd of the new interface
console.log(iface.fd);
// how to get packets
let readStream = fs.createReadStream(null, { fd: iface.fd });
readStream.on('data', packet => { ... });
// how to put packets
let writeStream = fs.createWriteStream(null, { fd: iface.fd });
writeStream.write(...);
// fork()
console.log(tunfd.fork());
```
## License
ISC