diff --git a/speedtest.go b/speedtest.go index 047a358..d6c8d5b 100644 --- a/speedtest.go +++ b/speedtest.go @@ -47,20 +47,20 @@ func main() { // 0. speed test setting var speedtestClient = speedtest.New(speedtest.WithUserConfig( &speedtest.UserConfig{ - UserAgent: *userAgent, - Proxy: *proxy, - Source: *source, - DnsBindSource: *dnsBindSource, - Debug: *debug, - PingMode: parseProto(*pingMode), // TCP as default - SavingMode: *savingMode, - CityFlag: *city, - LocationFlag: *location, - Keyword: *search, - NoDownload: *noDownload, - NoUpload: *noUpload, + UserAgent: *userAgent, + Proxy: *proxy, + Source: *source, + DnsBindSource: *dnsBindSource, + Debug: *debug, + PingMode: parseProto(*pingMode), // TCP as default + SavingMode: *savingMode, + MaxConnections: *thread, + CityFlag: *city, + LocationFlag: *location, + Keyword: *search, + NoDownload: *noDownload, + NoUpload: *noUpload, })) - speedtestClient.SetNThread(*thread) if *showCityList { speedtest.PrintCityList() diff --git a/speedtest/speedtest.go b/speedtest/speedtest.go index 371c9eb..3ba393d 100644 --- a/speedtest/speedtest.go +++ b/speedtest/speedtest.go @@ -46,7 +46,8 @@ type UserConfig struct { Debug bool PingMode Proto - SavingMode bool + SavingMode bool + MaxConnections int CityFlag string LocationFlag string @@ -72,8 +73,9 @@ func (s *Speedtest) NewUserConfig(uc *UserConfig) { } if uc.SavingMode { - s.SetNThread(1) // Set the number of concurrent connections to 1 + uc.MaxConnections = 1 // Set the number of concurrent connections to 1 } + s.SetNThread(uc.MaxConnections) if len(uc.CityFlag) > 0 { var err error