From d65410d3d022a2cfa216f79c627a43938f3e773a Mon Sep 17 00:00:00 2001 From: mbzo <37258062+zf1234d@users.noreply.github.com> Date: Thu, 30 Jul 2026 15:27:11 +0800 Subject: [PATCH] fix(lanzou): handle acw_sc__v2 challenge in Login function The Login endpoint may return an acw_sc__v2 validation page when accessed, which previously caused login failures. This change adds the same retry logic and cookie handling already used in request() to automatically solve the challenge, ensuring login success even when the anti-bot mechanism is triggered. --- drivers/lanzou/util.go | 54 ++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/drivers/lanzou/util.go b/drivers/lanzou/util.go index e451be249..b0545bbd5 100644 --- a/drivers/lanzou/util.go +++ b/drivers/lanzou/util.go @@ -157,25 +157,43 @@ func (d *LanZou) request(url string, method string, callback base.ReqCallback, u } func (d *LanZou) Login() ([]*http.Cookie, error) { - resp, err := base.NewRestyClient().SetRedirectPolicy(resty.NoRedirectPolicy()). - R().SetFormData(map[string]string{ - "task": "3", - "uid": d.Account, - "pwd": d.Password, - "setSessionId": "", - "setSig": "", - "setScene": "", - "setTocen": "", - "formhash": "", - }).Post("https://up.woozooo.com/mlogin.php") - if err != nil { - return nil, err - } - if utils.Json.Get(resp.Body(), "zt").ToInt() != 1 { - return nil, fmt.Errorf("login err: %s", resp.Body()) + var vs string + for retry := 0; retry < 3; retry++ { + req := base.NewRestyClient().SetRedirectPolicy(resty.NoRedirectPolicy()).R() + + // 如果已计算出 acw_sc__v2,通过 cookie 携带 + if vs != "" { + req.SetHeader("cookie", "acw_sc__v2="+vs) + } + + resp, err := req.SetFormData(map[string]string{ + "task": "3", + "uid": d.Account, + "pwd": d.Password, + "setSessionId": "", + "setSig": "", + "setScene": "", + "setTocen": "", + "formhash": "", + }).Post("https://up.woozooo.com/mlogin.php") + if err != nil { + return nil, err + } + bodyStr := resp.String() + if strings.Contains(bodyStr, "acw_sc__v2") { + vs, err = CalcAcwScV2(bodyStr) + if err != nil { + return nil, err + } + continue + } + if utils.Json.Get(resp.Body(), "zt").ToInt() != 1 { + return nil, fmt.Errorf("login err: %s", resp.Body()) + } + d.Cookie = CookieToString(resp.Cookies()) + return resp.Cookies(), nil } - d.Cookie = CookieToString(resp.Cookies()) - return resp.Cookies(), nil + return nil, errors.New("acw_sc__v2 validation error") } /*