- antigravity/node-tls-proxy/ ← 原 tools/node-tls-proxy - antigravity/firewall/ ← 原 tools/firewall - antigravity/maintenance/ ← 原 tools/maintenance - repository/http_upstream_antigravity.go ← Node.js 代理 3 个方法(原在 http_upstream.go) - service/identity_service_antigravity.go ← ApplyDefaultFingerprintOverrides + NewIdentityServiceWithSalt - service/account_antigravity.go ← Gemini TLS 指纹扩展函数 对上游文件 http_upstream.go 的钩子调用精简为 2 处 if 块(共 14 行) 对上游文件 account.go Gemini 分支精简为 1 行函数调用 便于 upstream rebase 时快速识别和保留自定义改动
41 lines
1.7 KiB
Go
41 lines
1.7 KiB
Go
package service
|
||
|
||
// ==============================================================
|
||
// antigravity — identity_service 扩展
|
||
//
|
||
// 此文件包含 Antigravity fork 对 IdentityService 的扩展,
|
||
// 新增了实例级隔离盐值和指纹默认值覆盖功能。
|
||
//
|
||
// 对上游文件 identity_service.go 的最小化改动:
|
||
// - defaultFingerprint 版本号更新(L29/L31):claude-cli 2.1.81 / sdk 0.80.0
|
||
// - IdentityService struct 新增 instanceSalt 字段(L86)
|
||
// [以上两处改动仍在原文件中,因为是对已有定义的修改,无法完全抽离]
|
||
// ==============================================================
|
||
|
||
// ApplyDefaultFingerprintOverrides 用配置覆盖 identity_service 的默认指纹
|
||
// 允许不同部署实例设置不同的 CLI/SDK 版本号,避免所有实例指纹相同
|
||
func ApplyDefaultFingerprintOverrides(cliVersion, pkgVersion, runtimeVersion, os_, arch string) {
|
||
if cliVersion != "" {
|
||
defaultFingerprint.UserAgent = "claude-cli/" + cliVersion + " (external, cli)"
|
||
}
|
||
if pkgVersion != "" {
|
||
defaultFingerprint.StainlessPackageVersion = pkgVersion
|
||
}
|
||
if runtimeVersion != "" {
|
||
defaultFingerprint.StainlessRuntimeVersion = runtimeVersion
|
||
}
|
||
if os_ != "" {
|
||
defaultFingerprint.StainlessOS = os_
|
||
}
|
||
if arch != "" {
|
||
defaultFingerprint.StainlessArch = arch
|
||
}
|
||
}
|
||
|
||
// NewIdentityServiceWithSalt 创建带实例盐值的 IdentityService
|
||
// 实例盐值用于 user_id 重写时的 session hash 混淆,
|
||
// 使不同 sub2api 实例对相同输入产生不同的 hash 输出,增加隔离性
|
||
func NewIdentityServiceWithSalt(cache IdentityCache, salt string) *IdentityService {
|
||
return &IdentityService{cache: cache, instanceSalt: salt}
|
||
}
|