fix: hide disabled relay and report password errors

This commit is contained in:
illusia committed 2026-09-10 16:32:18 +08:00
1 parent aef1f68875
commit 6d7976e5d8
5 files changed
+12 -33

No files matched your search

+2 -2
View File
@@ -10,7 +10,7 @@
"license": "AGPL-3.0-only",
"dependencies": {
"@discordjs/opus": "^0.10.0",
"@echosixhiya/teamspeak-client": "git+https://github.com/EchoSixHIYA/teamspeak-js.git#fef0fdb",
"@echosixhiya/teamspeak-client": "git+https://github.com/EchoSixHIYA/teamspeak-js.git#a145338",
"express": "^5.2.1",
"pino": "^10.3.1",
"werift": "0.24.4",
@@ -63,7 +63,7 @@
},
"node_modules/@echosixhiya/teamspeak-client": {
"version": "0.2.4",
"resolved": "git+https://github.com/EchoSixHIYA/teamspeak-js.git#fef0fdb4d024bc640544766be704bf46eab49e85",
"resolved": "git+https://github.com/EchoSixHIYA/teamspeak-js.git#a145338c7a83044dee0951c412ad91292b570215",
"license": "MIT",
"dependencies": {
"@noble/curves": "^2.0.1"
+1 -1
View File
@@ -22,7 +22,7 @@
},
"dependencies": {
"@discordjs/opus": "^0.10.0",
"@echosixhiya/teamspeak-client": "git+https://github.com/EchoSixHIYA/teamspeak-js.git#fef0fdb",
"@echosixhiya/teamspeak-client": "git+https://github.com/EchoSixHIYA/teamspeak-js.git#a145338",
"express": "^5.2.1",
"pino": "^10.3.1",
"werift": "0.24.4",
-4
View File
@@ -145,10 +145,6 @@ export class AdminService {
};
}
hasAccelerationRelaySettings(): boolean {
return this.database.getSettings().relayConfigured;
}
getAccelerationRelayOptions(): AccelerationRelayOptions | undefined {
const settings = this.database.getSettings();
if (!settings.relayConfigured || !settings.relayEnabled || !settings.relayHost || !settings.relayTokenEncrypted) return undefined;
+6 -23
View File
@@ -8,8 +8,6 @@ import { WebSpeakDatabase } from "./persistence/database.js";
import { loadOrCreateMasterSecret } from "./security/master-secret.js";
import { AdminService } from "./admin/admin-service.js";
import { JoinTicketStore } from "./server/join-ticket.js";
import { parseTeamSpeakTarget } from "./domain/teamspeak-target.js";
import { DEFAULT_ACCELERATION_RELAY_PORT, type AccelerationRelayOptions } from "./server/acceleration-relay.js";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const ROOT_DIR = path.resolve(__dirname, "..");
@@ -51,10 +49,12 @@ async function main() {
voiceBridgeOptions: {
joinTickets,
webRtc: () => adminService.getWebRtcAudioOptions(),
acceleration: () => adminService.hasAccelerationRelaySettings() ? adminService.getAccelerationRelayOptions() : readAccelerationRelayOptions(),
accelerationName: () => adminService.hasAccelerationRelaySettings()
? adminService.getAccelerationRelayName()
: readAccelerationRelayOptions() ? "中继加速" : undefined,
// The public gateway only uses the relay configuration explicitly
// saved in the admin console. Environment variables belong to the
// standalone relay process and must never make the relay option appear
// in the visitor UI after an administrator disables it.
acceleration: () => adminService.getAccelerationRelayOptions(),
accelerationName: () => adminService.getAccelerationRelayName(),
},
adminService,
logger,
@@ -73,23 +73,6 @@ async function main() {
process.on("SIGTERM", () => shutdown("SIGTERM"));
}
function readAccelerationRelayOptions(): AccelerationRelayOptions | undefined {
const relay = process.env.WEBSPEAK_ACCELERATION_RELAY?.trim();
const token = process.env.WEBSPEAK_ACCELERATION_RELAY_TOKEN?.trim();
if (!relay && !token) return undefined;
if (!relay || !token) {
console.warn("WEBSPEAK_ACCELERATION_RELAY and WEBSPEAK_ACCELERATION_RELAY_TOKEN must be configured together");
return undefined;
}
try {
const endpoint = parseTeamSpeakTarget(relay, DEFAULT_ACCELERATION_RELAY_PORT);
return { relayHost: endpoint.host, relayPort: endpoint.port, token };
} catch {
console.warn("WEBSPEAK_ACCELERATION_RELAY is invalid; acceleration is disabled");
return undefined;
}
}
function readPackageVersion(): string {
try {
const packageJson = JSON.parse(readFileSync(path.join(ROOT_DIR, "package.json"), "utf8")) as { version?: unknown };
+3 -3
View File
@@ -203,7 +203,7 @@ const copy = {
relayTokenPlaceholder: "填写中继服务令牌",
relayTokenConfigured: "已配置令牌(留空保持不变)",
relayManagedHint: "当前使用管理控制台保存的中继配置。令牌只保存为加密密文,不会返回到页面。",
relayEnvironmentHint: "尚未接管控制台配置;若部署环境已配置兼容的中继变量,现有中继仍会继续可用。",
relayEnvironmentHint: "中继仅使用此页面保存的配置;关闭并保存后,访客页面不会显示中继选项。",
accessMode: "访客访问模式",
fixedMode: "仅限此 TeamSpeak 服务器",
fixedModeLead: "访客只需填写昵称,目标和密码由 WebSpeak 管理。",
@@ -397,7 +397,7 @@ const copy = {
relayTokenPlaceholder: "Enter the relay service token",
relayTokenConfigured: "Token configured (leave blank to keep it)",
relayManagedHint: "The relay is managed from the console. The token is stored encrypted and is never returned to the browser.",
relayEnvironmentHint: "Console relay settings are not managed yet. A relay configured through the compatible environment variables will keep working.",
relayEnvironmentHint: "The relay uses only the settings saved here. After you disable and save it, visitors will no longer see the relay option.",
accessMode: "Guest access mode",
fixedMode: "Only this TeamSpeak server",
fixedModeLead: "Guests enter only a nickname; WebSpeak manages the target and password.",
@@ -582,7 +582,7 @@ const germanCopy = {
relayTokenPlaceholder: "Token des Relay-Dienstes eingeben",
relayTokenConfigured: "Token konfiguriert (leer lassen zum Beibehalten)",
relayManagedHint: "Der Relay wird über die Konsole verwaltet. Das Token wird verschlüsselt gespeichert und nie an den Browser zurückgegeben.",
relayEnvironmentHint: "Die Relay-Konfiguration wird noch nicht über die Konsole verwaltet. Ein über kompatible Umgebungsvariablen eingerichteter Relay bleibt aktiv.",
relayEnvironmentHint: "Der Relay verwendet nur die hier gespeicherten Einstellungen. Nach dem Deaktivieren und Speichern wird die Option für Besucher ausgeblendet.",
accessMode: "Gastzugriff",
fixedMode: "Nur dieser TeamSpeak-Server",
openMode: "Andere TeamSpeak-Server erlauben",