2023-04-21 10:46:24 +07:00
|
|
|
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
|
|
|
|
2023-04-21 10:46:24 +07: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 () => {
|
2021-08-22 09:10:25 +07:00
|
|
|
await SniPrepare();
|
2021-08-22 07:29:09 +07:00
|
|
|
const httpsServer = https.createServer({
|
2021-08-22 09:10:25 +07:00
|
|
|
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);
|
2023-04-21 10:46:24 +07:00
|
|
|
});
|