Git Product home page Git Product logo

bupnp's Introduction

bupnp

UPNP for node.js.

Usage

const UPNP = require('bupnp');

API

// Set a timeout
UPNP.RESPONSE_TIMEOUT = 1000

// Discovering internet gateway (upnp)
let wan = await UPNP.discover()

// Find external IP (upnp)
let host = await wan.getExternalIP()

// Add port mapping (remoteHost, externalPort, internalPort)
await wan.addPortMapping(host, src, dest)

// Remove port mapping
await wan.removePortMapping(host, port)

Contribution and License Agreement

If you contribute code to this project, you are implicitly allowing your code to be distributed under the MIT license. You are also implicitly verifying that all code is your original work. </legalese>

License

  • Copyright (c) 2017, Christopher Jeffrey (MIT License).

See LICENSE for more info.

bupnp's People

Contributors

chjj avatar roccomuso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bupnp's Issues

Gateway discovery goes in timeout

const UPNP = require('./lib/upnp')
UPNP.RESPONSE_TIMEOUT = 10*1000

UPNP.discover().then(console.log).catch(console.error)

Output:

Error: Request timed out.
    at Timeout.timeout.setTimeout [as _onTimeout] (/home/user/Desktop/REPOS/bupnp/lib/upnp.js:89:22)
    at ontimeout (timers.js:471:11)
    at tryOnTimeout (timers.js:306:5)
    at Timer.listOnTimeout (timers.js:266:5)

I tried with node-ssdp and it works.

var Client = require('node-ssdp').Client
, client = new Client();

client.on('response', function (headers, statusCode, rinfo) {
   console.log('Got a response to an m-search.', headers, statusCode, rinfo);
});

// get a list of all services on the network
setInterval(()=>{
  client.search('ssdp:all');
}, 3000)

Output:

{ 'CACHE-CONTROL': 'max-age=3600',
  EXT: '',
  LOCATION: 'http://192.168.88.1:2828/gateway.xml',
  SERVER: 'RouterOS/6.35.2UPnP/1.0 MikroTik UPnP/1.0',
  ST: 'urn:schemas-upnp-org:device:InternetGatewayDevice:1',
  USN: 'uuid:UUID-MIKROTIK-INTERNET-GATEWAY-DEVICE-TZ62-R761::urn:schemas-upnp-org:device:InternetGatewayDevice:1' }

200

{ address: '192.168.88.1', family: 'IPv4', port: 1900, size: 323}

Why bupnp doesn't discover it?

README api desc

Is this lib stable?
It would be useful to have the API and a little bit of doc wrote on the README

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.