| 123456789101112131415161718192021 |
- package vpn
- import "fmt"
- const (
- PapSecretsPath = "/etc/ppp/pap-secrets"
- ChapSecretsPath = "/etc/ppp/chap-secrets"
- )
- func formatTrafficBytes(b uint64) string {
- const unit = 1024
- if b < unit {
- return fmt.Sprintf("%d B", b)
- }
- div, exp := uint64(unit), 0
- for n := b / unit; n >= unit; n /= unit {
- div *= unit
- exp++
- }
- return fmt.Sprintf("%.1f %ciB", float64(b)/float64(div), "KMGTPE"[exp])
- }
|