https://github.com/rmw-deno-lib/upnp
upnp port mapping for deno
https://github.com/rmw-deno-lib/upnp
deno upnp
Last synced: 4 months ago
JSON representation
upnp port mapping for deno
- Host: GitHub
- URL: https://github.com/rmw-deno-lib/upnp
- Owner: rmw-deno-lib
- Created: 2021-05-06T10:05:25.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-08T03:09:06.000Z (about 5 years ago)
- Last Synced: 2025-11-27T21:37:06.820Z (7 months ago)
- Topics: deno, upnp
- Language: CoffeeScript
- Homepage:
- Size: 63.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# upnp
upnp port mapping for deno
## import or export
```
import Upnp from 'https://deno.land/x/rmw_upnp@0.0.12/lib/index.js'
```
or export in your `deps.js`
```
export {default as Upnp} from 'https://deno.land/x/rmw_upnp@0.0.12/lib/index.js'
```
## use
see [src/index_test.coffee](./src/index_test.coffee) or [lib/index_test.js](./lib/index_test.js) for example
coffeescript version
```coffee
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="") -> local ip
console.log await upnp.mapPort(
"UDP",8080,8080,0,"upnp test"
)
for await i from upnp.map()
console.log i
```
javascript version
```javascript
// Generated by CoffeeScript 2.5.1
import Upnp from './index.js';
(async() => {
var i, ref, results, upnp;
upnp = (await Upnp());
if (!upnp) {
console.log("UPNP not available");
return;
}
// mapPort(protocol,internal,external,duration=0,description="") -> local ip
console.log((await upnp.mapPort("UDP", 8080, 8080, 0, "upnp test")));
ref = upnp.map();
results = [];
for await (i of ref) {
results.push(console.log(i));
}
return results;
})();
//# sourceMappingURL=index_test.js.map
```
output like below
```javascript
[
{
NewPortMappingDescription: "upnp test",
NewProtocol: "UDP",
NewInternalClient: "172.16.0.15",
NewRemoteHost: "",
NewInternalPort: 8080,
NewExternalPort: 8080,
NewEnabled: 1,
NewLeaseDuration: 0
}
]
```