Fix25.1: стабилизирован auth_id flow и unlimited-семантика, усилен bootstrap secrets

This commit is contained in:
2026-05-09 00:45:20 +05:00
parent d73bab99ec
commit 7a64d76d08
4 changed files with 83 additions and 26 deletions
+12 -6
View File
@@ -5,7 +5,6 @@ import (
"hy2xs-admin/dao"
"hy2xs-admin/model/constant"
"hy2xs-admin/proxy"
"hy2xs-admin/util"
"net"
"net/url"
"os"
@@ -36,8 +35,15 @@ func Hysteria2Auth(conPass string) (int64, string, error) {
}
now := time.Now().UnixMilli()
secretDigest := util.PeerSecretDigest(conPass)
peer, err := dao.GetPeer("secret_digest = ? and disabled = 0 and (quota_bytes < 0 or quota_bytes > download_bytes + upload_bytes) and ? < expires_at and ? > banned_until", secretDigest, now, now)
secretDigest, digestErr := PeerSecretDigest(conPass)
if digestErr != nil {
return 0, "", digestErr
}
peer, err := dao.GetPeer(`secret_digest = ?
and disabled = 0
and (quota_bytes < 0 or quota_bytes > download_bytes + upload_bytes)
and (expires_at = 0 or ? < expires_at)
and ? > banned_until`, secretDigest, now, now)
if err != nil {
return 0, "", err
}
@@ -47,12 +53,12 @@ func Hysteria2Auth(conPass string) (int64, string, error) {
if err != nil {
return 0, "", err
}
device, exist := onlineUsers[*peer.Name]
device, exist := onlineUsers[*peer.AuthId]
if exist && *peer.MaxDevices <= device {
return 0, "", errors.New("device limited")
}
return *peer.Id, *peer.Name, nil
return *peer.Id, *peer.AuthId, nil
}
func Hysteria2Online() (map[string]int64, error) {
@@ -88,7 +94,7 @@ func Hysteria2Kick(ids []int64, kickUtilTime int64) error {
}
var keys []string
for _, item := range peers {
keys = append(keys, *item.Name)
keys = append(keys, *item.AuthId)
}
apiPort, err := GetHysteria2ApiPort()
if err != nil {