40 lines
840 B
Go
40 lines
840 B
Go
// Command redapricot-client runs the Go client that registers routing patterns
|
|
// with a redapricot hub and forwards player traffic to real destinations.
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"log"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
"github.com/iceBear67/redapricot/client"
|
|
)
|
|
|
|
func main() {
|
|
flag.Parse()
|
|
args := flag.Args()
|
|
if len(args) < 1 {
|
|
log.Fatal("usage: redapricot-client <config.json>")
|
|
}
|
|
|
|
cfg, err := client.LoadConfig(args[0])
|
|
if err != nil {
|
|
log.Fatalf("config: %v", err)
|
|
}
|
|
|
|
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
|
|
defer cancel()
|
|
|
|
c := client.New(cfg)
|
|
if err := c.Start(ctx); err != nil {
|
|
log.Fatalf("start: %v", err)
|
|
}
|
|
log.Printf("redapricot client running; %d mapping(s) registered", len(cfg.Mappings))
|
|
|
|
<-ctx.Done()
|
|
log.Printf("shutting down")
|
|
c.Close()
|
|
}
|