Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@immjs/nat-api

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@immjs/nat-api

Port mapping with UPnP and NAT-PMP

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by500%
Maintainers
0
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 15 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc