mirror of
https://github.com/samuelthomas2774/nxapi.git
synced 2026-10-23 10:06:55 -05:00
Handle simultaneous znc proxy requests properly
This commit is contained in:
11
src/util/net.ts
Normal file
11
src/util/net.ts
Normal 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;
|
||||
}
|
||||
@@ -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' : '') : '');
|
||||
|
||||
Reference in New Issue
Block a user