runtime-node
runtime-node copied to clipboard
Keep all ports that we connect to
Currently, when connecting to multiple ports in the same hostname, the firewall only tracks the first port connected to, and discards the rest. This fixes the code so that we track all ports connected to and report them to the server.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
:loudspeaker: Thoughts on this report? Let us know!
PR looks good to me. 👍 Maybe this approach would be slightly more efficient:
export class Hostnames {
private map = new Map<string, Ports>();
constructor(private readonly maxEntries: number = 200) {}
add(hostname: string, port: number | undefined) {
if (!this.map.has(hostname)) {
- this.map.set(hostname, new Set());
+ this.map.set(hostname, new Set([port]));
+ } else {
+ this.map.get(hostname)?.add(port);
}
- (this.map.get(hostname) as Ports).add(port);