fix: upnp port mapping not working

Massimo Melina committed Sep 3, 2023 at 18:02 UTC 336b1c175870a78b79c139447dbdca1df10bd2d7
1 file changed +3 -3
src/api.net.ts
+3 -3
@@ -82,10 +82,10 @@ const apis: ApiHandlers = {
82 if (!internalPort)
83 return new ApiError(HTTP_FAILED_DEPENDENCY, 'no internal port')
84 if (mapped)
85 - try { await client.removeMapping({ private: mapped.private.port, public: mapped.public.port, protocol: 'tcp' }) }
85 + try { await client.removeMapping({ public: { host: '', port: mapped.public.port } }) }
86 catch (e: any) { return new ApiError(HTTP_SERVER_ERROR, 'removeMapping failed: ' + String(e) ) }
87 - if (external)
88 - await client.createMapping({ private: internalPort, public: external, description: 'hfs', ttl: 0 })
87 + if (external) // must use the object form of 'public' to workaround a bug of the library
88 + await client.createMapping({ private: internalPort, public: { host: '', port: external }, description: 'hfs', ttl: 0 })
89 return {}
90 },
91