mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-07-16 05:13:36 +00:00
e9e30cd318
* Guacd, Docker-Compose, RDP (#475) * fix select edit host but not update view (#438) * fix: Checksum issue with chocolatey * fix: Remove homebrew old stuff * Add Korean translation (#439) Co-authored-by: 송준우 <2484@coreit.co.kr> * feat: Automate flatpak * fix: Add imagemagik to electron builder to resolve build error * fix: Build error with runtime repo flag * fix: Flatpak runtime error and install freedesktop ver warning * fix: Flatpak runtime error and install freedesktop ver warning * feat: Re-add homebrew cask and move scripts to backend * fix: No sandbox flag issue * fix: Change name for electron macos cask output * fix: Sandbox error with Linux * fix: Remove comming soon for app stores in readme * Adding Comment at the end of the public_key on the host on deploy (#440) * Add termix.rb Cask file * Update Termix to version 1.9.0 with new checksum * Update README to remove 'coming soon' notes * -Add New Interface for Credential DB -Add Credential Name as a comment into the server authorized_key file --------- Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com> * Sudo auto fill password (#441) * Add termix.rb Cask file * Update Termix to version 1.9.0 with new checksum * Update README to remove 'coming soon' notes * Feature Sudo password auto-fill; * Fix locale json shema; --------- Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com> * Added Italian Language; (#445) * Add termix.rb Cask file * Update Termix to version 1.9.0 with new checksum * Update README to remove 'coming soon' notes * Added Italian Language; --------- Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com> * Auto collapse snippet folders (#448) * Add termix.rb Cask file * Update Termix to version 1.9.0 with new checksum * Update README to remove 'coming soon' notes * feat: Add collapsable snippets (customizable in user profile) * Translations (#447) * Add termix.rb Cask file * Update Termix to version 1.9.0 with new checksum * Update README to remove 'coming soon' notes * Added Italian Language; * Fix translations; Removed duplicate keys, synchronised other languages using English as the source, translated added keys, fixed inaccurate translations. --------- Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com> * Remove PTY-level keepalive (#449) * Add termix.rb Cask file * Update Termix to version 1.9.0 with new checksum * Update README to remove 'coming soon' notes * Remove PTY-level keepalive to prevent unwanted terminal output; use SSH-level keepalive instead --------- Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com> * feat: add Guacamole support for RDP, VNC, and Telnet connections - Implemented WebSocket support for Guacamole in Nginx configuration. - Added REST API endpoints for generating connection tokens and checking guacd status. - Created Guacamole server using guacamole-lite for handling connections. - Developed frontend components for testing RDP/VNC connections and displaying the remote session. - Updated package dependencies to include guacamole-common-js and guacamole-lite. - Enhanced logging for Guacamole operations. * feat: enhance Guacamole support with RDP and VNC connection settings and UI updates * feat: Seperate server stats and tunnel management (improved both UI's) then started initial docker implementation * fix: finalize adding docker to db * fix: merge syntax errors * feat: implement mouse coordinate adjustment based on scale factor in GuacamoleDisplay * feat: add TypeScript definitions for guacamole-common-js module * feat: enhance Mouse.State constructor to accept optional parameters and object destructuring * feat: Add support for RDP and VNC connections in SSH host management - Introduced connectionType field to differentiate between SSH, RDP, VNC, and Telnet in host data structures. - Updated backend routes to handle RDP/VNC specific fields: domain, security, and ignoreCert. - Enhanced the HostManagerEditor to include RDP/VNC specific settings and authentication options. - Implemented token retrieval for RDP/VNC connections using Guacamole API. - Updated UI components to reflect connection type changes and provide appropriate connection buttons. - Removed the GuacamoleTestDialog component as its functionality is integrated into the HostManagerEditor. - Adjusted the TopNavbar and Host components to accommodate new connection types and their respective actions. * feat: Enhance Guacamole integration with extended configuration options - Added detailed Guacamole configuration interface for RDP/VNC/Telnet connections, including display, audio, performance, and session settings. - Implemented logging for token requests and received options for better debugging. - Updated HostManagerEditor to support new Guacamole configuration fields with validation and default values. - Integrated Guacamole configuration parsing in HostManagerViewer and Host components. - Enhanced API requests to include extended Guacamole configuration parameters in the token request. - Refactored code to convert camelCase configuration keys to kebab-case for compatibility with Guacamole API. * feat: merge guacd into 2.0.0 and improve UI for host manager and made general bug fixes --------- Co-authored-by: Tran Trung Kien <kientt13.7@gmail.com> Co-authored-by: LukeGus <bugattiguy527@gmail.com> Co-authored-by: junu <bigdwarf_@naver.com> Co-authored-by: 송준우 <2484@coreit.co.kr> Co-authored-by: SlimGary <trash.slim@gmail.com> Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com> Co-authored-by: Nunzio Marfè <nunzio.marfe@protonmail.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com> * feat: rename api routes and files * feat: improve guacd ui/backend * feat: improve guacd ui/backend * fix: state persistance issues causing refresh * feat: improge guacd connections, fixed telnet not opening, and improved general guacd integration * feat: continue improving integration also with bug fixes * Merge 2.0.0 with 2.0.0 that includes bug fixes (#620) * Guacd, Docker-Compose, RDP (#475) * fix select edit host but not update view (#438) * fix: Checksum issue with chocolatey * fix: Remove homebrew old stuff * Add Korean translation (#439) Co-authored-by: 송준우 <2484@coreit.co.kr> * feat: Automate flatpak * fix: Add imagemagik to electron builder to resolve build error * fix: Build error with runtime repo flag * fix: Flatpak runtime error and install freedesktop ver warning * fix: Flatpak runtime error and install freedesktop ver warning * feat: Re-add homebrew cask and move scripts to backend * fix: No sandbox flag issue * fix: Change name for electron macos cask output * fix: Sandbox error with Linux * fix: Remove comming soon for app stores in readme * Adding Comment at the end of the public_key on the host on deploy (#440) * Add termix.rb Cask file * Update Termix to version 1.9.0 with new checksum * Update README to remove 'coming soon' notes * -Add New Interface for Credential DB -Add Credential Name as a comment into the server authorized_key file --------- Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com> * Sudo auto fill password (#441) * Add termix.rb Cask file * Update Termix to version 1.9.0 with new checksum * Update README to remove 'coming soon' notes * Feature Sudo password auto-fill; * Fix locale json shema; --------- Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com> * Added Italian Language; (#445) * Add termix.rb Cask file * Update Termix to version 1.9.0 with new checksum * Update README to remove 'coming soon' notes * Added Italian Language; --------- Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com> * Auto collapse snippet folders (#448) * Add termix.rb Cask file * Update Termix to version 1.9.0 with new checksum * Update README to remove 'coming soon' notes * feat: Add collapsable snippets (customizable in user profile) * Translations (#447) * Add termix.rb Cask file * Update Termix to version 1.9.0 with new checksum * Update README to remove 'coming soon' notes * Added Italian Language; * Fix translations; Removed duplicate keys, synchronised other languages using English as the source, translated added keys, fixed inaccurate translations. --------- Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com> * Remove PTY-level keepalive (#449) * Add termix.rb Cask file * Update Termix to version 1.9.0 with new checksum * Update README to remove 'coming soon' notes * Remove PTY-level keepalive to prevent unwanted terminal output; use SSH-level keepalive instead --------- Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com> * feat: add Guacamole support for RDP, VNC, and Telnet connections - Implemented WebSocket support for Guacamole in Nginx configuration. - Added REST API endpoints for generating connection tokens and checking guacd status. - Created Guacamole server using guacamole-lite for handling connections. - Developed frontend components for testing RDP/VNC connections and displaying the remote session. - Updated package dependencies to include guacamole-common-js and guacamole-lite. - Enhanced logging for Guacamole operations. * feat: enhance Guacamole support with RDP and VNC connection settings and UI updates * feat: Seperate server stats and tunnel management (improved both UI's) then started initial docker implementation * fix: finalize adding docker to db * fix: merge syntax errors * feat: implement mouse coordinate adjustment based on scale factor in GuacamoleDisplay * feat: add TypeScript definitions for guacamole-common-js module * feat: enhance Mouse.State constructor to accept optional parameters and object destructuring * feat: Add support for RDP and VNC connections in SSH host management - Introduced connectionType field to differentiate between SSH, RDP, VNC, and Telnet in host data structures. - Updated backend routes to handle RDP/VNC specific fields: domain, security, and ignoreCert. - Enhanced the HostManagerEditor to include RDP/VNC specific settings and authentication options. - Implemented token retrieval for RDP/VNC connections using Guacamole API. - Updated UI components to reflect connection type changes and provide appropriate connection buttons. - Removed the GuacamoleTestDialog component as its functionality is integrated into the HostManagerEditor. - Adjusted the TopNavbar and Host components to accommodate new connection types and their respective actions. * feat: Enhance Guacamole integration with extended configuration options - Added detailed Guacamole configuration interface for RDP/VNC/Telnet connections, including display, audio, performance, and session settings. - Implemented logging for token requests and received options for better debugging. - Updated HostManagerEditor to support new Guacamole configuration fields with validation and default values. - Integrated Guacamole configuration parsing in HostManagerViewer and Host components. - Enhanced API requests to include extended Guacamole configuration parameters in the token request. - Refactored code to convert camelCase configuration keys to kebab-case for compatibility with Guacamole API. * feat: merge guacd into 2.0.0 and improve UI for host manager and made general bug fixes --------- Co-authored-by: Tran Trung Kien <kientt13.7@gmail.com> Co-authored-by: LukeGus <bugattiguy527@gmail.com> Co-authored-by: junu <bigdwarf_@naver.com> Co-authored-by: 송준우 <2484@coreit.co.kr> Co-authored-by: SlimGary <trash.slim@gmail.com> Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com> Co-authored-by: Nunzio Marfè <nunzio.marfe@protonmail.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com> * feat: rename api routes and files * feat: improve guacd ui/backend * feat: improve guacd ui/backend * fix: state persistance issues causing refresh * feat: improge guacd connections, fixed telnet not opening, and improved general guacd integration * feat: continue improving integration also with bug fixes --------- Co-authored-by: Wesley Reid <starhound@lostsouls.org> Co-authored-by: Tran Trung Kien <kientt13.7@gmail.com> Co-authored-by: junu <bigdwarf_@naver.com> Co-authored-by: 송준우 <2484@coreit.co.kr> Co-authored-by: SlimGary <trash.slim@gmail.com> Co-authored-by: Nunzio Marfè <nunzio.marfe@protonmail.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com> * feat: allow customizing guacd backened url * fix: ssh route mistmatching and guacamole url not changing * chore: increment ver * feat: change default to work with default compose, added splits creen support, updated readmes * fix: linux app not starting due to better sqlite isuses, improved copy/paste system so no context menu, added oidc remember me toggle, improved OS detection for sessions, flatpak invalid key, and sharing hosts with other users errors * fix: global settings not setting * chore: update compose * feat: improve the global status input * chore: cleanup files * chore: update export/improt with new host fields * fix: file manager and docker not loading properly --------- Co-authored-by: Wesley Reid <starhound@lostsouls.org> Co-authored-by: Tran Trung Kien <kientt13.7@gmail.com> Co-authored-by: junu <bigdwarf_@naver.com> Co-authored-by: 송준우 <2484@coreit.co.kr> Co-authored-by: SlimGary <trash.slim@gmail.com> Co-authored-by: Nunzio Marfè <nunzio.marfe@protonmail.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
225 lines
6.7 KiB
TypeScript
225 lines
6.7 KiB
TypeScript
import dotenv from "dotenv";
|
|
import { promises as fs } from "fs";
|
|
import { readFileSync } from "fs";
|
|
import path from "path";
|
|
import { fileURLToPath } from "url";
|
|
import { AutoSSLSetup } from "./utils/auto-ssl-setup.js";
|
|
import { AuthManager } from "./utils/auth-manager.js";
|
|
import { DataCrypto } from "./utils/data-crypto.js";
|
|
import { SystemCrypto } from "./utils/system-crypto.js";
|
|
import { systemLogger, versionLogger } from "./utils/logger.js";
|
|
|
|
(async () => {
|
|
const initStartTime = Date.now();
|
|
try {
|
|
dotenv.config({ quiet: true });
|
|
|
|
const dataDir = process.env.DATA_DIR || "./db/data";
|
|
const envPath = path.join(dataDir, ".env");
|
|
try {
|
|
await fs.access(envPath);
|
|
const persistentConfig = dotenv.config({ path: envPath, quiet: true });
|
|
if (persistentConfig.parsed) {
|
|
Object.assign(process.env, persistentConfig.parsed);
|
|
}
|
|
} catch {
|
|
// expected - env file may not exist
|
|
}
|
|
|
|
systemLogger.info("Termix backend initialization started", {
|
|
operation: "backend_init_start",
|
|
nodeEnv: process.env.NODE_ENV || "production",
|
|
port: process.env.PORT || 4090,
|
|
});
|
|
|
|
let version = "unknown";
|
|
|
|
const versionSources = [
|
|
() => process.env.VERSION,
|
|
() => {
|
|
try {
|
|
const packageJsonPath = path.join(process.cwd(), "package.json");
|
|
const packageJson = JSON.parse(
|
|
readFileSync(packageJsonPath, "utf-8"),
|
|
);
|
|
return packageJson.version;
|
|
} catch {
|
|
return null;
|
|
}
|
|
},
|
|
() => {
|
|
try {
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const packageJsonPath = path.join(
|
|
path.dirname(__filename),
|
|
"../../../package.json",
|
|
);
|
|
const packageJson = JSON.parse(
|
|
readFileSync(packageJsonPath, "utf-8"),
|
|
);
|
|
return packageJson.version;
|
|
} catch {
|
|
return null;
|
|
}
|
|
},
|
|
() => {
|
|
try {
|
|
const packageJsonPath = path.join("/app", "package.json");
|
|
const packageJson = JSON.parse(
|
|
readFileSync(packageJsonPath, "utf-8"),
|
|
);
|
|
return packageJson.version;
|
|
} catch {
|
|
return null;
|
|
}
|
|
},
|
|
];
|
|
|
|
for (const getVersion of versionSources) {
|
|
try {
|
|
const foundVersion = getVersion();
|
|
if (foundVersion && foundVersion !== "unknown") {
|
|
version = foundVersion;
|
|
break;
|
|
}
|
|
} catch {
|
|
continue;
|
|
}
|
|
}
|
|
versionLogger.info(`Termix Backend starting - Version: ${version}`, {
|
|
operation: "startup",
|
|
version: version,
|
|
});
|
|
|
|
const systemCrypto = SystemCrypto.getInstance();
|
|
await systemCrypto.initializeJWTSecret();
|
|
await systemCrypto.initializeDatabaseKey();
|
|
await systemCrypto.initializeInternalAuthToken();
|
|
|
|
await AutoSSLSetup.initialize();
|
|
systemLogger.success("SSL setup completed", {
|
|
operation: "backend_init_ssl",
|
|
sslEnabled: process.env.SSL_ENABLED === "true",
|
|
});
|
|
|
|
const dbModule = await import("./database/db/index.js");
|
|
await dbModule.initializeDatabase();
|
|
systemLogger.success("Database initialized", {
|
|
operation: "backend_init_db",
|
|
});
|
|
|
|
const authManager = AuthManager.getInstance();
|
|
await authManager.initialize();
|
|
DataCrypto.initialize();
|
|
|
|
const { OPKSSHBinaryManager } =
|
|
await import("./utils/opkssh-binary-manager.js");
|
|
try {
|
|
await OPKSSHBinaryManager.ensureBinary();
|
|
} catch (error) {
|
|
const dataDir =
|
|
process.env.DATA_DIR || path.join(process.cwd(), "db", "data");
|
|
systemLogger.warn(
|
|
"Failed to initialize OPKSSH binary - OPKSSH authentication will not be available",
|
|
{
|
|
operation: "opkssh_binary_init_failed",
|
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
stack: error instanceof Error ? error.stack : undefined,
|
|
platform: process.platform,
|
|
arch: process.arch,
|
|
dataDir,
|
|
},
|
|
);
|
|
}
|
|
|
|
await import("./database/database.js");
|
|
|
|
await import("./ssh/terminal.js");
|
|
await import("./ssh/tunnel.js");
|
|
await import("./ssh/file-manager.js");
|
|
await import("./ssh/server-stats.js");
|
|
await import("./ssh/docker.js");
|
|
await import("./ssh/docker-console.js");
|
|
await import("./dashboard.js");
|
|
|
|
// Initialize Guacamole server for RDP/VNC/Telnet support
|
|
const { getDb: getDbForGuac } = await import("./database/db/index.js");
|
|
const guacDb = getDbForGuac();
|
|
const guacEnabledRow = guacDb.$client
|
|
.prepare("SELECT value FROM settings WHERE key = 'guac_enabled'")
|
|
.get() as { value: string } | undefined;
|
|
const guacEnabled = guacEnabledRow
|
|
? guacEnabledRow.value !== "false"
|
|
: true;
|
|
|
|
if (process.env.ENABLE_GUACAMOLE !== "false" && guacEnabled) {
|
|
try {
|
|
await import("./guacamole/guacamole-server.js");
|
|
systemLogger.info("Guacamole server initialized", {
|
|
operation: "guac_init",
|
|
});
|
|
} catch (error) {
|
|
systemLogger.warn(
|
|
"Failed to initialize Guacamole server (guacd may not be available)",
|
|
{
|
|
operation: "guac_init_skip",
|
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
},
|
|
);
|
|
}
|
|
}
|
|
|
|
systemLogger.success("Termix backend started successfully", {
|
|
operation: "backend_init_complete",
|
|
port: process.env.PORT || 4090,
|
|
ssl: process.env.SSL_ENABLED === "true",
|
|
duration: Date.now() - initStartTime,
|
|
});
|
|
|
|
process.on("SIGINT", () => {
|
|
systemLogger.info(
|
|
"Received SIGINT signal, initiating graceful shutdown...",
|
|
{ operation: "shutdown" },
|
|
);
|
|
process.exit(0);
|
|
});
|
|
|
|
process.on("SIGTERM", () => {
|
|
systemLogger.info(
|
|
"Received SIGTERM signal, initiating graceful shutdown...",
|
|
{ operation: "shutdown" },
|
|
);
|
|
process.exit(0);
|
|
});
|
|
|
|
process.on("message", (msg: { type?: string }) => {
|
|
if (msg?.type === "shutdown") {
|
|
systemLogger.info(
|
|
"Received IPC shutdown, initiating graceful shutdown...",
|
|
{ operation: "shutdown" },
|
|
);
|
|
process.exit(0);
|
|
}
|
|
});
|
|
|
|
process.on("uncaughtException", (error) => {
|
|
systemLogger.error("Uncaught exception occurred", error, {
|
|
operation: "error_handling",
|
|
});
|
|
process.exit(1);
|
|
});
|
|
|
|
process.on("unhandledRejection", (reason) => {
|
|
systemLogger.error("Unhandled promise rejection", reason, {
|
|
operation: "error_handling",
|
|
});
|
|
process.exit(1);
|
|
});
|
|
} catch (error) {
|
|
systemLogger.error("Failed to initialize backend services", error, {
|
|
operation: "startup_failed",
|
|
});
|
|
process.exit(1);
|
|
}
|
|
})();
|