Project-Faster / qpep

A working version of qpep standalone go client/server, designed to accelerate high-latency connections, like those provided by geostationary satellites.
https://docs.projectfaster.org
Other
3 stars 1 forks source link

Issue 5 - make configuration consistency mandatory for addresses and ports #6

Closed parvit closed 2 years ago

parvit commented 2 years ago

Checks consistency of the commandline parameters before trying to start the servers / clients so that there is less of a chance of executing with wrong values.

The checks at the moment are:

If any of these conditions are not met than the server / client automatically terminates forcing the user to reevaluate their choice of parameters, the wrong value is also indicated clearly in the log, for example:

$ .\qpep.exe -apiport 0
2022/07/30 22:15:56 Server statistics reset.
22:15:56.478267 ARGS: .\qpep.exe -apiport 0
22:15:56.478781 {
 "AckElicitingPacketsBeforeAck": 10,
 "AckDecimationDenominator": 4,
 "InitialCongestionWindowPackets": 4,
 "MultiStream": true,
 "VarAckDelay": 0.25,
 "MaxAckDelay": 25,
 "MinReceivedBeforeAckDecimation": 100,
 "ClientFlag": false,
 "GatewayIP": "198.18.0.254",
 "GatewayPort": 443,
 "GatewayAPIPort": 0,
 "ListenIP": "127.0.0.1",
 "ListenPort": 9443,
 "WinDivertThreads": 1,
 "Verbose": false
}
22:15:56.480873 Running Server
22:15:56.481388 Invalid parameter api port as port [1-65536]: 0
22:15:56.482802 PANIC: configuration was unsuccessfull
22:15:56.481388 Opening API Server on: 127.0.0.1:0
goroutine 6 [running]:
runtime/debug.Stack(0xc00005c050, 0x2, 0xc000099d40)
        c:/home/dev/go_1.16.1/src/runtime/debug/stack.go:24 +0xa5
runtime/debug.PrintStack()
        c:/home/dev/go_1.16.1/src/runtime/debug/stack.go:16 +0x29
github.com/parvit/qpep/server.RunServer.func1(0xc00004eeb0)
        C:/home/dev/src/github.com/parvit/qpep-faster/server/server.go:47 +0xca
panic(0x1017f00, 0xc00004ec30)
        c:/home/dev/go_1.16.1/src/runtime/panic.go:965 +0x1c7
github.com/parvit/qpep/shared.AssertParamPort(...)
        C:/home/dev/src/github.com/parvit/qpep-faster/shared/params_validation.go:19
github.com/parvit/qpep/server.validateConfiguration(0x0, 0x0)
        C:/home/dev/src/github.com/parvit/qpep-faster/server/server.go:246 +0x2f9
github.com/parvit/qpep/server.RunServer(0x111c578, 0xc00002c780, 0xc00004eeb0)
        C:/home/dev/src/github.com/parvit/qpep-faster/server/server.go:56 +0x77
created by main.runAsServer
        C:/home/dev/src/github.com/parvit/qpep-faster/main.go:99 +0x9e
22:15:56.501325 Shutdown...
22:15:56.502971 [0000] Windivert engine must first be initialized
22:15:56.501840 Error running API server: http: Server closed
22:15:56.504062 Closed API Server
22:15:56.504062 1
22:15:57.507317 Exiting...

Which should be sufficient to cover most user error configurations that can be catched.

Please test and review, if there's positive feedback i'll merge.