archat-server/main.go
Maciej Krzyżanowski 559a33eaa7 Flag specification of WS API addr and UDP API addr
From now on flags --waddr for providing WebSocket API address
(for server to run or client to connect to) and --uaddr for providing
address of UDP hole punching listener (also server and client would use it)
2024-05-27 20:10:31 +02:00

38 lines
847 B
Go

package main
import (
"flag"
"log"
"krzyzanowski.dev/archat/client"
"krzyzanowski.dev/archat/common"
"krzyzanowski.dev/archat/server"
)
func main() {
wsapiAddr := flag.String("waddr", ":8080", "An IP address of the websocket API endpoint")
udpAddr := flag.String("uaddr", ":8081", "An IP address of the UDP hole-punching listener")
runType := flag.String("run", "client", "Either one of 'client' or 'server'")
flag.Parse()
commonSettings := common.Settings{
WsapiAddr: *wsapiAddr,
UdpAddr: *udpAddr,
}
if *runType == "client" {
settings := common.ClientSettings{
Settings: commonSettings,
}
client.RunClient(settings)
} else if *runType == "server" {
settings := common.ServerSettings{
Settings: commonSettings,
}
server.RunServer(settings)
} else {
log.Fatalf("Unknown run type %s\n", *runType)
}
}