mirror of
https://github.com/cedar2025/hysteria.git
synced 2025-06-08 13:29:56 +00:00
fix: incorrect speed conversion base
This commit is contained in:
parent
4c2a905892
commit
a852febc1f
@ -152,8 +152,8 @@ func formatSpeed(bytes uint32, duration time.Duration, useBytes bool) string {
|
|||||||
speed *= 8
|
speed *= 8
|
||||||
}
|
}
|
||||||
unitIndex := 0
|
unitIndex := 0
|
||||||
for speed > 1024 && unitIndex < len(units)-1 {
|
for speed > 1000 && unitIndex < len(units)-1 {
|
||||||
speed /= 1024
|
speed /= 1000
|
||||||
unitIndex++
|
unitIndex++
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%.2f %s", speed, units[unitIndex])
|
return fmt.Sprintf("%.2f %s", speed, units[unitIndex])
|
||||||
|
@ -976,8 +976,8 @@ func formatSpeed(bw Bandwidth) string {
|
|||||||
bwf := float64(bw)
|
bwf := float64(bw)
|
||||||
units := []string{"bps", "Kbps", "Mbps", "Gbps"}
|
units := []string{"bps", "Kbps", "Mbps", "Gbps"}
|
||||||
unitIndex := 0
|
unitIndex := 0
|
||||||
for bwf > 1024 && unitIndex < len(units)-1 {
|
for bwf > 1000 && unitIndex < len(units)-1 {
|
||||||
bwf /= 1024
|
bwf /= 1000
|
||||||
unitIndex++
|
unitIndex++
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%.2f %s", bwf, units[unitIndex])
|
return fmt.Sprintf("%.2f %s", bwf, units[unitIndex])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user