-
Notifications
You must be signed in to change notification settings - Fork 121
/
proxy.js
38 lines (30 loc) · 862 Bytes
/
proxy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* Copyright (c) Forward Email LLC
* SPDX-License-Identifier: BUSL-1.1
*/
// eslint-disable-next-line import/no-unassigned-import
require('#config/env');
const process = require('node:process');
const Graceful = require('@ladjs/graceful');
const ProxyServer = require('@ladjs/proxy');
const ip = require('ip');
const logger = require('#helpers/logger');
const proxy = new ProxyServer({
logger
});
const graceful = new Graceful({ servers: [proxy.server], logger });
graceful.listen();
(async () => {
try {
await proxy.listen(proxy.config.port);
if (process.send) process.send('ready');
const { port } = proxy.server.address();
logger.info(
`Lad proxy server listening on ${port} (LAN: ${ip.address()}:${port})`,
{ hide_meta: true }
);
} catch (err) {
await logger.error(err);
process.exit(1);
}
})();