The HID failure came down to the endpoint type map being indexed by endpoint number without the direction bit. A composite device can have endpoint 1 as both interrupt IN (0x81) and bulk OUT (0x01); the last one read won, so interrupt URBs were submitted as bulk and the kernel rejected them. The device attached and stayed silent. Endpoint data now comes from the raw descriptors read from /dev/bus/usb rather than sysfs, which only ever exposes the active alternate setting — a webcam's isochronous endpoints are invisible there because they only exist after SET_INTERFACE. Two sysfs parsing bugs fell out of that too: the numeric endpoint attributes are hex without a prefix (wMaxPacketSize "0040" was read as 40, not 64), and bInterval was never read at all. Reliability: three places could freeze the whole process. The share path fed io.Pipe from the WebSocket read loop, so one slow USB transfer stalled every tunnel and the keepalives with them. The relay wrote to client sockets while holding the hub lock, so one peer that stopped reading blocked routing and registration for everyone. Control transfers ran inline in the protocol loop behind a 5s timeout. Also fixed: a use-after- free where a discarded URB's memory could be collected while the kernel still owned it, a reap loop that spun at 100% CPU on ioctl errors, a missing attach timeout, a double close(done) panic, and Hash[:8] in the relay's log line, which let a client with a short hash take the server down. Adds mode "both", so one client can offer and consume devices at once. The tunnel and client-left callbacks became multicast for it: as plain fields the second manager to register silently unhooked the first. Tunnel traffic is now AES-256-GCM end to end, on the relay path as well as directly. The key is derived from the three tokens, not from the group hash — the relay is told the hash, so a key derived from it would protect nothing from the one party in the middle. Group IDs are unchanged, so existing setups keep working; only clients configured without the tokens drop to unencrypted, relay-only operation. Peers now try to connect directly, with the relay supplying the public address neither side can determine for itself. Candidates are raced because an unreachable address hangs until timeout rather than refusing. Falling back to the relay is not an error. Platform reach: cross-compiled targets for ARM, MIPS and RISC-V (the Linux client needed no code changes — usbdevfs is not architecture specific), multi-arch Docker images, an Android bridge that accepts devices over SCM_RIGHTS because apps cannot open /dev/bus/usb, and macOS builds via system_profiler enumeration. Adds a Windows KMDF filter driver under driver/windows with its Go side. UNTESTED: it has never been compiled or run, needs the WDK to build and an EV certificate to distribute. Treat it as a starting point. Adds "usb-client diag": says per machine whether sharing and using are possible, what stands in the way, and what fixes it. Reports can be uploaded to a relay to get them off machines that are awkward to copy from. 96 tests, all green under -race. Builds for linux, windows and darwin on amd64 and arm64. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
125 lines
5.5 KiB
HTML
125 lines
5.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>USB Server</title>
|
|
<link rel="stylesheet" href="/static/style.css">
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<header>
|
|
<h1>USB Server</h1>
|
|
<div class="status" id="status">Nicht verbunden</div>
|
|
</header>
|
|
|
|
<nav>
|
|
<button class="tab active" data-tab="devices">Geraete</button>
|
|
<button class="tab" data-tab="settings">Einstellungen</button>
|
|
<button class="tab" data-tab="token">Token</button>
|
|
<button class="tab" data-tab="service">Service</button>
|
|
</nav>
|
|
|
|
<!-- Devices Tab -->
|
|
<section id="tab-devices" class="tab-content active">
|
|
<div id="mode-info" class="info-box"></div>
|
|
<div id="device-list" class="device-list">
|
|
<p class="loading">Lade Geraete...</p>
|
|
</div>
|
|
</section>
|
|
|
|
<!-- Settings Tab -->
|
|
<section id="tab-settings" class="tab-content">
|
|
<form id="settings-form">
|
|
<div class="form-group">
|
|
<label for="relay-addr">Relay Server Adresse</label>
|
|
<input type="text" id="relay-addr" placeholder="ws://localhost:8443">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="hash">Hash</label>
|
|
<input type="text" id="hash" placeholder="SHA256 Hash" readonly>
|
|
<small>Wird aus den 3 Tokens berechnet</small>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="mode">Modus</label>
|
|
<select id="mode">
|
|
<option value="both">Beides (Freigeben und Empfangen)</option>
|
|
<option value="share">Nur Freigeben (Share)</option>
|
|
<option value="use">Nur Empfangen (Use)</option>
|
|
</select>
|
|
<small>Nach dem Speichern neu starten, damit der Modus wirkt</small>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="client-name">Client Name</label>
|
|
<input type="text" id="client-name" placeholder="Mein PC">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="web-port">Web-UI Port</label>
|
|
<input type="number" id="web-port" value="8080">
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="auto-connect-label">
|
|
<input type="checkbox" id="allow-force-detach">
|
|
Andere Clients duerfen Geraete trennen (Share-Modus)
|
|
</label>
|
|
<small>Erlaubt Use-Clients, Geraete die von anderen benutzt werden zu trennen</small>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="direct-port">Port fuer Direktverbindungen</label>
|
|
<input type="number" id="direct-port" min="0" max="65535" value="0">
|
|
<small>0 = zufaelliger Port. Fest setzen, wenn der Port durch eine Firewall
|
|
oder NAT weitergeleitet werden muss.</small>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="auto-connect-label">
|
|
<input type="checkbox" id="disable-direct">
|
|
Direktverbindungen deaktivieren
|
|
</label>
|
|
<small>Erzwingt, dass aller USB-Verkehr ueber den Relay laeuft. Normalerweise
|
|
verbinden sich Clients direkt, was Latenz spart und den Relay entlastet.</small>
|
|
</div>
|
|
<button type="submit" class="btn primary">Speichern</button>
|
|
</form>
|
|
</section>
|
|
|
|
<!-- Token Tab -->
|
|
<section id="tab-token" class="tab-content">
|
|
<div class="form-group">
|
|
<label for="token1">Token 1</label>
|
|
<input type="text" id="token1" placeholder="Token 1">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="token2">Token 2</label>
|
|
<input type="text" id="token2" placeholder="Token 2">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="token3">Token 3</label>
|
|
<input type="text" id="token3" placeholder="Token 3">
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Berechneter Hash</label>
|
|
<div id="computed-hash" class="hash-display">-</div>
|
|
</div>
|
|
<div class="button-group">
|
|
<button id="generate-tokens" class="btn primary">Neue Tokens Generieren</button>
|
|
<button id="apply-tokens" class="btn">Tokens Anwenden</button>
|
|
</div>
|
|
</section>
|
|
|
|
<!-- Service Tab -->
|
|
<section id="tab-service" class="tab-content">
|
|
<div class="info-box">
|
|
<p>USB Client als Systemdienst installieren fuer automatischen Start.</p>
|
|
</div>
|
|
<div class="button-group">
|
|
<button id="install-service" class="btn primary">Service Installieren</button>
|
|
<button id="uninstall-service" class="btn danger">Service Deinstallieren</button>
|
|
</div>
|
|
<div id="service-status" class="info-box" style="margin-top: 1rem;"></div>
|
|
</section>
|
|
</div>
|
|
|
|
<script src="/static/app.js"></script>
|
|
</body>
|
|
</html>
|