2025-12-25 17:15:01 +08:00
|
|
|
|
package service
|
2025-12-22 22:58:31 +08:00
|
|
|
|
|
2026-03-27 14:23:28 +08:00
|
|
|
|
import (
|
|
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/Wei-Shaw/sub2api/internal/pkg/tlsfingerprint"
|
|
|
|
|
|
)
|
2025-12-22 22:58:31 +08:00
|
|
|
|
|
2025-12-31 11:43:58 +08:00
|
|
|
|
// HTTPUpstream 上游 HTTP 请求接口
|
|
|
|
|
|
// 用于向上游 API(Claude、OpenAI、Gemini 等)发送请求
|
2025-12-22 22:58:31 +08:00
|
|
|
|
type HTTPUpstream interface {
|
2026-03-27 14:23:28 +08:00
|
|
|
|
// Do 执行 HTTP 请求(不启用 TLS 指纹)
|
2025-12-31 11:43:58 +08:00
|
|
|
|
Do(req *http.Request, proxyURL string, accountID int64, accountConcurrency int) (*http.Response, error)
|
2026-01-18 20:06:56 +08:00
|
|
|
|
|
|
|
|
|
|
// DoWithTLS 执行带 TLS 指纹伪装的 HTTP 请求
|
|
|
|
|
|
//
|
2026-03-27 14:23:28 +08:00
|
|
|
|
// profile 参数:
|
|
|
|
|
|
// - nil: 不启用 TLS 指纹,行为与 Do 方法相同
|
|
|
|
|
|
// - non-nil: 使用指定的 Profile 进行 TLS 指纹伪装
|
2026-01-18 20:06:56 +08:00
|
|
|
|
//
|
2026-03-27 14:23:28 +08:00
|
|
|
|
// Profile 由调用方通过 TLSFingerprintProfileService 解析后传入,
|
|
|
|
|
|
// 支持按账号绑定的数据库 profile 或内置默认 profile。
|
|
|
|
|
|
DoWithTLS(req *http.Request, proxyURL string, accountID int64, accountConcurrency int, profile *tlsfingerprint.Profile) (*http.Response, error)
|
2025-12-22 22:58:31 +08:00
|
|
|
|
}
|