Initial
This commit is contained in:
1
resources/app/dist/server/upnp.mjs
vendored
Normal file
1
resources/app/dist/server/upnp.mjs
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import natupnp from"nat-upnp";export default class UPnP{constructor({port:t=3e4,ttl:e}={}){this.port=t,this.ttl=e||600}client=natupnp.createClient();#t;createMapping(){global.logger.info(`Requesting UPnP port forwarding to destination port ${this.port}`);try{this.#e()}catch(t){return t.message=`Failed to created requested UPnP mapping: ${t.message}`,global.logger.error(t),null}return this.#t=setInterval(this.#e.bind(this),1e3*this.ttl/2),this}#e(){config.options?.debug&&global.logger.debug(`Renewing UPnP port forwarding lease to destination port ${this.port}`),this.client.portMapping({public:this.port,private:this.port,ttl:this.ttl,description:"Foundry Virtual Tabletop"})}removeMapping(){this.#t&&(clearInterval(this.#t),this.#t=void 0),this.client.portUnmapping({public:this.port})}}
|
||||
Reference in New Issue
Block a user