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

@@ -16,6 +16,7 @@ var defaultConfig = ConfFromFile{
Enc: "srun_bx1", Enc: "srun_bx1",
OS: "Windows 10", OS: "Windows 10",
Name: "windows", Name: "windows",
InfoPrefix: "SRBX1",
DoubleStack: false, DoubleStack: false,
}, },
Settings: SettingsConf{ Settings: SettingsConf{

View File

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

View File

@@ -3,6 +3,7 @@ package srun
import ( import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"net/http" "net/http"
) )
@@ -83,7 +84,12 @@ func (c Srun) DoLogin(clientIP string) error {
if err != nil { if err != nil {
return err 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) Md5Str := Md5(tokenStr)
EncryptedMd5 := "{MD5}" + Md5Str EncryptedMd5 := "{MD5}" + Md5Str
EncryptedChkstr := Sha1( EncryptedChkstr := Sha1(
@@ -99,6 +105,7 @@ func (c Srun) DoLogin(clientIP string) error {
} else { } else {
doubleStack = "0" doubleStack = "0"
} }
res, err = c.api.Login(&LoginRequest{ res, err = c.api.Login(&LoginRequest{
Username: c.LoginInfo.Form.Username, Username: c.LoginInfo.Form.Username,
Password: EncryptedMd5, Password: EncryptedMd5,