style: 变量命名

This commit is contained in:
Mmx233
2023-08-28 22:49:17 +08:00
parent 1df6000c71
commit e77448eeb9
10 changed files with 130 additions and 130 deletions

View File

@@ -44,26 +44,26 @@ func (a *Api) request(path string, query map[string]interface{}) (map[string]int
query["callback"] = callback
query["_"] = timestamp
httpTool := tool.NewHttpTool(a.Client)
req, e := httpTool.GenReq("GET", &tool.DoHttpReq{
req, err := httpTool.GenReq("GET", &tool.DoHttpReq{
Url: a.BaseUrl + path,
Query: query,
})
if e != nil {
log.Debugln(e)
return nil, e
if err != nil {
log.Debugln(err)
return nil, err
}
resp, e := httpTool.Client.Do(req)
if e != nil {
log.Debugln(e)
return nil, e
resp, err := httpTool.Client.Do(req)
if err != nil {
log.Debugln(err)
return nil, err
}
defer resp.Body.Close()
data, e := io.ReadAll(resp.Body)
if e != nil {
log.Debugln(e)
return nil, e
data, err := io.ReadAll(resp.Body)
if err != nil {
log.Debugln(err)
return nil, err
}
res := string(data)
@@ -83,9 +83,9 @@ func (a *Api) DetectAcid() (string, error) {
addr := a.BaseUrl
for {
log.Debugln("HTTP GET ", addr)
res, e := a.NoDirect.Get(addr)
if e != nil {
return "", e
res, err := a.NoDirect.Get(addr)
if err != nil {
return "", err
}
_ = res.Body.Close()
loc := res.Header.Get("location")
@@ -97,9 +97,9 @@ func (a *Api) DetectAcid() (string, error) {
}
var u *url.URL
u, e = url.Parse(addr)
if e != nil {
return "", e
u, err = url.Parse(addr)
if err != nil {
return "", err
}
acid := u.Query().Get(`ac_id`)
if acid != "" {

View File

@@ -30,13 +30,13 @@ type Srun struct {
api Api
}
func (c Srun) LoginStatus() (online bool, ip string, e error) {
res, e := c.api.GetUserInfo()
if e != nil {
return false, "", e
func (c Srun) LoginStatus() (online bool, ip string, err error) {
res, err := c.api.GetUserInfo()
if err != nil {
return false, "", err
}
err, ok := res["error"]
errRes, ok := res["error"]
if !ok {
return false, "", ErrResultCannotFound
}
@@ -54,7 +54,7 @@ func (c Srun) LoginStatus() (online bool, ip string, e error) {
inet := strings.HasPrefix(ip, "192.168.") || strings.HasPrefix(ip, "10.") || strings.HasPrefix(ip, "172.")
online = err.(string) == "ok" || !inet
online = errRes.(string) == "ok" || !inet
return
}
@@ -66,9 +66,9 @@ func (c Srun) DoLogin(clientIP string) error {
c.LoginInfo.Form.Username += "@" + c.LoginInfo.Form.UserType
}
res, e := c.api.GetChallenge(c.LoginInfo.Form.Username, clientIP)
if e != nil {
return e
res, err := c.api.GetChallenge(c.LoginInfo.Form.Username, clientIP)
if err != nil {
return err
}
token, ok := res["challenge"]
if !ok {
@@ -79,15 +79,15 @@ func (c Srun) DoLogin(clientIP string) error {
log.Debugln("发送登录请求")
info, e := json.Marshal(map[string]string{
info, err := json.Marshal(map[string]string{
"username": c.LoginInfo.Form.Username,
"password": c.LoginInfo.Form.Password,
"ip": clientIP,
"acid": c.LoginInfo.Meta.Acid,
"enc_ver": c.LoginInfo.Meta.Enc,
})
if e != nil {
return e
if err != nil {
return err
}
EncryptedInfo := "{SRBX1}" + Base64(XEncode(string(info), tokenStr))
Md5Str := Md5(tokenStr)
@@ -99,7 +99,7 @@ func (c Srun) DoLogin(clientIP string) error {
tokenStr + EncryptedInfo,
)
res, e = c.api.Login(
res, err = c.api.Login(
c.LoginInfo.Form.Username,
EncryptedMd5,
c.LoginInfo.Meta.Acid,
@@ -109,8 +109,8 @@ func (c Srun) DoLogin(clientIP string) error {
c.LoginInfo.Meta.N,
c.LoginInfo.Meta.Type,
)
if e != nil {
return e
if err != nil {
return err
}
var result interface{}
result, ok = res["error"]