mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-03 09:52:50 +08:00
Add ServerQuery Login dialog
Wires up the previously-disabled "ServerQuery Login" Extras menu item with a username/password form. Sends the raw TS3 "login" command (client_login_name/client_login_password) over the existing connection - no typed builder exists for it upstream, same situation as the other raw-command features this session. Credentials are base64-encoded over the connector's stdin protocol (rather than naive space-splitting) so passwords with spaces or special characters survive the trip intact. Fire-and-forget like kick/ban: the dialog closes on submit and relies on the existing generic error/permission-error event path for feedback. Verified against the real server end-to-end - bogus credentials round-tripped through connector -> gateway -> frontend and surfaced as a clean error event (this particular server responds "NotImplemented" to post-connect query login, which is itself proof the command reached the server and got a real protocol-level reply). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
db8b5ea958
commit
0f8576ac6c
7 files changed
+123
-1
No files matched your search
@@ -1247,6 +1247,39 @@ async fn run(args: Args) -> Result<()> {
|
|||||||
}
|
}
|
||||||
_ => emit(&Event::Error { message: format!("Invalid delservergroup args: {rest}") }),
|
_ => emit(&Event::Error { message: format!("Invalid delservergroup args: {rest}") }),
|
||||||
}
|
}
|
||||||
|
} else if let Some(rest) = l.strip_prefix("serverquerylogin ") {
|
||||||
|
let mut parts = rest.trim().splitn(2, ' ');
|
||||||
|
let user_b64 = parts.next().unwrap_or("");
|
||||||
|
let pass_b64 = parts.next().unwrap_or("");
|
||||||
|
let decoded = base64::engine::general_purpose::STANDARD
|
||||||
|
.decode(user_b64)
|
||||||
|
.ok()
|
||||||
|
.and_then(|b| String::from_utf8(b).ok())
|
||||||
|
.zip(
|
||||||
|
base64::engine::general_purpose::STANDARD
|
||||||
|
.decode(pass_b64)
|
||||||
|
.ok()
|
||||||
|
.and_then(|b| String::from_utf8(b).ok()),
|
||||||
|
);
|
||||||
|
match decoded {
|
||||||
|
Some((username, password)) => {
|
||||||
|
let mut packet = OutCommand::new(
|
||||||
|
Direction::C2S,
|
||||||
|
Flags::empty(),
|
||||||
|
PacketType::Command,
|
||||||
|
"login",
|
||||||
|
);
|
||||||
|
packet.write_arg("client_login_name", &username);
|
||||||
|
packet.write_arg("client_login_password", &password);
|
||||||
|
match packet.send_with_result(&mut con) {
|
||||||
|
Ok(handle) => {
|
||||||
|
pending_messages.insert(handle, "ServerQuery Login".into());
|
||||||
|
}
|
||||||
|
Err(e) => emit(&Event::Error { message: e.to_string() }),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => emit(&Event::Error { message: "Invalid serverquerylogin args".into() }),
|
||||||
|
}
|
||||||
} else if let Some(b64) = l.strip_prefix("audio ") {
|
} else if let Some(b64) = l.strip_prefix("audio ") {
|
||||||
match base64::engine::general_purpose::STANDARD.decode(b64.trim()) {
|
match base64::engine::general_purpose::STANDARD.decode(b64.trim()) {
|
||||||
Ok(bytes) => {
|
Ok(bytes) => {
|
||||||
|
|||||||
@@ -214,6 +214,10 @@ wss.on("connection", (socket: WebSocket) => {
|
|||||||
await connection?.removeServerGroup(msg.serverGroupId, msg.clientDbId);
|
await connection?.removeServerGroup(msg.serverGroupId, msg.clientDbId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "serverQueryLogin": {
|
||||||
|
await connection?.serverQueryLogin(msg.username, msg.password);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case "disconnect": {
|
case "disconnect": {
|
||||||
await connection?.disconnect(msg.message ?? "");
|
await connection?.disconnect(msg.message ?? "");
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -573,6 +573,12 @@ export class Ts3Connection {
|
|||||||
this.child?.stdin.write(`delservergroup ${serverGroupId} ${clientDbId}\n`);
|
this.child?.stdin.write(`delservergroup ${serverGroupId} ${clientDbId}\n`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async serverQueryLogin(username: string, password: string): Promise<void> {
|
||||||
|
const u = Buffer.from(username, "utf8").toString("base64");
|
||||||
|
const p = Buffer.from(password, "utf8").toString("base64");
|
||||||
|
this.child?.stdin.write(`serverquerylogin ${u} ${p}\n`);
|
||||||
|
}
|
||||||
|
|
||||||
async sendChatMessage(message: string): Promise<void> {
|
async sendChatMessage(message: string): Promise<void> {
|
||||||
const sanitized = message.replace(/[\r\n]+/g, " ").trim();
|
const sanitized = message.replace(/[\r\n]+/g, " ").trim();
|
||||||
if (sanitized) this.child?.stdin.write(`chat ${sanitized}\n`);
|
if (sanitized) this.child?.stdin.write(`chat ${sanitized}\n`);
|
||||||
|
|||||||
@@ -1729,6 +1729,15 @@
|
|||||||
padding: 0.3rem 0.7rem;
|
padding: 0.3rem 0.7rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ts-serverquery-login-compose {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ts-serverquery-login-compose input {
|
||||||
|
min-width: 260px;
|
||||||
|
}
|
||||||
|
|
||||||
.ts-poke-compose button:hover {
|
.ts-poke-compose button:hover {
|
||||||
background: linear-gradient(var(--button-bg-hover-1), var(--button-bg-hover-2));
|
background: linear-gradient(var(--button-bg-hover-1), var(--button-bg-hover-2));
|
||||||
}
|
}
|
||||||
|
|||||||
+59
-1
@@ -3198,6 +3198,10 @@ function AppInner() {
|
|||||||
const [changeNicknameOpen, setChangeNicknameOpen] = useState(false);
|
const [changeNicknameOpen, setChangeNicknameOpen] = useState(false);
|
||||||
const [nicknameDraft, setNicknameDraft] = useState("");
|
const [nicknameDraft, setNicknameDraft] = useState("");
|
||||||
const nicknameBackdrop = useBackdropDismiss(() => setChangeNicknameOpen(false));
|
const nicknameBackdrop = useBackdropDismiss(() => setChangeNicknameOpen(false));
|
||||||
|
const [serverQueryLoginOpen, setServerQueryLoginOpen] = useState(false);
|
||||||
|
const [serverQueryUsername, setServerQueryUsername] = useState("");
|
||||||
|
const [serverQueryPassword, setServerQueryPassword] = useState("");
|
||||||
|
const serverQueryLoginBackdrop = useBackdropDismiss(() => setServerQueryLoginOpen(false));
|
||||||
const [contacts, setContacts] = useState<Contact[]>(() => loadContacts());
|
const [contacts, setContacts] = useState<Contact[]>(() => loadContacts());
|
||||||
const [contactsOpen, setContactsOpen] = useState(false);
|
const [contactsOpen, setContactsOpen] = useState(false);
|
||||||
const [recording, setRecording] = useState(false);
|
const [recording, setRecording] = useState(false);
|
||||||
@@ -4164,6 +4168,18 @@ function AppInner() {
|
|||||||
socketRef.current?.send(JSON.stringify({ type: "setNickname", nickname: newNickname }));
|
socketRef.current?.send(JSON.stringify({ type: "setNickname", nickname: newNickname }));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleServerQueryLogin = () => {
|
||||||
|
if (!serverQueryUsername.trim() || !serverQueryPassword) return;
|
||||||
|
socketRef.current?.send(
|
||||||
|
JSON.stringify({
|
||||||
|
type: "serverQueryLogin",
|
||||||
|
username: serverQueryUsername.trim(),
|
||||||
|
password: serverQueryPassword,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
setServerQueryLoginOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
const handleOutputDeviceChange = async (deviceId: string) => {
|
const handleOutputDeviceChange = async (deviceId: string) => {
|
||||||
setOutputDeviceId(deviceId);
|
setOutputDeviceId(deviceId);
|
||||||
await audioPlayerRef.current?.setOutputDevice(deviceId);
|
await audioPlayerRef.current?.setOutputDevice(deviceId);
|
||||||
@@ -4845,7 +4861,15 @@ function AppInner() {
|
|||||||
<span className="ts-menu-item-icon">📧</span>
|
<span className="ts-menu-item-icon">📧</span>
|
||||||
<span className="ts-menu-item-label">{t("menu.extras.offlineMessages")}</span>
|
<span className="ts-menu-item-label">{t("menu.extras.offlineMessages")}</span>
|
||||||
</button>
|
</button>
|
||||||
<button className="ts-menu-item" disabled>
|
<button
|
||||||
|
className="ts-menu-item"
|
||||||
|
onClick={() => {
|
||||||
|
setServerQueryUsername("");
|
||||||
|
setServerQueryPassword("");
|
||||||
|
setServerQueryLoginOpen(true);
|
||||||
|
setExtrasMenuOpen(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<span className="ts-menu-item-icon">🔑</span>
|
<span className="ts-menu-item-icon">🔑</span>
|
||||||
<span className="ts-menu-item-label">{t("menu.extras.serverQueryLogin")}</span>
|
<span className="ts-menu-item-label">{t("menu.extras.serverQueryLogin")}</span>
|
||||||
</button>
|
</button>
|
||||||
@@ -5350,6 +5374,40 @@ function AppInner() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{serverQueryLoginOpen && (
|
||||||
|
<div className="ts-poke-compose-backdrop" {...serverQueryLoginBackdrop}>
|
||||||
|
<div className="ts-poke-compose ts-serverquery-login-compose" onClick={(e) => e.stopPropagation()}>
|
||||||
|
<span>🔑 {t("menu.extras.serverQueryLogin")}</span>
|
||||||
|
<input
|
||||||
|
autoFocus
|
||||||
|
placeholder={t("serverQueryLogin.username")}
|
||||||
|
value={serverQueryUsername}
|
||||||
|
onChange={(e) => setServerQueryUsername(e.target.value)}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === "Escape") setServerQueryLoginOpen(false);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
type="password"
|
||||||
|
placeholder={t("serverQueryLogin.password")}
|
||||||
|
value={serverQueryPassword}
|
||||||
|
onChange={(e) => setServerQueryPassword(e.target.value)}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === "Enter") handleServerQueryLogin();
|
||||||
|
if (e.key === "Escape") setServerQueryLoginOpen(false);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
disabled={!serverQueryUsername.trim() || !serverQueryPassword}
|
||||||
|
onClick={handleServerQueryLogin}
|
||||||
|
>
|
||||||
|
{t("serverQueryLogin.login")}
|
||||||
|
</button>
|
||||||
|
<button onClick={() => setServerQueryLoginOpen(false)}>{t("favorites.cancel")}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{pokeTarget && (
|
{pokeTarget && (
|
||||||
<div className="ts-poke-compose-backdrop" {...pokeBackdrop}>
|
<div className="ts-poke-compose-backdrop" {...pokeBackdrop}>
|
||||||
<div className="ts-poke-compose" onClick={(e) => e.stopPropagation()}>
|
<div className="ts-poke-compose" onClick={(e) => e.stopPropagation()}>
|
||||||
|
|||||||
@@ -363,6 +363,10 @@ export class DemoSocket {
|
|||||||
this.after(200, () => this.sendChannels(this.lastNickname));
|
this.after(200, () => this.sendChannels(this.lastNickname));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "serverQueryLogin":
|
||||||
|
// No observable effect - the demo has no real ServerQuery backend to
|
||||||
|
// authenticate against.
|
||||||
|
break;
|
||||||
// "disconnect" is intentionally unhandled here: handleDisconnect() in
|
// "disconnect" is intentionally unhandled here: handleDisconnect() in
|
||||||
// App.tsx always calls socket.close() right after sending it, and
|
// App.tsx always calls socket.close() right after sending it, and
|
||||||
// close() already emits the "disconnected" event below.
|
// close() already emits the "disconnected" event below.
|
||||||
|
|||||||
@@ -400,6 +400,10 @@ const translations: Record<Lang, Record<string, string>> = {
|
|||||||
"groupAssign.empty": "Keine Gruppen vorhanden.",
|
"groupAssign.empty": "Keine Gruppen vorhanden.",
|
||||||
"groupAssign.clickToRemove": "Klicken zum Entfernen",
|
"groupAssign.clickToRemove": "Klicken zum Entfernen",
|
||||||
|
|
||||||
|
"serverQueryLogin.username": "Benutzername",
|
||||||
|
"serverQueryLogin.password": "Passwort",
|
||||||
|
"serverQueryLogin.login": "Anmelden",
|
||||||
|
|
||||||
"clientContext.privateChat": "Privater Chat",
|
"clientContext.privateChat": "Privater Chat",
|
||||||
"clientContext.poke": "Anstupsen",
|
"clientContext.poke": "Anstupsen",
|
||||||
"clientContext.copyName": "Namen kopieren",
|
"clientContext.copyName": "Namen kopieren",
|
||||||
@@ -842,6 +846,10 @@ const translations: Record<Lang, Record<string, string>> = {
|
|||||||
"groupAssign.empty": "No groups found.",
|
"groupAssign.empty": "No groups found.",
|
||||||
"groupAssign.clickToRemove": "Click to remove",
|
"groupAssign.clickToRemove": "Click to remove",
|
||||||
|
|
||||||
|
"serverQueryLogin.username": "Username",
|
||||||
|
"serverQueryLogin.password": "Password",
|
||||||
|
"serverQueryLogin.login": "Login",
|
||||||
|
|
||||||
"clientContext.privateChat": "Private chat",
|
"clientContext.privateChat": "Private chat",
|
||||||
"clientContext.poke": "Poke",
|
"clientContext.poke": "Poke",
|
||||||
"clientContext.copyName": "Copy name",
|
"clientContext.copyName": "Copy name",
|
||||||
|
|||||||
Reference in new issue
Block a user