forked from forwardemail/forwardemail.net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproxy.js
32 lines (27 loc) · 812 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
// eslint-disable-next-line import/no-unassigned-import
require('./config/env');
const Graceful = require('@ladjs/graceful');
const ProxyServer = require('@ladjs/proxy');
const ip = require('ip');
const logger = require('./helpers/logger');
const proxy = new ProxyServer({
logger
});
if (!module.parent) {
const graceful = new Graceful({ servers: [proxy], 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})`
);
} catch (err) {
logger.error(err);
// eslint-disable-next-line unicorn/no-process-exit
process.exit(1);
}
})();
}