rpc on random port, if using local shorthand

This commit is contained in:
Norwin Roosen 2020-12-31 12:51:37 +01:00
parent 21a41cccf5
commit 8a1e56ba1b
No known key found for this signature in database
GPG Key ID: 24BC059DE24C43A3
1 changed files with 7 additions and 6 deletions

13
main.go
View File

@ -5,6 +5,7 @@ import (
"fmt"
"image"
"log"
"math/rand"
"os"
"os/signal"
"runtime/pprof"
@ -30,6 +31,7 @@ var (
func main() {
flag.Parse()
rand.Seed(time.Now().UnixNano())
task := runWithExitHandler(taskFromFlags)
if *cpuprofile != "" {
runWithProfiler(*cpuprofile, task)
@ -52,10 +54,12 @@ func taskFromFlags(stop chan bool, wg *sync.WaitGroup) {
os.Exit(1)
}
if startServer && startClient && rán == "" && hev == "" {
rán = fmt.Sprintf(":%d", rand.Intn(30000)+1000)
hev = rán
}
if startServer {
if rán == "" {
rán = ":5555"
}
r := rpc.SummonRán(rán, stop, wg)
var img *image.NRGBA
@ -71,9 +75,6 @@ func taskFromFlags(stop chan bool, wg *sync.WaitGroup) {
}
if startClient {
if hev == "" {
hev = ":5555"
}
rpc.ConnectHevring(hev, stop, wg)
}