Полная зачистка legacy + закрытие fix24.1/fix24.2 + обновление логотипа
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"crypto/hmac"
|
||||
"crypto/sha256"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
@@ -42,3 +44,22 @@ func VerifyPassword(password string, storedHash string) (ok bool, legacy bool) {
|
||||
}
|
||||
return SHA224String(password) == storedHash, true
|
||||
}
|
||||
|
||||
func HmacSHA256Hex(payload string, secret string) string {
|
||||
mac := hmac.New(sha256.New, []byte(secret))
|
||||
mac.Write([]byte(payload))
|
||||
sum := mac.Sum(nil)
|
||||
str := ""
|
||||
for _, v := range sum {
|
||||
str += fmt.Sprintf("%02x", v)
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
||||
func PeerSecretDigest(rawSecret string) string {
|
||||
secretKey := strings.TrimSpace(os.Getenv("HY2XS_PEER_SECRET_KEY"))
|
||||
if secretKey == "" {
|
||||
secretKey = "hy2xs-peer-secret-key"
|
||||
}
|
||||
return HmacSHA256Hex(rawSecret, secretKey)
|
||||
}
|
||||
|
||||
@@ -78,6 +78,10 @@ func GetMemPercent() (float64, error) {
|
||||
return value, err
|
||||
}
|
||||
|
||||
func GetMemInfo() (*mem.VirtualMemoryStat, error) {
|
||||
return mem.VirtualMemory()
|
||||
}
|
||||
|
||||
func GetDiskPercent() (float64, error) {
|
||||
var err error
|
||||
parts, err := disk.Partitions(true)
|
||||
@@ -86,6 +90,17 @@ func GetDiskPercent() (float64, error) {
|
||||
return value, err
|
||||
}
|
||||
|
||||
func GetDiskInfo() (*disk.UsageStat, error) {
|
||||
parts, err := disk.Partitions(true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(parts) == 0 {
|
||||
return nil, errors.New("disk partition not found")
|
||||
}
|
||||
return disk.Usage(parts[0].Mountpoint)
|
||||
}
|
||||
|
||||
func VerifyPort(port string) error {
|
||||
if port != "" {
|
||||
value, err := strconv.ParseInt(port, 10, 64)
|
||||
|
||||
Reference in New Issue
Block a user