feat: Info 字段前缀可以通过 meta 设置

This commit is contained in:
Mmx233
2023-12-01 00:25:18 +08:00
parent 1f535b3feb
commit 282a2e97bd
3 changed files with 10 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ type LoginMeta struct {
Enc string `json:"enc" yaml:"enc"`
OS string `json:"os" yaml:"os"`
Name string `json:"name" yaml:"name"`
InfoPrefix string `json:"info_prefix" yaml:"info_prefix"`
DoubleStack bool `json:"double_stack" json:"double_stack"`
}

View File

@@ -3,6 +3,7 @@ package srun
import (
"encoding/json"
"errors"
"fmt"
log "github.com/sirupsen/logrus"
"net/http"
)
@@ -83,7 +84,12 @@ func (c Srun) DoLogin(clientIP string) error {
if err != nil {
return err
}
EncryptedInfo := "{SRBX1}" + Base64(XEncode(string(info), tokenStr))
var infoPrefix string
if c.LoginInfo.Meta.InfoPrefix != "" {
infoPrefix = fmt.Sprintf("{%s}", c.LoginInfo.Meta.InfoPrefix)
}
EncryptedInfo := infoPrefix + Base64(XEncode(string(info), tokenStr))
Md5Str := Md5(tokenStr)
EncryptedMd5 := "{MD5}" + Md5Str
EncryptedChkstr := Sha1(
@@ -99,6 +105,7 @@ func (c Srun) DoLogin(clientIP string) error {
} else {
doubleStack = "0"
}
res, err = c.api.Login(&LoginRequest{
Username: c.LoginInfo.Form.Username,
Password: EncryptedMd5,