CH-J Server Managerserverhantering över SSH
Menyn
Publicerad källa

CH-J Server Manager

Bläddra i kataloger och filer för en specifik programutgåva.

Ladda ner källa ZIP
CH-J / Server Manager 196 filer
core-20261013T133631Z-faa4ab45100e Tillagd: Datum inte noterat · Byggd:
Filer
createMainWindow.js Tillagd: Datum inte noterat 2,3 KB · 74 linjer
Ladda ner fil
1"use strict";
3const path = require("node:path");
4const { BrowserWindow, session, shell } = require("electron");
5const { windowChromeOptions } = require("./windowChrome");
7function isAllowedExternalUrl(value) {
8 try {
9 const url = new URL(String(value || ""));
10 return url.protocol === "https:" && ["ch-j.de"].includes(url.hostname);
11 } catch {
12 return false;
13 }
16function hardenSession(logger) {
17 session.defaultSession.setPermissionRequestHandler((_webContents, _permission, callback) => callback(false));
18 session.defaultSession.setPermissionCheckHandler(() => false);
19 session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
20 callback({
21 responseHeaders: {
22 ...details.responseHeaders,
23 "X-Content-Type-Options": ["nosniff"],
24 "Referrer-Policy": ["no-referrer"],
25 "Permissions-Policy": ["camera=(), microphone=(), geolocation=(), usb=(), serial=()"]
26 }
27 });
28 });
29 logger?.info("Default Electron session hardened.");
32function createMainWindow(options = {}) {
33 const preload = path.join(__dirname, "..", "..", "preload", "corePreload.js");
34 const renderer = path.join(__dirname, "..", "..", "renderer", "index.html");
35 const window = new BrowserWindow({
36 title: "CH-J Server Manager",
37 width: 1240,
38 height: 780,
39 minWidth: 960,
40 minHeight: 640,
41 backgroundColor: "#07111f",
42 icon: options.icon || path.join(__dirname, "..", "..", "..", "build", "icon.png"),
43 show: false,
44 ...windowChromeOptions(),
45 webPreferences: {
46 preload,
47 contextIsolation: true,
48 nodeIntegration: false,
49 sandbox: true,
50 webSecurity: true,
51 allowRunningInsecureContent: false,
52 spellcheck: false
53 }
54 });
56 window.webContents.setWindowOpenHandler(({ url }) => {
57 if (isAllowedExternalUrl(url)) void shell.openExternal(url);
58 return { action: "deny" };
59 });
60 window.webContents.on("will-navigate", (event, url) => {
61 if (url !== window.webContents.getURL()) event.preventDefault();
62 });
63 window.webContents.on("will-attach-webview", (event) => event.preventDefault());
64 window.once("ready-to-show", () => window.show());
65 window.loadFile(renderer);
66 return window;
69module.exports = {
70 createMainWindow,
71 hardenSession,
72 isAllowedExternalUrl,
73 windowChromeOptions
74};
SHA-256c994b144c801c3e1018abc83d4e4bee6cd9d4c127ae92c2c01874211e2e66f1d

CH-J Proprietary Software License 1.14 · Källan finns under CH-J Proprietary Software License 1.14. Dess tillgänglighet ändrar inte licensvillkoren eller ger ytterligare rättigheter.

Arkiv SHA-256de757268dbc4f0226549f8b4f41f9b7e585c856ee97fa0d43b17a0e95c281449