mirror of
https://github.com/originalmk/archat-server.git
synced 2024-10-03 11:16:10 +00:00
Maciej Krzyżanowski
559a33eaa7
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)
38 lines
847 B
Go
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)
|
|
}
|
|
}
|