2024-03-21 21:36:25 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-05-27 18:10:31 +00:00
|
|
|
"flag"
|
2024-03-21 21:36:25 +00:00
|
|
|
"log"
|
2024-03-22 17:12:44 +00:00
|
|
|
|
2024-04-29 00:02:51 +00:00
|
|
|
"krzyzanowski.dev/archat/client"
|
2024-05-27 18:10:31 +00:00
|
|
|
"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() {
|
2024-05-27 18:10:31 +00:00
|
|
|
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
|
|
|
|
2024-05-27 18:10:31 +00:00
|
|
|
flag.Parse()
|
2024-03-21 21:36:25 +00:00
|
|
|
|
2024-05-27 18:10:31 +00:00
|
|
|
commonSettings := common.Settings{
|
|
|
|
WsapiAddr: *wsapiAddr,
|
|
|
|
UdpAddr: *udpAddr,
|
|
|
|
}
|
2024-03-21 21:36:25 +00:00
|
|
|
|
2024-05-27 18:10:31 +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 {
|
2024-05-27 18:10:31 +00:00
|
|
|
log.Fatalf("Unknown run type %s\n", *runType)
|
2024-03-21 21:36:25 +00:00
|
|
|
}
|
|
|
|
}
|