Add lazy_start option.

When on, the client will not attempt to connect to the server at
startup, only when a connection is initiated.
This commit is contained in:
Siyuan Ren
2022-12-30 11:55:42 +08:00
parent 1d9fa029c2
commit 604d4fc652
3 changed files with 27 additions and 15 deletions

View File

@@ -136,6 +136,7 @@ func client(config *clientConfig) {
for {
try += 1
c, err := cs.NewClient(config.Server, auth, tlsConfig, quicConfig, pktConnFunc, up, down, config.FastOpen,
config.LazyStart,
func(err error) {
if config.QuitOnDisconnect {
logrus.WithFields(logrus.Fields{
@@ -170,7 +171,12 @@ func client(config *clientConfig) {
}
}
defer client.Close()
logrus.WithField("addr", config.Server).Info("Connected")
if config.LazyStart {
logrus.WithField("addr", config.Server).Info("Option lazy_start specified. Server connection deferred.")
} else {
logrus.WithField("addr", config.Server).Info("Connected")
}
// Local
errChan := make(chan error)