43 lines
808 B
JavaScript
Executable File
43 lines
808 B
JavaScript
Executable File
var natUpnp = require('nat-upnp');
|
|
|
|
var dgram = require('dgram');
|
|
var server = dgram.createSocket('udp4');
|
|
|
|
var PORT = 45454;
|
|
|
|
var client = natUpnp.createClient();
|
|
|
|
client.portMapping({
|
|
public: PORT,
|
|
private: PORT,
|
|
ttl: 2 * 60
|
|
}, (err) => {
|
|
console.log("portMapping ", err);
|
|
// Will be called once finished
|
|
});
|
|
|
|
client.portUnmapping({
|
|
public: PORT
|
|
});
|
|
|
|
client.getMappings((err, results) => {
|
|
console.log("getMappings ", results);
|
|
});
|
|
|
|
client.getMappings({ local: true }, (err, results) => {
|
|
console.log("getMappings local : ", results);
|
|
});
|
|
|
|
client.externalIp((err, ip) => {
|
|
console.log("externalIp ", ip);
|
|
});
|
|
|
|
|
|
process.on('SIGINT', function() {
|
|
console.log("Caught interrupt signal");
|
|
|
|
client.close();
|
|
process.exit();
|
|
// if (i_should_exit) {
|
|
// }
|
|
}); |