Handle simultaneous znc proxy requests properly

This commit is contained in:
Samuel Elliott
2022-05-30 13:12:06 +01:00
parent b8f9c2c110
commit 9f63fc8359
10 changed files with 207 additions and 79 deletions

11
src/util/net.ts Normal file
View File

@@ -0,0 +1,11 @@
import * as net from 'node:net';
export function parseListenAddress(address: string | number) {
const match = ('' + address).match(/^((?:((?:\d+\.){3}\d+)|\[(.*)\]):)?(\d+)$/);
if (!match || (match[1] && !net.isIP(match[2] || match[3]))) throw new Error('Invalid address/port');
const host = match[2] || match[3] || null;
const port = parseInt(match[4]);
return [host, port] as const;
}

View File

@@ -33,3 +33,6 @@ export const git = (() => {
};
})();
export const dev = !!git || process.env.NODE_ENV === 'development';
export const product = 'nxapi ' + version +
(git ? '-' + git.revision.substr(0, 7) + (git.branch ? ' (' + git.branch + ')' : dev ? '-dev' : '') : '');