33 lines
710 B
Markdown
33 lines
710 B
Markdown
# WebSocket Relay Server
|
|
|
|
A minimal Go WebSocket relay server with SSL support for P2P connections.
|
|
|
|
## Setup
|
|
|
|
```bash
|
|
go mod tidy
|
|
# Configure via config.yaml (see config.yaml for options)
|
|
go run main.go
|
|
```
|
|
|
|
## Configuration
|
|
|
|
Edit `config.yaml` to configure:
|
|
- **Server port and TLS settings**
|
|
- **SSL certificate paths**
|
|
|
|
## Usage
|
|
|
|
- WebSocket endpoint: `/ws`
|
|
- All WebSocket messages are relayed to all connected clients
|
|
|
|
## Testing
|
|
|
|
```javascript
|
|
// For TLS enabled (default config)
|
|
const ws = new WebSocket('wss://localhost:8443/ws');
|
|
// For HTTP only
|
|
// const ws = new WebSocket('ws://localhost:8443/ws');
|
|
ws.onmessage = (event) => console.log('Received:', event.data);
|
|
ws.send('Hello from client!');
|
|
``` |