Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

result cannot found from response #44

Closed
only-apple-can-do opened this issue Nov 2, 2024 · 2 comments
Closed

result cannot found from response #44

only-apple-can-do opened this issue Nov 2, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@only-apple-can-do
Copy link

hello 这里是电子科大的

在未登录的情况下,bitsrun 登录报错 result cannot found from response,原因是请求用户信息的时候返回了

{
    "client_ip": "113.54.155.x",
    "ecode": 0,
    "error": "not_online_error",
    "error_msg": "",
    "online_ip": "113.54.155.x",
    "res": "not_online_error",
    "srun_ver": "SRunCGIAuthIntfSvr V1.18 B20181212",
    "st": 1730530275
}

根据代码

func (c Srun) LoginStatus() (online *bool, ip *string, err error) {
res, err := c.Api.GetUserInfo()
if err != nil {
return nil, nil, err
}
errRes, ok := res["error"]
if ok {
isOnlineStr, ok := errRes.(string)
if ok && isOnlineStr == "ok" {
online = &ok
}
}
ipInterface, ok := res["client_ip"]
if !ok {
ipInterface, ok = res["online_ip"]
}
if ipInterface != nil {
ipStr, ok := ipInterface.(string)
if ok {
ip = &ipStr
}
}
if online == nil || ip == nil {
err = ErrResultCannotFound
}
return
}

执行到 74 时 onlinenilip113.54.155.x,抛出错误 ErrResultCannotFound 是否是有意的?

另外,在上面的函数和后续处理中 online 从未被赋值为 false(的指针),代表 if *online { ... } else { ... }else 的代码永远不会执行,也就是从来不会登录

online, ip, err := srunClient.LoginStatus()
if err != nil {
if online == nil {
return err
} else if isClientIpRequired {
logger.Debugln("响应体缺失客户端 ip,尝试从页面匹配")
clientIp, err = srunDetector.DetectIp()
if err != nil {
return err
}
}
} else {
clientIp = *ip
}
if config.Meta.DoubleStack {
logger.Debugln("使用双栈网络时认证 ip 为空")
} else {
loginIp = clientIp
logger.Debugln("认证客户端 ip: ", loginIp)
}
// 登录执行
if *online {
_Println("已登录~")
if config.Settings.DDNS.Enable && config.Settings.Guardian.Enable && ipLast != clientIp {
if ddns(logger, clientIp, httpClient) == nil {
ipLast = clientIp
}
}
return nil
} else {
logger.Infoln("检测到用户未登录,开始尝试登录...")
if err = srunClient.DoLogin(loginIp); err != nil {
return err
}
logger.Infoln("登录成功~")
if config.Settings.DDNS.Enable {
_ = ddns(logger, clientIp, httpClient)
}
}


我这里只针对我自己的环境做了测试,将

if online == nil || ip == nil {

条件从或改为和。将

条件改为 online != nil && *online 可以正常登录


我不太清楚其他学校是否有这个问题,如果其他学校是正常的我后面有空的话花时间提个 pr 适配下我们学校的环境(

@Mmx233
Copy link
Owner

Mmx233 commented Nov 2, 2024

是 bug

@Mmx233 Mmx233 closed this as completed in 33c7e93 Nov 2, 2024
@Mmx233
Copy link
Owner

Mmx233 commented Nov 2, 2024

请尝试 1.6.5

@Mmx233 Mmx233 added the bug Something isn't working label Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants