修复全量审查问题;设置接口PATCH化;回传指纹加固
CI / test (push) Successful in 32s

This commit is contained in:
2026-07-22 16:51:23 +08:00
parent 0614ef22af
commit f51fb6c722
66 changed files with 3997 additions and 687 deletions
+12 -6
View File
@@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"time"
@@ -108,13 +109,18 @@ func (s *ProxyService) probeGeo(ctx context.Context, id uint) {
break
}
}
var row model.Proxy
if err := s.db.WithContext(ctx).First(&row, id).Error; err != nil {
return
}
s.persistGeo(ctx, id, res)
}
// persistGeo 条件更新地区字段:代理已被删除时零命中放弃——整行 Save 零命中会
// 回退 Create 把删掉的代理复活;错误也不能静默吞掉。
func (s *ProxyService) persistGeo(ctx context.Context, id uint, res geoResult) {
now := time.Now()
row.Country, row.City, row.GeoAt = res.Country, res.City, &now
s.db.WithContext(ctx).Save(&row)
tx := s.db.WithContext(ctx).Model(&model.Proxy{}).Where("id = ?", id).
Updates(map[string]any{"country": res.Country, "city": res.City, "geo_at": &now})
if tx.Error != nil {
log.Printf("proxy geo persist %d: %v", id, tx.Error)
}
}
// Probe 同步重测代理出口地理并返回最新视图;供手动「重测」入口调用。