adding config-file arg
This commit is contained in:
parent
983c4195e0
commit
9ad38190a5
@ -7,7 +7,7 @@ A minimal Go WebSocket relay server with SSL support for P2P connections.
|
|||||||
```bash
|
```bash
|
||||||
go mod tidy
|
go mod tidy
|
||||||
# Configure via config.yaml (see config.yaml for options)
|
# Configure via config.yaml (see config.yaml for options)
|
||||||
go run main.go
|
go run main.go --config-file=./config.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
@ -18,16 +18,16 @@ Edit `config.yaml` to configure:
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
- WebSocket endpoint: `/ws`
|
- WebSocket endpoint: `/`
|
||||||
- All WebSocket messages are relayed to all connected clients
|
- All WebSocket messages are relayed to all connected clients
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// For TLS enabled (default config)
|
// For TLS enabled (default config)
|
||||||
const ws = new WebSocket('wss://localhost:8443/ws');
|
const ws = new WebSocket('wss://localhost:8443/');
|
||||||
// For HTTP only
|
// For HTTP only
|
||||||
// const ws = new WebSocket('ws://localhost:8443/ws');
|
// const ws = new WebSocket('ws://localhost:8443/');
|
||||||
ws.onmessage = (event) => console.log('Received:', event.data);
|
ws.onmessage = (event) => console.log('Received:', event.data);
|
||||||
ws.send('Hello from client!');
|
ws.send('Hello from client!');
|
||||||
```
|
```
|
||||||
6
main.go
6
main.go
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -11,7 +12,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cfg, err := config.Load("config.yaml")
|
configFile := flag.String("config-file", "config.yaml", "Path to configuration file")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
cfg, err := config.Load(*configFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("Failed to load config:", err)
|
log.Fatal("Failed to load config:", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user