Skip to content

Dev#267

Merged
xiaozhou26 merged 6 commits into
mainfrom
dev
Jun 12, 2026
Merged

Dev#267
xiaozhou26 merged 6 commits into
mainfrom
dev

Conversation

@xiaozhou26

Copy link
Copy Markdown
Collaborator

No description provided.

- 新增util包的RandomUserAgent函数,生成主流桌面浏览器随机UA
- 替换所有硬编码userAgent为defaultUserAgent()调用
- 为客户端状态加入UserAgent字段并初始化随机UA
- 重构prooftoken模块,适配新的随机UA和POW逻辑
移除其他浏览器的UA模板,仅保留Edge Windows版本,匹配硬编码的sec-ch-ua头以通过Cloudflare校验,同时保留版本随机化保证指纹多样性
Copilot AI review requested due to automatic review settings June 12, 2026 11:03
@xiaozhou26 xiaozhou26 merged commit 936dd0b into main Jun 12, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces randomized User-Agent generation and a refactored/optimized proof-of-work (Sentinel) token generator, and threads the UA through more of the ChatGPT request flow. It also updates SSE/TTS stream parsing and adjusts response conversion/model propagation tests.

Changes:

  • Add util.RandomUserAgent() (+ tests) and use it across ChatGPT requests instead of a single hardcoded UA.
  • Rewrite internal/prooftoken to generate requirements/proof tokens with new config structures and iteration logic.
  • Improve stream handling (notably TTS patch-stream parsing) and ensure the request model is propagated into converted SSE chunks.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

Show a summary per file
File Description
util/useragent.go Adds randomized Edge-family UA generator.
util/useragent_test.go Adds tests for UA generation behavior.
internal/prooftoken/prooftoken.go Refactors POW requirements/proof token generation and related utilities.
internal/chatgpt/request.go Uses randomized UA, updates sentinel init flow, and improves TTS SSE parsing.
internal/chatgpt/request_test.go Updates tests for UA expectations and adds TTS stream parsing coverage.
internal/chatgpt/files.go Switches upload UA to defaultUserAgent().
internal/chatgpt/client_state.go Adds UserAgent to client state and initializes it.
internal/chatgpt/artifact_delivery.go Switches download UA to defaultUserAgent().
initialize/handlers.go Updates TTS handler flow to use the newer conversation-posting path and closes WS on error.
conversion/response/chatgpt/convert.go Makes chunk conversion safer when content parts are missing/non-string and uses request model.
conversion/response/chatgpt/convert_test.go Adds tests for model propagation and source-marker handling.
go.mod Removes funcaptcha dependency.
go.sum Removes funcaptcha checksums.
.gitignore Normalizes .gocache entry and adds additional ignores.
Comments suppressed due to low confidence (1)

util/useragent.go:49

  • RandomUserAgent uses a shared *rand.Rand (uaRand) without synchronization, but math/rand.Rand is not safe for concurrent use. If RandomUserAgent is called from multiple goroutines this can cause data races and undefined behavior.
// RandomUserAgent 返回一个随机的主流桌面浏览器 User-Agent
func RandomUserAgent() string {
	initUARand()
	spec := userAgentSpecs[uaRand.Intn(len(userAgentSpecs))]


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

xiaozhou26 added a commit that referenced this pull request Jun 13, 2026
* feat: 更新 ConvertToString 函数以支持动态模型,并添加相关测试用例

* feat: 更新 HandlerTTS 函数以支持流式数据解析,并添加相关单元测试

* fix: 移除不再需要的 funcaptcha 依赖

* refactor: 替换固定UA为随机浏览器UA,优化指纹多样性

- 新增util包的RandomUserAgent函数,生成主流桌面浏览器随机UA
- 替换所有硬编码userAgent为defaultUserAgent()调用
- 为客户端状态加入UserAgent字段并初始化随机UA
- 重构prooftoken模块,适配新的随机UA和POW逻辑

* refactor(util/useragent): 限定UA模板仅为Edge Windows一族

移除其他浏览器的UA模板,仅保留Edge Windows版本,匹配硬编码的sec-ch-ua头以通过Cloudflare校验,同时保留版本随机化保证指纹多样性
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants