Mmx233 / BitSrunLoginGo

深澜校园网登录程序 Go 语言版,适用于Windows、Linux、路由器等。提供对 Docker、Go Module、OpenWrt 的支持
GNU Affero General Public License v3.0
303 stars 27 forks source link

不能follow重定向 #26

Closed VPCU closed 1 year ago

VPCU commented 1 year ago

不能follow 301:

./bitsrun_linux_amd64 --debug
INFO[0000] 正在获取登录状态                                     
DEBU[0000] HTTP GET  http://example.edu.cn/cgi-bin/rad_user_info 
DEBU[0000] <html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
 /html>
ERRO[0000] 登录出错:  invalid character '<' looking for beginning of value

https://github.com/Mmx233/BitSrunLoginGo/blob/672db9c15493c354e1280bb3ff0ed11e83e89712/pkg/srun/api.go#L31C9-L31C9

a.NoDirect = &(*client)

这句话相当于

a.NoDirect = client

导致之后修改了client的CheckRedirect。

建议修改为类似

a.NoDirect = &http.Client{
    Transport: client.Transport, Jar: client.Jar, Timeout: client.Timeout,
    CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
        return http.ErrUseLastResponse
    },
}
Mmx233 commented 1 year ago

已修复:https://github.com/Mmx233/BitSrunLoginGo/commit/0065d3889337a492bece4d5fe4825f7862a35f6a ,感谢反馈

Mmx233 commented 1 year ago

需要帮忙打包吗,现在还不会 release

VPCU commented 1 year ago

谢谢,不用帮我打包了