feat: options to disable update check & fix client lazy mode

This commit is contained in:
Toby
2023-08-24 14:10:51 -07:00
parent 09355c4e21
commit 353aacfd62
4 changed files with 37 additions and 22 deletions

View File

@@ -361,15 +361,21 @@ func runClient(cmd *cobra.Command, args []string) {
logger.Fatal("failed to load client config", zap.Error(err))
}
c, err := client.NewReconnectableClient(hyConfig, connectLog, config.Lazy)
c, err := client.NewReconnectableClient(hyConfig, func(c client.Client, count int) {
connectLog(count)
// On the client side, we start checking for updates after we successfully connect
// to the server, which, depending on whether lazy mode is enabled, may or may not
// be immediately after the client starts. We don't want the update check request
// to interfere with the lazy mode option.
if count == 1 && !disableUpdateCheck {
go runCheckUpdateClient(c)
}
}, config.Lazy)
if err != nil {
logger.Fatal("failed to initialize client", zap.Error(err))
}
defer c.Close()
// TODO: add option to disable update checking
go runCheckUpdateClient(c) // TODO: fix lazy mode
uri := config.URI()
logger.Info("use this URI to share your server", zap.String("uri", uri))
if showQR {
@@ -622,12 +628,7 @@ func (f *obfsConnFactory) New(addr net.Addr) (net.PacketConn, error) {
}
func connectLog(count int) {
if count == 1 {
logger.Info("connected to server")
} else {
// Not the first time, we have reconnected
logger.Info("reconnected to server", zap.Int("count", count))
}
logger.Info("connected to server", zap.Int("count", count))
}
type socks5Logger struct{}