mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Merge branch 'release-candidate' of https://github.com/Pax1601/DCSOlympus into release-candidate
This commit is contained in:
commit
6d5eb05f0b
@ -54,10 +54,10 @@ export class AudioManager {
|
||||
|
||||
constructor() {
|
||||
ConfigLoadedEvent.on((config: OlympusConfig) => {
|
||||
if (config.audio)
|
||||
config.audio.WSPort ? this.setPort(config.audio.WSPort) : this.setEndpoint(config.audio.WSEndpoint);
|
||||
else
|
||||
console.error("No audio configuration found in the Olympus configuration file");
|
||||
if (config.audio) {
|
||||
this.setPort(config.audio.WSPort);
|
||||
this.setEndpoint(config.audio.WSEndpoint);
|
||||
} else console.error("No audio configuration found in the Olympus configuration file");
|
||||
});
|
||||
|
||||
CommandModeOptionsChangedEvent.on((options: CommandModeOptions) => {
|
||||
@ -101,11 +101,19 @@ export class AudioManager {
|
||||
|
||||
let wsAddress = res ? res[1] : location.toString();
|
||||
if (wsAddress.at(wsAddress.length - 1) === "/") wsAddress = wsAddress.substring(0, wsAddress.length - 1);
|
||||
if (this.#endpoint) this.#socket = new WebSocket(`wss://${wsAddress}/${this.#endpoint}`);
|
||||
else if (this.#port) this.#socket = new WebSocket(`ws://${wsAddress}:${this.#port}`);
|
||||
else console.error("The audio backend was enabled but no port/endpoint was provided in the configuration");
|
||||
|
||||
if (!this.#socket) return;
|
||||
if (this.#port === undefined && this.#endpoint === undefined) {
|
||||
console.error("The audio backend was enabled but no port/endpoint was provided in the configuration");
|
||||
return;
|
||||
}
|
||||
|
||||
this.#socket = new WebSocket(`wss://${wsAddress}/${this.#endpoint}`);
|
||||
if (!this.#socket) this.#socket = new WebSocket(`ws://${wsAddress}:${this.#port}`);
|
||||
|
||||
if (!this.#socket) {
|
||||
console.error("Failed to connect to audio websocket");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Log the opening of the connection */
|
||||
this.#socket.addEventListener("open", (event) => {
|
||||
|
||||
@ -126,9 +126,13 @@ module.exports = function (configLocation, viteProxy) {
|
||||
});
|
||||
|
||||
/* Define middleware */
|
||||
app.use(logger('dev', {
|
||||
skip: function (req, res) { return res.statusCode < 400 }
|
||||
}));
|
||||
app.use(
|
||||
logger("dev", {
|
||||
skip: function (req, res) {
|
||||
return res.statusCode < 400;
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
/* Authorization middleware */
|
||||
if (
|
||||
@ -166,7 +170,7 @@ module.exports = function (configLocation, viteProxy) {
|
||||
app.use("/olympus", async (req, res, next) => {
|
||||
/* Check if custom authorization headers are being used */
|
||||
const user =
|
||||
//@ts-ignore
|
||||
//@ts-ignore
|
||||
req.auth?.user ??
|
||||
checkCustomHeaders(config, usersConfig, groupsConfig, req);
|
||||
|
||||
@ -221,16 +225,27 @@ module.exports = function (configLocation, viteProxy) {
|
||||
});
|
||||
|
||||
/* Proxy middleware */
|
||||
app.use(
|
||||
"/olympus",
|
||||
httpProxyMiddleware.createProxyMiddleware({
|
||||
target: `http://${
|
||||
backendAddress === "*" ? "localhost" : backendAddress
|
||||
}:${config["backend"]["port"]}/olympus`,
|
||||
changeOrigin: true,
|
||||
})
|
||||
);
|
||||
|
||||
if (config["backend"]["port"]) {
|
||||
app.use(
|
||||
"/olympus",
|
||||
httpProxyMiddleware.createProxyMiddleware({
|
||||
target: `http://${
|
||||
backendAddress === "*" ? "localhost" : backendAddress
|
||||
}:${config["backend"]["port"]}/olympus`,
|
||||
changeOrigin: true,
|
||||
})
|
||||
);
|
||||
} else {
|
||||
app.use(
|
||||
"/olympus",
|
||||
httpProxyMiddleware.createProxyMiddleware({
|
||||
target: `https://${
|
||||
backendAddress === "*" ? "localhost" : backendAddress
|
||||
}/olympus`,
|
||||
changeOrigin: true,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
app.use(bodyParser.json({ limit: "50mb" }));
|
||||
app.use(bodyParser.urlencoded({ limit: "50mb", extended: true }));
|
||||
|
||||
@ -45,29 +45,44 @@ module.exports = function (configLocation) {
|
||||
router.put("/config", function (req, res, next) {
|
||||
if (req.auth?.user === "Admin") {
|
||||
/* Create a backup folder for the configuration files */
|
||||
let backupFolder = path.join(path.dirname(configLocation), "Olympus Configs Backup");
|
||||
let backupFolder = path.join(
|
||||
path.dirname(configLocation),
|
||||
"Olympus Configs Backup"
|
||||
);
|
||||
if (!fs.existsSync(backupFolder)) {
|
||||
fs.mkdirSync(backupFolder);
|
||||
}
|
||||
|
||||
/* Make a backup of the existing files */
|
||||
let timestamp = new Date().toISOString().replace(/:/g, "-");
|
||||
fs.copyFileSync(
|
||||
path.join(path.dirname(configLocation), "olympusUsers.json"),
|
||||
path.join(
|
||||
path.dirname(configLocation),
|
||||
"Olympus Configs Backup",
|
||||
"olympusUsers.json." + timestamp
|
||||
if (
|
||||
fs.existsSync(
|
||||
path.join(path.dirname(configLocation), "olympusUsers.json")
|
||||
)
|
||||
);
|
||||
fs.copyFileSync(
|
||||
path.join(path.dirname(configLocation), "olympusGroups.json"),
|
||||
path.join(
|
||||
path.dirname(configLocation),
|
||||
"Olympus Configs Backup",
|
||||
"olympusGroups.json." + timestamp
|
||||
) {
|
||||
fs.copyFileSync(
|
||||
path.join(path.dirname(configLocation), "olympusUsers.json"),
|
||||
path.join(
|
||||
path.dirname(configLocation),
|
||||
"Olympus Configs Backup",
|
||||
"olympusUsers.json." + timestamp
|
||||
)
|
||||
);
|
||||
}
|
||||
if (
|
||||
fs.existsSync(
|
||||
path.join(path.dirname(configLocation), "olympusGroups.json")
|
||||
)
|
||||
);
|
||||
) {
|
||||
fs.copyFileSync(
|
||||
path.join(path.dirname(configLocation), "olympusGroups.json"),
|
||||
path.join(
|
||||
path.dirname(configLocation),
|
||||
"Olympus Configs Backup",
|
||||
"olympusGroups.json." + timestamp
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/* Save the users configuration file */
|
||||
let usersConfig = req.body.users;
|
||||
|
||||
@ -190,7 +190,7 @@ class DCSInstance {
|
||||
this.gameMasterPasswordHash = config["authentication"]["gameMasterPassword"];
|
||||
|
||||
/* Read the new configurations added in v2.0.0 */
|
||||
if ( config["frontend"]["autoconnectWhenLocal"] !== undefined)
|
||||
if (config["frontend"]["autoconnectWhenLocal"] !== undefined)
|
||||
this.autoconnectWhenLocal = config["frontend"]["autoconnectWhenLocal"];
|
||||
if (config["frontend"]["audio"] !== undefined && config["frontend"]["audio"]["SRSPort"] !== undefined)
|
||||
this.SRSPort = config["audio"]["SRSPort"];
|
||||
|
||||
@ -159,6 +159,7 @@ class Manager {
|
||||
if (this.getActiveInstance()) {
|
||||
this.setPort('frontend', this.getActiveInstance().frontendPort);
|
||||
this.setPort('backend', this.getActiveInstance().backendPort);
|
||||
this.expertSettingsPage.getElement().querySelector(".autoconnect .checkbox").classList.toggle("checked", this.getActiveInstance().autoconnectWhenLocal)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user