http_upstream_port.go 909 B

123456789101112131415161718192021222324
  1. package service
  2. import (
  3. "net/http"
  4. "github.com/Wei-Shaw/sub2api/internal/pkg/tlsfingerprint"
  5. )
  6. // HTTPUpstream 上游 HTTP 请求接口
  7. // 用于向上游 API(Claude、OpenAI、Gemini 等)发送请求
  8. type HTTPUpstream interface {
  9. // Do 执行 HTTP 请求(不启用 TLS 指纹)
  10. Do(req *http.Request, proxyURL string, accountID int64, accountConcurrency int) (*http.Response, error)
  11. // DoWithTLS 执行带 TLS 指纹伪装的 HTTP 请求
  12. //
  13. // profile 参数:
  14. // - nil: 不启用 TLS 指纹,行为与 Do 方法相同
  15. // - non-nil: 使用指定的 Profile 进行 TLS 指纹伪装
  16. //
  17. // Profile 由调用方通过 TLSFingerprintProfileService 解析后传入,
  18. // 支持按账号绑定的数据库 profile 或内置默认 profile。
  19. DoWithTLS(req *http.Request, proxyURL string, accountID int64, accountConcurrency int, profile *tlsfingerprint.Profile) (*http.Response, error)
  20. }