Add args for production
This commit is contained in:
parent
a9beb8a467
commit
ca79e88b46
3 changed files with 11 additions and 9 deletions
6
app.js
6
app.js
|
|
@ -4,14 +4,16 @@ const https = require("https");
|
||||||
const app = require("./index.js");
|
const app = require("./index.js");
|
||||||
const listener = require("./src/client.js");
|
const listener = require("./src/client.js");
|
||||||
const { SniPrepare, SniListener } = require("./src/sni.js");
|
const { SniPrepare, SniListener } = require("./src/sni.js");
|
||||||
|
const port80 = (process.argv.length >= 2 ? parseInt(process.argv[2]) : 0) || 80;
|
||||||
|
const port443 = (process.argv.length >= 3 ? parseInt(process.argv[3]) : 0) || 443;
|
||||||
|
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
await SniPrepare();
|
await SniPrepare();
|
||||||
const httpsServer = https.createServer({
|
const httpsServer = https.createServer({
|
||||||
SNICallback: SniListener,
|
SNICallback: SniListener,
|
||||||
}, listener);
|
}, listener);
|
||||||
httpsServer.listen(443);
|
httpsServer.listen(port443);
|
||||||
app.listen(80);
|
app.listen(port80);
|
||||||
};
|
};
|
||||||
|
|
||||||
main().catch((err) => {
|
main().catch((err) => {
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,9 @@ const PUBLIC_KEY_TYPE = 'spki'
|
||||||
* @param {crypto.KeyObject} privateKey
|
* @param {crypto.KeyObject} privateKey
|
||||||
* @param {String} [passphrase]
|
* @param {String} [passphrase]
|
||||||
*
|
*
|
||||||
* @return {String}
|
|
||||||
*/
|
*/
|
||||||
const exportPrivateKey = (privateKey, passphrase) => {
|
const exportPrivateKey = (privateKey, passphrase) => {
|
||||||
|
/** @type {crypto.KeyExportOptions<'pem'>} */
|
||||||
const privateKeyOpts = {
|
const privateKeyOpts = {
|
||||||
type: PRIVATE_KEY_TYPE,
|
type: PRIVATE_KEY_TYPE,
|
||||||
format: PRIVATE_KEY_FORMAT
|
format: PRIVATE_KEY_FORMAT
|
||||||
|
|
@ -41,10 +41,9 @@ const exportPrivateKey = (privateKey, passphrase) => {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {crypto.KeyObject} publicKey
|
* @param {crypto.KeyObject} publicKey
|
||||||
*
|
|
||||||
* @return {String}
|
|
||||||
*/
|
*/
|
||||||
const exportPublicKey = publicKey => {
|
const exportPublicKey = publicKey => {
|
||||||
|
/** @type {crypto.KeyExportOptions<'pem'>} */
|
||||||
return publicKey.export({
|
return publicKey.export({
|
||||||
type: PUBLIC_KEY_TYPE,
|
type: PUBLIC_KEY_TYPE,
|
||||||
format: PUBLIC_KEY_FORMAT
|
format: PUBLIC_KEY_FORMAT
|
||||||
|
|
@ -55,9 +54,10 @@ const exportPublicKey = publicKey => {
|
||||||
* @param {String} privateKeyData
|
* @param {String} privateKeyData
|
||||||
* @param {String} [passphrase]
|
* @param {String} [passphrase]
|
||||||
*
|
*
|
||||||
* @return {String}
|
* @return {crypto.KeyObject}
|
||||||
*/
|
*/
|
||||||
const importPrivateKey = (privateKeyData, passphrase) => {
|
const importPrivateKey = (privateKeyData, passphrase) => {
|
||||||
|
/** @type {crypto.KeyExportOptions<'pem'>} */
|
||||||
const privateKeyOpts = {
|
const privateKeyOpts = {
|
||||||
key: privateKeyData,
|
key: privateKeyData,
|
||||||
format: PRIVATE_KEY_FORMAT,
|
format: PRIVATE_KEY_FORMAT,
|
||||||
|
|
@ -93,8 +93,8 @@ const importPublicKey = publicKeyData => {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {String} dirname
|
* @param {String} filename
|
||||||
* @param {(crypto.KeyObject|String)} key
|
* @param {crypto.KeyObject|string} key
|
||||||
* @param {String} [passphrase]
|
* @param {String} [passphrase]
|
||||||
*
|
*
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
const https = require('https')
|
const https = require('https')
|
||||||
|
|
||||||
const request = (url, { data = '', ...options } = {}, cb) => {
|
const request = (/** @type {string | import("url").URL} */ url, /** @type {https.RequestOptions&{data?: string}} */ { data = '', ...options } = {}, /** @type {() => any} */ cb) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
url = new URL(url)
|
url = new URL(url)
|
||||||
|
|
|
||||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue