libpcap-ffi
- libpcap
FFI wrapper for Node.js
Note: This project is still in development.
Only supports Windows, for now. Contributions are welcome.
This project was made possible thanks to koffi
, an awesome and fast C FFI module for Node.js.
You'll need to install Npcap.
Check that you have the wpcap.dll
file at C:\Windows\System32\Npcap\wpcap.dll
- should be the default location.
Note that libpcap-ffi
may not be compatible with WinPcap
so if you had WinPcap installed before, you'll need to uninstall it or
find a way to use the wpcap.dll
from Npcap instead of the one from WinPcap.
Not supported yet.
Every functions can be directly imported from libpcap-ffi
, so if you want to use findAllDevs
, you can simply do:
// ESM
import { findAllDevs } from "libpcap-ffi";
// CJS
const { findAllDevs } = require("libpcap-ffi");
// Just use it !
const devices = findAllDevs();
console.log(devices);
/** >>> Returns the following array:
* [
* {
* name: '\\Device\\...',
* description: '...',
* addresses: [ ... ],
* flags: 22
* },
* ...
* ]
*/
Note that we use pnpm
to manage dependencies.
Command | Description |
---|---|
pnpm install |
Install the dependencies. |
pnpm build |
Bundle src directory into dist using tsup . |
pnpm tsx examples/devices.ts |
Run an example script using tsx . |
A list of things to do to make the library more complete.
- Remove
next
attribute onDevice
objects. - Parse
addresses
attribute onDevice
objects.- Make an interface for the
addresses
attribute. - Read them as an array of object.
- Make a function to parse those.
- Make an interface for the
- OpenLive
- OpenOffline