@achingbrain/nat-port-mapper
Port mapping with UPnP and NAT-PMP
Table of contents
Install
$ npm i @achingbrain/nat-port-mapper
Usage
import { upnpNat } from '@achingbrain/nat-port-mapper'
const client = await upnpNat({
ttl: number
description: string
gateway: string
keepAlive: boolean
})
await client.map({
localPort: 1000,
protocol: 'TCP'
})
await client.map({
publicPort: 2000,
localPort: 3000,
protocol: 'UDP'
})
await client.unmap({
localPort: 1000,
protocol: 'TCP'
})
const externalIp = await client.externalIp()
console.log('External IP:', ip)
client.close()
Credits
Based on alxhotel/nat-api
Additional Information
License
Licensed under either of
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.