Skip to main content
Deno 2 is finally here 🎉️
Learn more

upnp

upnp port mapping for deno

import

import Upnp from 'https://deno.land/x/rmw_upnp@0.0.2/mod.js'

or export in your deps.js

export Upnp from 'https://deno.land/x/rmw_upnp@0.0.2/mod.js'

use

see src/index_test.coffee or lib/index_test.js for example

coffeescript version

import Upnp from './index.js'

do =>
  upnp = await Upnp()
  if not upnp
    console.log "UPNP not available"
    return

  # mapPort(protocol,internal,external,duration=0,description="")
  await upnp.mapPort(
    "UDP",8080,8080,0,"upnp test"
  )
  console.log await upnp.map()

javascript version

// Generated by CoffeeScript 2.5.1
import Upnp from './index.js';

(async() => {
  var upnp;
  upnp = (await Upnp());
  if (!upnp) {
    console.log("UPNP not available");
    return;
  }
  // mapPort(protocol,internal,external,duration=0,description="")
  await upnp.mapPort("UDP", 8080, 8080, 0, "upnp test");
  return console.log((await upnp.map()));
})();

//# sourceMappingURL=index_test.js.map

output like below

[
  {
    NewPortMappingDescription: "upnp test",
    NewProtocol: "UDP",
    NewInternalClient: "172.16.0.15",
    NewRemoteHost: "",
    NewInternalPort: 8080,
    NewExternalPort: 8080,
    NewEnabled: 1,
    NewLeaseDuration: 0
  }
]