mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-01 17:02:49 +08:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b856094b48 | ||
|
|
f67d171001 | ||
|
|
762554b39d | ||
|
|
e96eb62d90 |
No files matched your search
+47
-1
@@ -902,6 +902,29 @@ async fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Stable per-identity HWID in the TeamSpeak shape (`<32 hex>,<32 hex>`),
|
||||
/// derived from the identity's UID hash so it survives reconnects.
|
||||
fn hardware_id_for(uid: &[u8]) -> String {
|
||||
let hex = |bytes: &[u8]| bytes.iter().map(|b| format!("{b:02x}")).collect::<String>();
|
||||
let mut padded = uid.to_vec();
|
||||
padded.resize(20, 0);
|
||||
format!("{},{}", hex(&padded[..16]), hex(&padded[4..20]))
|
||||
}
|
||||
|
||||
/// Text for a `banclient` the server refused. Permission ids differ between
|
||||
/// TeamSpeak and TeaSpeak, so the usual causes are named instead of the id.
|
||||
fn ban_failure_message(e: &tsclientlib::CommandError) -> String {
|
||||
match e.missing_permission {
|
||||
Some(perm) => format!(
|
||||
"Ban failed: missing permission (id {}). Usual causes: a permanent ban (duration 0) \
|
||||
without unlimited i_client_ban_max_bantime, a duration above it, too little \
|
||||
i_client_ban_power, or the target has b_client_ignore_bans.",
|
||||
perm.0
|
||||
),
|
||||
None => format!("Ban failed: {e}"),
|
||||
}
|
||||
}
|
||||
|
||||
/// VoySpeak (formerly GreenTeaSpeak) servers report versions like `2.5.1 [Build: …]`.
|
||||
/// Classic TeaSpeak reports `TeaSpeak 1.4.21-beta [Build: …]` — not a GTS host.
|
||||
/// Classic TeamSpeak 3 reports `3.13.8 [Build: …]` — must not use GTS labels.
|
||||
@@ -1015,7 +1038,13 @@ async fn run(args: Args) -> Result<()> {
|
||||
.and_then(|s| serde_json::from_str::<Identity>(s).ok().or_else(|| Identity::new_from_str(s).ok()))
|
||||
.unwrap_or_else(Identity::create);
|
||||
let identity_str = serde_json::to_string(&identity).unwrap();
|
||||
let mut con_config = Connection::build(args.address).name(args.nickname).identity(identity);
|
||||
// Without this every web user sends tsclientlib's built-in HWID, so a
|
||||
// hardware-id ban on one web user would lock out all of them.
|
||||
let hardware_id = hardware_id_for(&identity.key().to_pub().get_uid_no_base64());
|
||||
let mut con_config = Connection::build(args.address)
|
||||
.name(args.nickname)
|
||||
.hardware_id(hardware_id)
|
||||
.identity(identity);
|
||||
let server_type = match args.server_type.as_str() {
|
||||
"teaspeak" => ServerType::Teaspeak,
|
||||
"teamspeak" => ServerType::Teamspeak,
|
||||
@@ -2777,6 +2806,14 @@ async fn run(args: Args) -> Result<()> {
|
||||
} else {
|
||||
emit(&Event::Error { message: format!("{label} failed: {e}") });
|
||||
}
|
||||
} else if label == "Ban client" {
|
||||
// A rejected ban must be visible: the UI only knows it sent one.
|
||||
emit(&Event::Error { message: ban_failure_message(&e) });
|
||||
if e.missing_permission.is_some() {
|
||||
emit(&Event::ServerLog {
|
||||
entry: ServerLogEntry::PermissionError { action: label },
|
||||
});
|
||||
}
|
||||
} else if e.missing_permission.is_some() {
|
||||
emit(&Event::ServerLog {
|
||||
entry: ServerLogEntry::PermissionError { action: label },
|
||||
@@ -3311,6 +3348,15 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hardware_id_is_stable_and_per_identity() {
|
||||
let a = hardware_id_for(&[1u8; 20]);
|
||||
assert_eq!(a, hardware_id_for(&[1u8; 20]));
|
||||
assert_ne!(a, hardware_id_for(&[2u8; 20]));
|
||||
let (left, right) = a.split_once(',').unwrap();
|
||||
assert_eq!((left.len(), right.len()), (32, 32));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn upload_chunks_assemble_in_order_and_reject_gaps() {
|
||||
let mut partials = HashMap::new();
|
||||
|
||||
+44
-4
@@ -2042,6 +2042,50 @@
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* Disconnected/connecting: centered in the otherwise empty tree panel. */
|
||||
.ts-tree-panel > .ts-tree-empty:only-child {
|
||||
box-sizing: border-box;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.ts-tree-empty > button,
|
||||
.ts-tree-empty > a {
|
||||
display: block;
|
||||
margin-top: 0.75rem;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.ts-tree-empty > .ts-mobile-connect-btn {
|
||||
flex: none;
|
||||
min-height: 40px;
|
||||
padding: 0 1.5rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ts-tree-empty-demo {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.ts-spinner {
|
||||
display: inline-block;
|
||||
width: 0.9em;
|
||||
height: 0.9em;
|
||||
vertical-align: -0.1em;
|
||||
border: 2px solid var(--text-muted);
|
||||
border-top-color: transparent;
|
||||
border-radius: 50%;
|
||||
animation: ts-spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes ts-spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.ts-tree-list {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
@@ -5424,10 +5468,6 @@ input.ts-identities-uid {
|
||||
|
||||
/* Disconnected: the header already says so, keep the panel calm and centered. */
|
||||
.ts-app.ts-mobile .ts-tree-panel > .ts-tree-empty:only-child {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-style: normal;
|
||||
font-size: 16px;
|
||||
color: var(--text-muted);
|
||||
|
||||
+38
-9
@@ -236,6 +236,7 @@ import {
|
||||
} from "./ConnectionTabs";
|
||||
import { BARE_URL_REGEX, renderBbcode, wrapUrls } from "./lib/bbcode";
|
||||
import { parseChannelName, spacerDisplayName } from "./lib/spacer";
|
||||
import { channelsInTreeOrder } from "./lib/channelOrder";
|
||||
import akimoPhoto from "./assets/akimo.jpg";
|
||||
import {
|
||||
applyParkedGatewayEvent,
|
||||
@@ -2332,6 +2333,7 @@ function ConnectDialog({
|
||||
<input
|
||||
autoFocus
|
||||
value={host}
|
||||
placeholder={t("connect.hostPlaceholder")}
|
||||
disabled={SERVER_CHOICES.length === 1}
|
||||
onChange={(e) => onHostChange(e.target.value)}
|
||||
/>
|
||||
@@ -4451,7 +4453,7 @@ function MoveClientDialog({
|
||||
}) {
|
||||
const t = useT();
|
||||
const backdrop = useBackdropDismiss(onClose);
|
||||
const movable = [...channels].sort((a, b) => a.order - b.order);
|
||||
const movable = channelsInTreeOrder(channels);
|
||||
|
||||
return (
|
||||
<div className="ts-dialog-backdrop" {...backdrop}>
|
||||
@@ -4469,7 +4471,7 @@ function MoveClientDialog({
|
||||
<div className="ts-connection-info-loading">{t("moveClient.empty")}</div>
|
||||
) : (
|
||||
<ul className="ts-group-assign-list">
|
||||
{movable.map((ch) => {
|
||||
{movable.map(({ channel: ch, depth }) => {
|
||||
const current = ch.id === currentChannelId;
|
||||
const spacer = spacerDisplayName(ch.name, ch.parent === 0);
|
||||
const label = spacer.isSpacer
|
||||
@@ -4481,6 +4483,7 @@ function MoveClientDialog({
|
||||
className={`ts-menu-item${current ? " ts-group-assign-current" : ""}`}
|
||||
disabled={current || spacer.isSpacer}
|
||||
onClick={() => onSelect(ch.id)}
|
||||
style={depth > 0 ? { paddingLeft: `${depth * 1.25}em` } : undefined}
|
||||
>
|
||||
<span className="ts-menu-item-icon">
|
||||
{current ? "✔️" : spacer.isSpacer ? "➖" : "📁"}
|
||||
@@ -5124,8 +5127,8 @@ function PermissionsEditorDialog({
|
||||
))}
|
||||
{(scope === "channel" || scope === "channelclient") && (
|
||||
<ul className="ts-perms-editor-list">
|
||||
{channels.map((c) => (
|
||||
<li key={c.id}>
|
||||
{channelsInTreeOrder(channels).map(({ channel: c, depth }) => (
|
||||
<li key={c.id} style={depth > 0 ? { paddingLeft: `${depth * 1.25}em` } : undefined}>
|
||||
<button
|
||||
className={`ts-link-button${channelId === c.id ? " ts-perms-editor-selected" : ""}`}
|
||||
onClick={() => {
|
||||
@@ -8952,7 +8955,7 @@ function AppInner() {
|
||||
const [host, setHost] = useState(
|
||||
() =>
|
||||
localStorage.getItem(LAST_HOST_KEY) ??
|
||||
(DEMO_MODE ? DEMO_HOST : loadDesignTheme() === "nova" ? "" : "localhost")
|
||||
(DEMO_MODE ? DEMO_HOST : "")
|
||||
);
|
||||
const [nickname, setNickname] = useState(
|
||||
() => localStorage.getItem(LAST_NICKNAME_KEY) ?? (DEMO_MODE ? "Guest" : "")
|
||||
@@ -12726,7 +12729,8 @@ function AppInner() {
|
||||
reason: banReason,
|
||||
})
|
||||
);
|
||||
logClient("info", "Moderation", `Banned ${banTarget.name}`);
|
||||
// Only a request: the server may still refuse it (an error event follows then).
|
||||
logClient("info", "Moderation", `Ban requested for ${banTarget.name}`);
|
||||
setBanTarget(null);
|
||||
setBanReason("");
|
||||
setBanSeconds("0");
|
||||
@@ -13502,8 +13506,12 @@ function AppInner() {
|
||||
{whisperMenuOpen && (
|
||||
<div className="ts-menu ts-menu-away" ref={focusFirstItem} onKeyDown={handleMenuKeyDown}>
|
||||
<div className="ts-context-menu-title">{t("whisper.channels")}</div>
|
||||
{channels.map((ch) => (
|
||||
<label key={ch.id} className="ts-menu-item">
|
||||
{channelsInTreeOrder(channels).map(({ channel: ch, depth }) => (
|
||||
<label
|
||||
key={ch.id}
|
||||
className="ts-menu-item"
|
||||
style={depth > 0 ? { paddingLeft: `${depth * 1.25}em` } : undefined}
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={whisperChannelIds.has(ch.id)}
|
||||
@@ -14726,7 +14734,28 @@ function AppInner() {
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<div className="ts-tree-empty">{t("tree.notConnected")}</div>
|
||||
<div className="ts-tree-empty">
|
||||
{connecting ? (
|
||||
<>
|
||||
<span className="ts-spinner" aria-hidden="true" /> {t("tree.connectingTo", { host })}
|
||||
<button onClick={handleDisconnect}>{t("connect.cancel")}</button>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
{t("tree.notConnected")}
|
||||
{!mobile && (
|
||||
<button className="ts-mobile-connect-btn" onClick={() => setConnectDialogOpen(true)}>
|
||||
{t("menu.connections.connect")}
|
||||
</button>
|
||||
)}
|
||||
{!DEMO_MODE && (
|
||||
<a className="ts-tree-empty-demo" href="https://demo.webspeak3.de" target="_blank" rel="noreferrer">
|
||||
{t("tree.tryDemo")}
|
||||
</a>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/** Minimal shape needed to lay channels out like the channel tree. */
|
||||
export interface OrderedChannelLike {
|
||||
id: number;
|
||||
parent: number;
|
||||
/** Position among the siblings of the same parent (not a global index). */
|
||||
order: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flattens channels in channel-tree order: each parent is followed by its
|
||||
* subchannels (recursively), siblings sorted by `order`. `order` is only
|
||||
* meaningful between siblings, so a flat sort by it interleaves the levels.
|
||||
* Channels whose parent is missing are appended at the end as roots.
|
||||
*/
|
||||
export function channelsInTreeOrder<T extends OrderedChannelLike>(
|
||||
channels: readonly T[],
|
||||
): { channel: T; depth: number }[] {
|
||||
const byParent = new Map<number, T[]>();
|
||||
for (const ch of channels) {
|
||||
const list = byParent.get(ch.parent);
|
||||
if (list) list.push(ch);
|
||||
else byParent.set(ch.parent, [ch]);
|
||||
}
|
||||
for (const list of byParent.values()) list.sort((a, b) => a.order - b.order || a.id - b.id);
|
||||
|
||||
const out: { channel: T; depth: number }[] = [];
|
||||
const seen = new Set<number>();
|
||||
const walk = (parent: number, depth: number) => {
|
||||
for (const ch of byParent.get(parent) ?? []) {
|
||||
if (seen.has(ch.id)) continue;
|
||||
seen.add(ch.id);
|
||||
out.push({ channel: ch, depth });
|
||||
walk(ch.id, depth + 1);
|
||||
}
|
||||
};
|
||||
walk(0, 0);
|
||||
// Orphans (parent not in the list) and anything in a parent cycle.
|
||||
for (const ch of channels) {
|
||||
if (seen.has(ch.id)) continue;
|
||||
const orphanParent = ch.parent;
|
||||
for (const sibling of byParent.get(orphanParent) ?? []) {
|
||||
if (seen.has(sibling.id)) continue;
|
||||
seen.add(sibling.id);
|
||||
out.push({ channel: sibling, depth: 0 });
|
||||
walk(sibling.id, 1);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -112,6 +112,7 @@
|
||||
"connect.title": "Připojit",
|
||||
"connect.novaSubtitle": "WebSpeak3 běží celý v prohlížeči — není potřeba nic stahovat",
|
||||
"connect.serverAddress": "Přezdívka nebo adresa serveru:",
|
||||
"connect.hostPlaceholder": "např. ts.example.com:9987",
|
||||
"connect.serverPassword": "Heslo serveru:",
|
||||
"connect.nickname": "Přezdívka:",
|
||||
"connect.phoneticNickname": "Fonetická přezdívka:",
|
||||
@@ -476,6 +477,8 @@
|
||||
"tree.search": "Hledat kanály a uživatele",
|
||||
"tree.label": "Kanály",
|
||||
"tree.notConnected": "Nepřipojeno",
|
||||
"tree.connectingTo": "Připojování k {host}…",
|
||||
"tree.tryDemo": "Nemáte server? Vyzkoušejte demo",
|
||||
"tree.clickToSelect": "Kliknutím vyberete, dvojklikem se připojíte",
|
||||
"tree.clickToJoin": "Dvojklikem se připojíte",
|
||||
"tree.joinNotConnected": "Nepřipojeno — nelze přepnout kanál",
|
||||
|
||||
@@ -112,6 +112,7 @@
|
||||
"connect.title": "Verbinden",
|
||||
"connect.novaSubtitle": "WebSpeak3 läuft komplett im Browser — kein Download nötig",
|
||||
"connect.serverAddress": "Server Nickname oder Adresse:",
|
||||
"connect.hostPlaceholder": "z. B. ts.beispiel.de:9987",
|
||||
"connect.serverPassword": "Server Passwort:",
|
||||
"connect.nickname": "Nickname:",
|
||||
"connect.phoneticNickname": "Phonetischer Nickname:",
|
||||
@@ -476,6 +477,8 @@
|
||||
"tree.search": "Kanäle und Nutzer suchen",
|
||||
"tree.label": "Kanäle",
|
||||
"tree.notConnected": "Nicht verbunden",
|
||||
"tree.connectingTo": "Verbinde mit {host}…",
|
||||
"tree.tryDemo": "Kein Server? Probier die Demo",
|
||||
"tree.clickToSelect": "Klicken zum Auswählen, Doppelklick zum Beitreten",
|
||||
"tree.clickToJoin": "Doppelklick zum Beitreten",
|
||||
"tree.joinNotConnected": "Nicht verbunden — Channel-Wechsel nicht möglich",
|
||||
|
||||
@@ -112,6 +112,7 @@
|
||||
"connect.title": "Connect",
|
||||
"connect.novaSubtitle": "WebSpeak3 runs entirely in the browser — no download needed",
|
||||
"connect.serverAddress": "Server nickname or address:",
|
||||
"connect.hostPlaceholder": "e.g. ts.example.com:9987",
|
||||
"connect.serverPassword": "Server password:",
|
||||
"connect.nickname": "Nickname:",
|
||||
"connect.phoneticNickname": "Phonetic nickname:",
|
||||
@@ -476,6 +477,8 @@
|
||||
"tree.search": "Search channels and users",
|
||||
"tree.label": "Channels",
|
||||
"tree.notConnected": "Not connected",
|
||||
"tree.connectingTo": "Connecting to {host}…",
|
||||
"tree.tryDemo": "No server? Try the demo",
|
||||
"tree.clickToSelect": "Click to select, double-click to join",
|
||||
"tree.clickToJoin": "Double-click to join",
|
||||
"tree.joinNotConnected": "Not connected — cannot switch channel",
|
||||
|
||||
@@ -112,6 +112,7 @@
|
||||
"connect.title": "اتصال",
|
||||
"connect.novaSubtitle": "WebSpeak3 بهطور کامل در مرورگر اجرا میشود — بدون نیاز به دانلود",
|
||||
"connect.serverAddress": "نام مستعار یا آدرس سرور:",
|
||||
"connect.hostPlaceholder": "مثلاً ts.example.com:9987",
|
||||
"connect.serverPassword": "رمز عبور سرور:",
|
||||
"connect.nickname": "نام مستعار:",
|
||||
"connect.phoneticNickname": "تلفظ نام مستعار:",
|
||||
@@ -475,6 +476,8 @@
|
||||
"tree.search": "جستجوی کانالها و کاربران",
|
||||
"tree.label": "کانالها",
|
||||
"tree.notConnected": "متصل نیست",
|
||||
"tree.connectingTo": "در حال اتصال به {host}…",
|
||||
"tree.tryDemo": "سروری ندارید؟ دمو را امتحان کنید",
|
||||
"tree.clickToSelect": "برای انتخاب کلیک کن، برای ورود دوبار کلیک کن",
|
||||
"tree.clickToJoin": "برای ورود دوبار کلیک کن",
|
||||
"tree.joinNotConnected": "متصل نیست — نمیتوان کانال را تغییر داد",
|
||||
|
||||
@@ -112,6 +112,7 @@
|
||||
"connect.title": "Подключение",
|
||||
"connect.novaSubtitle": "WebSpeak3 работает полностью в браузере — ничего скачивать не нужно",
|
||||
"connect.serverAddress": "Имя или адрес сервера:",
|
||||
"connect.hostPlaceholder": "например, ts.example.com:9987",
|
||||
"connect.serverPassword": "Пароль сервера:",
|
||||
"connect.nickname": "Никнейм:",
|
||||
"connect.phoneticNickname": "Фонетический никнейм:",
|
||||
@@ -476,6 +477,8 @@
|
||||
"tree.search": "Поиск каналов и пользователей",
|
||||
"tree.label": "Каналы",
|
||||
"tree.notConnected": "Нет подключения",
|
||||
"tree.connectingTo": "Подключение к {host}…",
|
||||
"tree.tryDemo": "Нет сервера? Попробуйте демо",
|
||||
"tree.clickToSelect": "Щелчок – выбрать, двойной щелчок – войти",
|
||||
"tree.clickToJoin": "Двойной щелчок – войти",
|
||||
"tree.joinNotConnected": "Нет подключения — нельзя сменить канал",
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
"away.setGlobalStatus": "设置全局离开状态",
|
||||
"connect.title": "连接",
|
||||
"connect.serverAddress": "服务器昵称或地址:",
|
||||
"connect.hostPlaceholder": "例如 ts.example.com:9987",
|
||||
"connect.serverPassword": "服务器密码:",
|
||||
"connect.nickname": "昵称:",
|
||||
"connect.phoneticNickname": "昵称读音:",
|
||||
@@ -368,6 +369,8 @@
|
||||
"tree.search": "搜索频道和用户",
|
||||
"tree.label": "频道",
|
||||
"tree.notConnected": "未连接",
|
||||
"tree.connectingTo": "正在连接到 {host}…",
|
||||
"tree.tryDemo": "没有服务器?试试演示版",
|
||||
"tree.clickToSelect": "单击选择,双击加入",
|
||||
"tree.clickToJoin": "双击加入",
|
||||
"tree.joinNotConnected": "未连接 — 无法切换频道",
|
||||
|
||||
Reference in new issue
Block a user