Updated the changelog and the file.ts

canary
WolverinDEV 2020-04-03 16:02:26 +02:00
parent 6a85e91f53
commit 07f1461821
2 changed files with 24 additions and 2 deletions

View File

@ -2,6 +2,8 @@
* **03.03.20**
- Using webpack instead of our own loaded (a lot of restructuring)
- Fixed that the microphone slider hasn't worked for touch devices
- Fixed a bug which caused that audio data hasn't been transmitted
- Added the ability to start a https web server
* **28.03.20**
- Fixed a bug within the permission editor which kicks you from the server

22
file.ts
View File

@ -9,6 +9,7 @@ import * as mt from "mime-types";
import * as os from "os";
import {PathLike} from "fs";
import {ChildProcess} from "child_process";
import * as https from "https";
/* All project files */
type ProjectResourceType = "html" | "js" | "css" | "wasm" | "wav" | "json" | "img" | "i18n" | "pem";
@ -495,6 +496,8 @@ namespace server {
let server: http.Server;
let php: string;
let options: Options;
const use_https = true;
export async function launch(_files: ProjectResource[], options_: Options) {
options = options_;
files = _files;
@ -513,7 +516,24 @@ namespace server {
console.error("failed to validate php interpreter: %o", error);
throw "invalid php interpreter";
}
server = http.createServer(handle_request);
if(process.env["ssl_enabled"] || use_https) {
//openssl req -nodes -new -x509 -keyout files_key.pem -out files_cert.pem
const key_file = process.env["ssl_key"] || path.join(__dirname, "files_key.pem");
const cert_file = process.env["ssl_cert"] || path.join(__dirname, "files_cert.pem");
if(!await fs.pathExists(key_file))
throw "Missing ssl key file";
if(!await fs.pathExists(cert_file))
throw "Missing ssl cert file";
server = https.createServer({
key: await fs.readFile(key_file),
cert: await fs.readFile(cert_file),
}, handle_request);
} else {
server = http.createServer(handle_request);
}
await new Promise((resolve, reject) => {
server.on('error', reject);
server.listen(options.port, () => {