domain-forward/app.js

24 lines
594 B
JavaScript
Raw Normal View History

import { config } from "dotenv";
import https from "https";
import app from "./index.js";
import listener from "./src/client.js";
import { SniPrepare, SniListener } from "./src/sni.js";
2023-12-12 19:45:36 +01:00
config();
2021-08-22 07:29:09 +07:00
2022-06-16 23:11:01 +07:00
const port80 = parseInt(process.env.HTTP_PORT || "80");
const port443 = parseInt(process.env.HTTPS_PORT || "443");
2023-12-12 19:45:36 +01:00
2021-08-22 07:29:09 +07:00
const main = async () => {
await SniPrepare();
2021-08-22 07:29:09 +07:00
const httpsServer = https.createServer({
SNICallback: SniListener,
}, listener);
2021-09-20 20:11:57 +07:00
httpsServer.listen(port443);
2023-12-13 19:56:39 +01:00
app.listen(port80);
2021-08-22 07:29:09 +07:00
};
2021-08-22 07:35:03 +07:00
main().catch((err) => {
console.log(err);
process.exit(1);
});