Browse by type
A simple peer-to-peer clipboard sharing application written in Go. Share text between your desktop and mobile devices easily using a web interface and QR codes.
go build -o tvclipboard
./tvclipboard
The server will automatically detect your local IP address and start on port 8080. You'll see output like:
Server starting on port 8080
Local access: http://localhost:8080
Network access: http://192.168.1.100:8080
QR code will use: http://192.168.1.100:8080
Open in browser and scan QR code with your phone
Navigate to any of the URLs shown in the console output (localhost works fine for desktop access)
?mode=client to be ClientsHow Roles Work: - Host Mode: First client to connect. Shows QR code and received content. - Client Mode: Subsequent clients. Simplified interface for sending only. - Works for phone-to-phone, desktop-to-phone, or any combination! - If the host disconnects, the next connected client becomes the new host.
sharedKey variable in static/index.html line 312http:// (like local network), use long-press in textarea → "Paste"https:// or localhost://TV Clipboard includes a comprehensive test suite covering all major functionality:
# Run all tests
go test -v
# Run tests with coverage
go test -v -cover
# Run specific test
go test -v -run TestTokenGeneration
The test suite includes 33 tests covering:
Session Management (15 tests) - Token generation with valid format - Token encryption/decryption with AES-GCM - Token validation (valid, invalid, expired, not found) - Token cleanup of expired sessions - Private key generation from hex string or random
QR Code Generation (2 tests) - QR code endpoint returns valid PNG format - QR code URL contains proper token parameter
Client URL Handling (3 tests) - Client page responds to missing token - Client page contains error handling JavaScript
WebSocket Connection (4 tests) - Host connection without token succeeds - Host connection with token is rejected - Client connection without token is rejected when host exists - Client connection with invalid/expired token is rejected
Message Flow (9 tests) - Message broadcasting to all clients except sender - Complete message flow from client to host - Encryption compatibility with various content types - Long messages (10KB, 100KB) - Empty messages - Messages with quotes and special characters - Multiline messages - Concurrent message handling - Client reconnection
Current test coverage focuses on: - Session token generation and validation - WebSocket connection lifecycle - Message serialization/deserialization - Token-based authentication - QR code generation
Note: Client-side encryption (using Web Crypto API in JavaScript) is tested through integration tests that verify complete message flow between clients and host.
TV Clipboard includes session-based security to prevent unauthorized access:
You can configure session security using environment variables:
TVCLIPBOARD_PRIVATE_KEYTVCLIPBOARD_PRIVATE_KEY="a1b2c3d4e5f6789012345678901234567890abcdef1234567890abcdef123456"TVCLIPBOARD_SESSION_TIMEOUTTVCLIPBOARD_SESSION_TIMEOUT=15# Set custom private key and 15-minute timeout
export TVCLIPBOARD_PRIVATE_KEY="your-32-byte-hex-key-here"
export TVCLIPBOARD_SESSION_TIMEOUT=15
./tvclipboard
Session tokens are encrypted using AES-GCM with your private key: - Each token contains a random UUID and timestamp - Tokens are stored server-side and validated on connection - Expired tokens are automatically cleaned up every minute - Invalid or expired connections are rejected with HTTP 401
$ claude mcp add tvclipboard \
-- python -m otcore.mcp_server <graph>