Dev#267
Merged
Merged
Conversation
- 新增util包的RandomUserAgent函数,生成主流桌面浏览器随机UA - 替换所有硬编码userAgent为defaultUserAgent()调用 - 为客户端状态加入UserAgent字段并初始化随机UA - 重构prooftoken模块,适配新的随机UA和POW逻辑
移除其他浏览器的UA模板,仅保留Edge Windows版本,匹配硬编码的sec-ch-ua头以通过Cloudflare校验,同时保留版本随机化保证指纹多样性
There was a problem hiding this comment.
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/prooftokento 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校验,同时保留版本随机化保证指纹多样性
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.