GithubHelp home page GithubHelp logo

voxelum / nat-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alxhotel/nat-api

0.0 1.0 0.0 519 KB

:left_right_arrow: Fast port mapping with UPnP and NAT-PMP

License: MIT License

TypeScript 100.00%
typescript node nat pmp upnp

nat-api's Introduction

nat-api

Fast port mapping with UPnP and NAT-PMP in NodeJS.

This is a fork version of nat-api.

The major differences are:

  • Use typescript, so has type definition.
  • Split PMP and upnp API, so you can use them individually.
  • Support ESM.
  • Optimize the dependencies. (only 2 up-to-dated deps)

Install

Required: NodeJS >= 10

npm install @xmcl/nat-api

Usage

const { createUpnpClient } = require('nat-api')

const client = await createUpnpClient()

// map 25565 to 25565 for 1 min:
await client.map({
  description: "Mapped by @xmcl/nat-api",
  protocol: 'tcp',
  public: 25565,
  private: 25565,
  ttl: 60 * 1000,
})

// Unmap port public and private port 25565 with TCP by default
await client.unmap({ port: 25565 })

// Get external IP
const mappings = await client.getMappings()

// see existed mappings
console.log(mappings)

// Destroy client
client.destroy()

API

See type definition in typescript.

Additional Information

License

MIT. Copyright (c) Alex

nat-api's People

Contributors

achingbrain avatar alxhotel avatar betamos avatar ci010 avatar dependabot-preview[bot] avatar

Watchers

 avatar

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.