增加bark配置

This commit is contained in:
2026-06-17 23:49:19 +08:00
parent 22e0e75c35
commit 6ee1f26124
19 changed files with 784 additions and 260 deletions
+51 -12
View File
@@ -66,6 +66,15 @@ func (c *ApiGetCardController) GetCard() {
return
}
// 读取机器码/MAC
machineCode := strings.TrimSpace(c.GetString("machine_code"))
if machineCode == "" {
machineCode = strings.TrimSpace(c.GetString("machineCode"))
}
if machineCode == "" {
machineCode = strings.TrimSpace(c.GetString("mac"))
}
// 参数校验
if platform == "" {
c.cardErr(400, 400, "缺少参数 type(来源平台)")
@@ -92,7 +101,7 @@ func (c *ApiGetCardController) GetCard() {
switch module {
case "cursor":
c.extractCursor(platform, dataType, startID, now)
c.extractCursor(platform, dataType, startID, now, machineCode)
case "windsurf":
c.extractWindsurf(platform, dataType, startID, now)
case "krio":
@@ -121,8 +130,25 @@ func (c *ApiGetCardController) readOptionalStartID() (uint64, error) {
return id, nil
}
func (c *ApiGetCardController) extractCursor(platform, dataType string, startID uint64, now time.Time) {
c.extractWithProbe("cursor", platform, dataType, now, func() (uint64, *string, *string, string, string, *int8, error) {
func (c *ApiGetCardController) extractCursor(platform, dataType string, startID uint64, now time.Time, machineCode string) {
// 优先查询该机器码是否已经绑定过未删除的卡密
if machineCode != "" {
var existing models.PlatformAccountPoolCursor
err := models.Orm.QueryTable(new(models.PlatformAccountPoolCursor)).
Filter("machine_code", machineCode).
Filter("delete_time__isnull", true).
Exclude("is_used", 0).
OrderBy("-id").
Limit(1).
One(&existing)
if err == nil {
// 直接返回已绑定的卡密信息
c.cardOK(buildCardResult(&existing.Account, &existing.Password, existing.Token, existing.DataType))
return
}
}
c.extractWithProbe("cursor", platform, dataType, now, machineCode, func() (uint64, *string, *string, string, string, *int8, error) {
var row models.PlatformAccountPoolCursor
qs := models.Orm.QueryTable(new(models.PlatformAccountPoolCursor)).
Filter("is_extracted", 0).
@@ -141,7 +167,7 @@ func (c *ApiGetCardController) extractCursor(platform, dataType string, startID
}
func (c *ApiGetCardController) extractWindsurf(platform, dataType string, startID uint64, now time.Time) {
c.extractWithProbe("windsurf", platform, dataType, now, func() (uint64, *string, *string, string, string, *int8, error) {
c.extractWithProbe("windsurf", platform, dataType, now, "", func() (uint64, *string, *string, string, string, *int8, error) {
var row models.PlatformAccountPoolWindsurf
qs := models.Orm.QueryTable(new(models.PlatformAccountPoolWindsurf)).
Filter("is_extracted", 0).
@@ -160,7 +186,7 @@ func (c *ApiGetCardController) extractWindsurf(platform, dataType string, startI
}
func (c *ApiGetCardController) extractKrio(platform, dataType string, startID uint64, now time.Time) {
c.extractWithProbe("krio", platform, dataType, now, func() (uint64, *string, *string, string, string, *int8, error) {
c.extractWithProbe("krio", platform, dataType, now, "", func() (uint64, *string, *string, string, string, *int8, error) {
var row models.PlatformAccountPoolKiro
qs := models.Orm.QueryTable(new(models.PlatformAccountPoolKiro)).
Filter("is_extracted", 0).
@@ -179,7 +205,7 @@ func (c *ApiGetCardController) extractKrio(platform, dataType string, startID ui
}
func (c *ApiGetCardController) extractCodex(platform, dataType string, startID uint64, now time.Time) {
c.extractWithProbe("codex", platform, dataType, now, func() (uint64, *string, *string, string, string, *int8, error) {
c.extractWithProbe("codex", platform, dataType, now, "", func() (uint64, *string, *string, string, string, *int8, error) {
var row models.PlatformAccountPoolCodex
qs := models.Orm.QueryTable(new(models.PlatformAccountPoolCodex)).
Filter("is_extracted", 0).
@@ -203,6 +229,7 @@ type poolRowFetcher func() (id uint64, account, password *string, token, rowData
func (c *ApiGetCardController) extractWithProbe(
module, platform, dataType string,
now time.Time,
machineCode string,
fetch poolRowFetcher,
) {
for {
@@ -221,14 +248,20 @@ func (c *ApiGetCardController) extractWithProbe(
c.cardErr(500, 500, "无效模块")
return
}
params := map[string]interface{}{
"is_extracted": 1,
"extracted_time": now,
"extracted_platform": platform,
"update_time": now,
}
if module == "cursor" && machineCode != "" {
params["machine_code"] = machineCode
}
_, err = models.Orm.QueryTable(tableName).
Filter("id", id).
Update(map[string]interface{}{
"is_extracted": 1,
"extracted_time": now,
"extracted_platform": platform,
"update_time": now,
})
Update(params)
if err != nil {
c.cardErr(500, 500, "提取失败")
return
@@ -240,10 +273,16 @@ func (c *ApiGetCardController) extractWithProbe(
c.cardOK(buildCardResult(account, password, token, rowDataType))
return
}
if module == "cursor" && machineCode != "" {
_, _ = models.Orm.QueryTable(tableName).Filter("id", id).Update(map[string]interface{}{"machine_code": "", "update_time": time.Now()})
}
continue
}
if !poolProbeToken(module, rowDataType, token, id) {
if module == "cursor" && machineCode != "" {
_, _ = models.Orm.QueryTable(tableName).Filter("id", id).Update(map[string]interface{}{"machine_code": "", "update_time": time.Now()})
}
continue
}