archat-server/main.go

38 lines
847 B
Go
Raw Normal View History

2024-03-21 21:36:25 +00:00
package main
import (
"flag"
2024-03-21 21:36:25 +00:00
"log"
2024-04-29 00:02:51 +00:00
"krzyzanowski.dev/archat/client"
"krzyzanowski.dev/archat/common"
2024-04-29 00:02:51 +00:00
"krzyzanowski.dev/archat/server"
2024-03-21 21:36:25 +00:00
)
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'")
2024-03-21 21:36:25 +00:00
flag.Parse()
2024-03-21 21:36:25 +00:00
commonSettings := common.Settings{
WsapiAddr: *wsapiAddr,
UdpAddr: *udpAddr,
}
2024-03-21 21:36:25 +00:00
if *runType == "client" {
settings := common.ClientSettings{
Settings: commonSettings,
}
client.RunClient(settings)
} else if *runType == "server" {
settings := common.ServerSettings{
Settings: commonSettings,
}
server.RunServer(settings)
2024-03-21 21:36:25 +00:00
} else {
log.Fatalf("Unknown run type %s\n", *runType)
2024-03-21 21:36:25 +00:00
}
}