fix 139yun

This commit is contained in:
j2rong4cn
2025-07-04 14:27:10 +08:00
parent 82619cc9b2
commit 4990af3c09
2 changed files with 19 additions and 22 deletions

View File

@ -286,10 +286,8 @@ type PersonalUploadUrlResp struct {
} }
type QueryRoutePolicyResp struct { type QueryRoutePolicyResp struct {
Success bool `json:"success"` BaseResp
Code string `json:"code"` Data struct {
Message string `json:"message"`
Data struct {
RoutePolicyList []struct { RoutePolicyList []struct {
SiteID string `json:"siteID"` SiteID string `json:"siteID"`
SiteCode string `json:"siteCode"` SiteCode string `json:"siteCode"`

View File

@ -159,20 +159,15 @@ func (d *Yun139) request(pathname string, method string, callback base.ReqCallba
} }
func (d *Yun139) requestRoute(data interface{}, resp interface{}) ([]byte, error) { func (d *Yun139) requestRoute(data interface{}, resp interface{}) ([]byte, error) {
body, err := utils.Json.Marshal(data)
if err != nil {
return nil, err
}
url := "https://user-njs.yun.139.com/user/route/qryRoutePolicy" url := "https://user-njs.yun.139.com/user/route/qryRoutePolicy"
req := base.RestyClient.R() req := base.RestyClient.R()
randStr := random.String(16) randStr := random.String(16)
ts := time.Now().Format("2006-01-02 15:04:05") ts := time.Now().Format("2006-01-02 15:04:05")
callback := func(req *resty.Request) { req.SetBody(data)
req.SetBody(data)
}
if callback != nil {
callback(req)
}
body, err := utils.Json.Marshal(req.Body)
if err != nil {
return nil, err
}
sign := calSign(string(body), ts, randStr) sign := calSign(string(body), ts, randStr)
svcType := "1" svcType := "1"
if d.isFamily() { if d.isFamily() {
@ -199,20 +194,24 @@ func (d *Yun139) requestRoute(data interface{}, resp interface{}) ([]byte, error
"Inner-Hcy-Router-Https": "1", "Inner-Hcy-Router-Https": "1",
}) })
var e BaseResp
req.SetResult(&e)
res, err := req.Execute(http.MethodPost, url) res, err := req.Execute(http.MethodPost, url)
if err != nil {
return nil, err
}
log.Debugln(res.String()) log.Debugln(res.String())
var e BaseResp
err = utils.Json.Unmarshal(res.Bytes(), &e)
if err != nil {
return nil, err
}
if !e.Success { if !e.Success {
return nil, errors.New(e.Message) return nil, errors.New(e.Message)
} }
if resp != nil { err = utils.Json.Unmarshal(res.Bytes(), resp)
err = utils.Json.Unmarshal(res.Bytes(), resp) if err != nil {
if err != nil { return nil, err
return nil, err
}
} }
return res.Bytes(), nil return res.Bytes(), err
} }
func (d *Yun139) post(pathname string, data interface{}, resp interface{}) ([]byte, error) { func (d *Yun139) post(pathname string, data interface{}, resp interface{}) ([]byte, error) {