Support importing native TeamSpeak .ini identity files

The connector now parses --identity either as our own JSON blob or as a
raw TS3 identity string ("<counter>V<base64-key>", the format inside a
native client's exported .ini and in teamspeak:// URLs) via tsproto's
Identity::new_from_str, which already handles both.

The web client's "Identitäten" > Importieren now recognizes a native
.ini file (looks for a [Identity] section), unescapes its \xHH-escaped
name field, and pulls out id/identity/nickname/phonetic_nickname directly
- no conversion needed, the raw identity string is stored as-is and self-
migrates to our JSON format after the first successful connect (same as
any other imported/created identity).

Verified with a real exported .ini file: parsing extracts the right
name/nickname/blob, and connecting the connector directly against the
real server with that exact identity string succeeds and is recognized
as the already-known account (its own channel/server group, not the
default guest group) - not just a fresh/anonymous identity.
This commit is contained in:
Moepchi committed 2026-08-06 00:48:42 +02:00
1 parent 17899ae137
commit 53ccb22189
2 files changed
+41 -2

No files matched your search

+36 -1
View File
@@ -2864,7 +2864,7 @@ function IdentitiesDialog({
<input
ref={importInputRef}
type="file"
accept=".json,application/json"
accept=".json,.ini,application/json,text/plain"
style={{ display: "none" }}
onChange={(e) => {
const file = e.target.files?.[0];
@@ -5345,10 +5345,45 @@ function AppInner() {
URL.revokeObjectURL(url);
};
/** Parses the native client's identity .ini format:
* [Identity]
* id=<name, with \xHH-escaped non-ASCII chars>
* identity="<counter>V<base64 key>"
* nickname=<...>
* phonetic_nickname=<...>
* Returns null if it doesn't look like one. */
const parseIniIdentity = (text: string): { name: string; nickname: string; phonetic: string; blob: string } | null => {
if (!/^\s*\[Identity\]/im.test(text)) return null;
const fields: Record<string, string> = {};
for (const line of text.split(/\r?\n/)) {
const m = line.match(/^(\w+)\s*=\s*(.*)$/);
if (!m) continue;
let value = m[2].trim();
if (value.startsWith('"') && value.endsWith('"')) value = value.slice(1, -1);
// The native client escapes non-ASCII bytes in this file as \xHH.
value = value.replace(/\\x([0-9a-fA-F]{2})/g, (_, hex) => String.fromCharCode(parseInt(hex, 16)));
fields[m[1]] = value;
}
if (!fields.identity) return null;
return { name: fields.id ?? "", nickname: fields.nickname ?? "", phonetic: fields.phonetic_nickname ?? "", blob: fields.identity };
};
const handleImportIdentity = (file: File) => {
const reader = new FileReader();
reader.onload = () => {
const text = (reader.result as string).trim();
const ini = parseIniIdentity(text);
if (ini) {
const identity: Identity = {
id: crypto.randomUUID(),
name: ini.name || file.name.replace(/\.ini$/i, "") || t("identities.newName"),
nickname: ini.nickname,
phoneticName: ini.phonetic,
blob: ini.blob,
};
setIdentities((prev) => [...prev, identity]);
return;
}
try {
JSON.parse(text);
} catch {