fix26.2: полная UI-полировка peer/dashboard и завершение i18n
This commit is contained in:
@@ -60,7 +60,6 @@ func HmacSHA256Hex(payload string, secret string) string {
|
||||
return str
|
||||
}
|
||||
|
||||
|
||||
func DecodeBase64Key(raw string, expectedLen int) ([]byte, error) {
|
||||
raw = strings.TrimSpace(raw)
|
||||
if raw == "" {
|
||||
@@ -122,4 +121,3 @@ func DecryptAESGCM(cipherText string, key []byte) (string, error) {
|
||||
}
|
||||
return string(plain), nil
|
||||
}
|
||||
|
||||
|
||||
+20
-7
@@ -11,9 +11,21 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func resolveDiskPath() string {
|
||||
if configured := strings.TrimSpace(os.Getenv("HY2XS_DISK_PATH")); configured != "" {
|
||||
return configured
|
||||
}
|
||||
return "/"
|
||||
}
|
||||
|
||||
func GetEnvDiskPath() string {
|
||||
return strings.TrimSpace(os.Getenv("HY2XS_DISK_PATH"))
|
||||
}
|
||||
|
||||
func Exec(cmd string) (string, error) {
|
||||
command := exec.Command("bash", "-c", cmd)
|
||||
command.Env = os.Environ()
|
||||
@@ -83,22 +95,23 @@ func GetMemInfo() (*mem.VirtualMemoryStat, error) {
|
||||
}
|
||||
|
||||
func GetDiskPercent() (float64, error) {
|
||||
var err error
|
||||
parts, err := disk.Partitions(true)
|
||||
diskInfo, err := disk.Usage(parts[0].Mountpoint)
|
||||
diskInfo, err := disk.Usage(resolveDiskPath())
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
value, err := strconv.ParseFloat(fmt.Sprintf("%.1f", diskInfo.UsedPercent), 64)
|
||||
return value, err
|
||||
}
|
||||
|
||||
func GetDiskInfo() (*disk.UsageStat, error) {
|
||||
parts, err := disk.Partitions(true)
|
||||
usage, err := disk.Usage(resolveDiskPath())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(parts) == 0 {
|
||||
return nil, errors.New("disk partition not found")
|
||||
if usage == nil {
|
||||
return nil, errors.New("disk usage not found")
|
||||
}
|
||||
return disk.Usage(parts[0].Mountpoint)
|
||||
return usage, nil
|
||||
}
|
||||
|
||||
func VerifyPort(port string) error {
|
||||
|
||||
Reference in New Issue
Block a user