Closed MichaelJCole closed 1 month ago
A quick look at the pmp client has these types boolean:
https://github.com/achingbrain/nat-port-mapper/blob/master/src/pmp/index.ts#L32
export interface PortMappingOptions { type?: 'tcp' | 'udp' ttl?: number public?: boolean private?: boolean internal?: boolean external?: boolean }
But then cast with Number() https://github.com/achingbrain/nat-port-mapper/blob/master/src/pmp/index.ts#L186
request (op: number, obj: PortMappingOptions, deferred: DeferredPromise<any>): void { ... internal = Number(obj.private ?? obj.internal ?? 0) if (internal !== (internal | 0) ?? internal < 0) { throw new Error('the "private" port must be a whole integer >= 0') } external = Number(obj.public ?? obj.external ?? 0) if (external !== (external | 0) ?? external < 0) { throw new Error('the "public" port must be a whole integer >= 0') }
A quick look at the pmp client has these types boolean:
https://github.com/achingbrain/nat-port-mapper/blob/master/src/pmp/index.ts#L32
But then cast with Number() https://github.com/achingbrain/nat-port-mapper/blob/master/src/pmp/index.ts#L186