Skip to content

Commit

Permalink
fix: wrong number of connections in saving mode
Browse files Browse the repository at this point in the history
  • Loading branch information
r3inbowari committed May 4, 2024
1 parent 9cbad29 commit 092e492
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
26 changes: 13 additions & 13 deletions speedtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 4 additions & 2 deletions speedtest/speedtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ type UserConfig struct {
Debug bool
PingMode Proto

SavingMode bool
SavingMode bool
MaxConnections int

CityFlag string
LocationFlag string
Expand All @@ -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
Expand Down

0 comments on commit 092e492

Please sign in to comment.