OverviewFilesCommitsIssuesDocsReleasesPeers

holepunchto-kb / skills / mininet / api-extract.json

102 lines · json ref:
{
  "repo": "mininet",
  "timestamp": "2026-01-16T23:39:34.594Z",
  "entryPoint": "index.js",
  "exports": {
    "packageJson": {
      "main": "index.js"
    }
  },
  "api": {
    "file": "index.js",
    "exports": [
      {
        "type": "default",
        "name": "Mininet"
      }
    ],
    "classes": [
      {
        "name": "Mininet"
      },
      {
        "name": "Controller"
      },
      {
        "name": "Switch"
      },
      {
        "name": "Host"
      }
    ],
    "functions": [
      {
        "name": "onsocket"
      },
      {
        "name": "onreadable"
      },
      {
        "name": "onready"
      },
      {
        "name": "onstart"
      },
      {
        "name": "broadcast"
      },
      {
        "name": "forward"
      },
      {
        "name": "onupdate"
      },
      {
        "name": "sendFromHost"
      },
      {
        "name": "send"
      },
      {
        "name": "kill"
      },
      {
        "name": "pkill"
      },
      {
        "name": "onspawn"
      },
      {
        "name": "header"
      },
      {
        "name": "fork"
      },
      {
        "name": "noop"
      },
      {
        "name": "trim"
      }
    ]
  },
  "readme": {
    "content": "# mininet\n\n> Spin up and interact with virtual networks using\n> [Mininet](http://mininet.org/) and Node.js\n\n```\nnpm install mininet\n```\n\n## Usage\n\n```js\nconst Mininet = require('mininet')\n\nconst mn = new Mininet()\n\n// create a switch\nconst s1 = mn.createSwitch()\n\n// create some hosts\nconst h1 = mn.createHost()\nconst h2 = mn.createHost()\n\n// link them to the switch\nh1.link(s1)\nh2.link(s1)\n\n// start the network\nmn.start()\n\n// run a server in node\nconst proc = h1.spawn('node server.js')\n\nproc.on('message:listening', function () {\n  // when h1 signals it is listening, run curl\n  const proc2 = h2.spawn('curl --silent ' + h1.ip + ':10000')\n\n  proc2.on('stdout', function (data) {\n    process.stdout.write('h2 ' + data)\n    mn.stop() // stop when h2 messages\n  })\n})\n\nproc.on('stdout', function (data) {\n  process.stdout.write('h1 ' + data)\n})\n```\n\nAssuming server.js looks like this\n\n```js\nconst http = require('http')\nconst mn = require('mininet/host')\n\nconst server = http.createServer(function (",
    "sections": [
      "intro",
      "usage",
      "api",
      "messaging",
      "license"
    ],
    "hasApi": true,
    "hasExamples": true,
    "exampleCount": 8,
    "examples": [
      "npm install mininet",
      "const Mininet = require('mininet')\n\nconst mn = new Mininet()\n\n// create a switch\nconst s1 = mn.createSwitch()\n\n// create some hosts\nconst h1 = mn.createHost()\nconst h2 = mn.createHost()\n\n// link them to the switch\nh1.link(s1)\nh2.link(s1)\n\n// start the network\nmn.start()\n\n// run a server in node\nconst proc = h1.spawn('node server.js')\n\nproc.on('message:listening', function () {\n  // when h1 signals it is listening, run curl\n  const proc2 = h2.spawn('curl --silent ' + h1.ip + ':10000')\n\n  proc2.on('stdout', function (data) {\n    process.stdout.write('h2 ' + data)\n    mn.stop() // stop when h2 messages\n  })\n})\n\nproc.on('stdout', function (data) {\n  process.stdout.write('h1 ' + data)\n})",
      "const http = require('http')\nconst mn = require('mininet/host')\n\nconst server = http.createServer(function (req, res) {\n  console.log('Server responding')\n  res.end('hello from server\\n')\n})\n\nserver.listen(10000, function () {\n  console.log('Server listening on', this.address().port)\n  mn.send('listening') // msg the host\n})"
    ]
  },
  "patterns": []
}