File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -409,8 +409,11 @@ func TestCreateBaseHeaderMatchesWebClientShape(t *testing.T) {
409409 if first ["oai-language" ] != "zh-CN" {
410410 t .Fatalf ("oai-language = %q, want zh-CN" , first ["oai-language" ])
411411 }
412- if ! strings .Contains (first ["user-agent" ], "Edg/147.0.0.0" ) {
413- t .Fatalf ("user-agent = %q, want Edge 147 shape" , first ["user-agent" ])
412+ // UA must be the Edge variant to stay consistent with the hardcoded
413+ // sec-ch-ua = "Microsoft Edge";v="146". Version is randomized.
414+ ua := first ["user-agent" ]
415+ if ! strings .Contains (ua , "Edg/" ) {
416+ t .Fatalf ("user-agent = %q, want Edge variant to match sec-ch-ua=Microsoft Edge 146" , ua )
414417 }
415418 if first ["oai-device-id" ] == "" || first ["oai-device-id" ] != second ["oai-device-id" ] {
416419 t .Fatalf ("oai-device-id should be stable across headers: first=%q second=%q" , first ["oai-device-id" ], second ["oai-device-id" ])
Original file line number Diff line number Diff line change @@ -16,45 +16,19 @@ type userAgentSpec struct {
1616 Family string
1717}
1818
19- // 模板覆盖 Chrome / Edge / Firefox / Safari 四大主流桌面浏览器,
20- // 版本号在 [MinVersion, MaxVersion] 闭区间内随机。
19+ // 模板限定为 Edge(Windows)一族。
20+ //
21+ // 为什么不能用其他浏览器:internal/chatgpt 的 createBaseHeaderForState 同时
22+ // 写死了 sec-ch-ua = "Microsoft Edge";v="146",如果 user-agent 跟 sec-ch-ua
23+ // 不一致,Cloudflare/ChatGPT 一眼就能看出是脚本客户端。版本号在
24+ // [MinVersion, MaxVersion] 闭区间内随机,仍然保留一定的指纹多样性。
2125var userAgentSpecs = []userAgentSpec {
22- {
23- Template : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%d.0.0.0 Safari/537.36" ,
24- MinVersion : 120 ,
25- MaxVersion : 147 ,
26- Family : "Chrome-Win" ,
27- },
28- {
29- Template : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%d.0.0.0 Safari/537.36" ,
30- MinVersion : 120 ,
31- MaxVersion : 147 ,
32- Family : "Chrome-Mac" ,
33- },
3426 {
3527 Template : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%d.0.0.0 Safari/537.36 Edg/%d.0.0.0" ,
3628 MinVersion : 120 ,
3729 MaxVersion : 147 ,
3830 Family : "Edge-Win" ,
3931 },
40- {
41- Template : "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:%d.0) Gecko/20100101 Firefox/%d.0" ,
42- MinVersion : 120 ,
43- MaxVersion : 132 ,
44- Family : "Firefox-Win" ,
45- },
46- {
47- Template : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:%d.0) Gecko/20100101 Firefox/%d.0" ,
48- MinVersion : 120 ,
49- MaxVersion : 132 ,
50- Family : "Firefox-Mac" ,
51- },
52- {
53- Template : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/%d.0 Safari/605.1.15" ,
54- MinVersion : 17 ,
55- MaxVersion : 18 ,
56- Family : "Safari-Mac" ,
57- },
5832}
5933
6034var (
You can’t perform that action at this time.
0 commit comments