修复检测
This commit is contained in:
parent
269fbd08ff
commit
df02280086
@ -878,6 +878,54 @@ func setPoolUnavailable(c *beego.Controller, module string) {
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
func updatePoolUsable(c *beego.Controller, module string) {
|
||||
if _, err := requirePlatformAuth(c); err != nil {
|
||||
poolJSONErr(c, 401, 401, err.Error())
|
||||
return
|
||||
}
|
||||
if module != "cursor" {
|
||||
poolJSONErr(c, 400, 400, "该模块不支持可用状态修改")
|
||||
return
|
||||
}
|
||||
raw, err := io.ReadAll(c.Ctx.Request.Body)
|
||||
if err != nil {
|
||||
poolJSONErr(c, 400, 400, "参数错误")
|
||||
return
|
||||
}
|
||||
var payload struct {
|
||||
ID uint64 `json:"id"`
|
||||
Usable int `json:"usable"`
|
||||
}
|
||||
if err := json.Unmarshal(raw, &payload); err != nil || payload.ID == 0 {
|
||||
poolJSONErr(c, 400, 400, "参数错误")
|
||||
return
|
||||
}
|
||||
if payload.Usable != 0 && payload.Usable != 1 {
|
||||
poolJSONErr(c, 400, 400, "可用状态参数错误")
|
||||
return
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
updated, err := models.Orm.QueryTable(new(models.PlatformAccountPoolCursor)).Filter("id", payload.ID).Update(orm.Params{
|
||||
"is_used": int8(payload.Usable),
|
||||
"update_time": now,
|
||||
})
|
||||
if err != nil {
|
||||
poolJSONErr(c, 500, 500, "可用状态更新失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
if updated == 0 {
|
||||
poolJSONErr(c, 404, 404, "记录不存在")
|
||||
return
|
||||
}
|
||||
msg := "已标记不可用"
|
||||
if payload.Usable == 1 {
|
||||
msg = "已标记可用"
|
||||
}
|
||||
c.Data["json"] = map[string]interface{}{"code": 200, "msg": msg}
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
func updatePoolPlatform(c *beego.Controller, module string) {
|
||||
if _, err := requirePlatformAuth(c); err != nil {
|
||||
poolJSONErr(c, 401, 401, err.Error())
|
||||
@ -1088,6 +1136,9 @@ func (c *PlatformAccountPoolCursorController) UpdateRemark() {
|
||||
func (c *PlatformAccountPoolCursorController) SetUnavailable() {
|
||||
setPoolUnavailable(&c.Controller, "cursor")
|
||||
}
|
||||
func (c *PlatformAccountPoolCursorController) UpdateUsable() {
|
||||
updatePoolUsable(&c.Controller, "cursor")
|
||||
}
|
||||
func (c *PlatformAccountPoolCursorController) UpdatePlatform() {
|
||||
updatePoolPlatform(&c.Controller, "cursor")
|
||||
}
|
||||
|
||||
@ -59,67 +59,7 @@ func normalizeBearerToken(s string) string {
|
||||
}
|
||||
|
||||
func probeCursor(token string) Result {
|
||||
url := "https://api2.cursor.sh/auth/full_stripe_profile"
|
||||
req, err := http.NewRequest(http.MethodGet, url, nil)
|
||||
if err != nil {
|
||||
return Result{OK: false, Detail: "构造请求失败: " + err.Error()}
|
||||
}
|
||||
|
||||
req.Header.Set("Authorization", "Bearer "+strings.TrimSpace(token))
|
||||
req.Header.Set("X-Cursor-Client-Version", "3.0.16")
|
||||
req.Header.Set("X-New-Onboarding-Completed", "false")
|
||||
req.Header.Set("X-Ghost-Mode", "true")
|
||||
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Cursor/3.0.16 Chrome/142.0.7444.265 Electron/39.8.1 Safari/537.36")
|
||||
req.Header.Set("Accept", "*/*")
|
||||
req.Header.Set("Origin", "vscode-file://vscode-app")
|
||||
req.Header.Set("Accept-Encoding", "gzip, deflate, br, zstd")
|
||||
req.Header.Set("Accept-Language", "zh-CN")
|
||||
req.Header.Set("Priority", "u=1, i")
|
||||
|
||||
resp, err := httpClient.Do(req)
|
||||
if err != nil {
|
||||
return Result{OK: false, Detail: "请求官方账单接口超时/网络失败: " + err.Error(), HTTPStatus: 500}
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, _ := io.ReadAll(io.LimitReader(resp.Body, 16384))
|
||||
jsonStr := string(body)
|
||||
|
||||
res := Result{
|
||||
HTTPStatus: resp.StatusCode,
|
||||
Endpoint: url,
|
||||
BytesRead: len(body),
|
||||
RawPreview: jsonStr,
|
||||
StreamProtocol: "HTTP/2 JSON REST",
|
||||
StreamNote: "2026型画像探测",
|
||||
ProbeMessage: "GET full_stripe_profile",
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
res.OK = false
|
||||
res.Detail = fmt.Sprintf("Token已失效或被官方拉黑(HTTP %d)", resp.StatusCode)
|
||||
return res
|
||||
}
|
||||
|
||||
if strings.Contains(jsonStr, `"noModelsRemaining":true`) ||
|
||||
strings.Contains(jsonStr, `"is_usage_limited":true`) ||
|
||||
strings.Contains(jsonStr, `"hard_limit_reached"`) ||
|
||||
strings.Contains(jsonStr, `"blocked"`) ||
|
||||
(strings.Contains(jsonStr, `"membershipType":"free"`) && strings.Contains(jsonStr, `"trialEligible":false`)) {
|
||||
res.OK = false
|
||||
res.Detail = "Token存活,但属于无额度Free空壳号(上号必弹付费墙)"
|
||||
return res
|
||||
}
|
||||
|
||||
if len(jsonStr) < 10 {
|
||||
res.OK = false
|
||||
res.Detail = "官方接口返回异常空数据"
|
||||
return res
|
||||
}
|
||||
|
||||
res.OK = true
|
||||
res.Detail = "检测成功,高速算力/Agent额度健康"
|
||||
return res
|
||||
return probeCursorHiAgent(token)
|
||||
}
|
||||
|
||||
func probeWindsurf(apiKey string) Result {
|
||||
|
||||
@ -170,6 +170,7 @@ func Register() {
|
||||
beego.Router("/platform/accountPool/cursor/extract", &controllers.PlatformAccountPoolCursorController{}, "post:Extract")
|
||||
beego.Router("/platform/accountPool/cursor/updateRemark", &controllers.PlatformAccountPoolCursorController{}, "post:UpdateRemark")
|
||||
beego.Router("/platform/accountPool/cursor/setUnavailable", &controllers.PlatformAccountPoolCursorController{}, "post:SetUnavailable")
|
||||
beego.Router("/platform/accountPool/cursor/updateUsable", &controllers.PlatformAccountPoolCursorController{}, "post:UpdateUsable")
|
||||
beego.Router("/platform/accountPool/cursor/updatePlatform", &controllers.PlatformAccountPoolCursorController{}, "post:UpdatePlatform")
|
||||
beego.Router("/platform/accountPool/cursor/unextract", &controllers.PlatformAccountPoolCursorController{}, "post:Unextract")
|
||||
beego.Router("/platform/accountPool/cursor/replenish", &controllers.PlatformAccountPoolCursorController{}, "post:Replenish")
|
||||
|
||||
BIN
server.exe
BIN
server.exe
Binary file not shown.
Loading…
Reference in New Issue
Block a user