mirror of
https://github.com/lukaszraczylo/mcp-captcharesolver.git
synced 2026-10-12 00:45:28 +00:00
feat(stealth): consistent header set with TLS/JA3 advisories
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package stealth
|
||||
|
||||
// HeaderSet is a consistent header bundle plus advisories the MCP cannot enforce.
|
||||
type HeaderSet struct {
|
||||
Headers map[string]string `json:"headers"`
|
||||
Advisories []string `json:"advisories"`
|
||||
}
|
||||
|
||||
// HeadersFor builds an HTTP header set consistent with the given fingerprint.
|
||||
func HeadersFor(fp Fingerprint) HeaderSet {
|
||||
return HeaderSet{
|
||||
Headers: map[string]string{
|
||||
"User-Agent": fp.UserAgent,
|
||||
"Accept-Language": fp.Locale + ",en;q=0.9",
|
||||
"Sec-CH-UA": fp.SecCHUA,
|
||||
"Sec-CH-UA-Platform": fp.SecCHUAPlatform,
|
||||
"Sec-CH-UA-Mobile": "?0",
|
||||
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
|
||||
},
|
||||
Advisories: []string{
|
||||
"TLS/JA3 fingerprint is set by the browser's TLS stack and cannot be changed by this MCP — use a matching browser build or a TLS-rotating proxy.",
|
||||
"HTTP/2 frame fingerprint is browser-controlled; header order here is advisory only.",
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package stealth
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestHeadersFor(t *testing.T) {
|
||||
fp := GenerateFingerprint(FingerprintParams{OS: "macos", Browser: "chrome", Locale: "en-GB", Seed: 5})
|
||||
h := HeadersFor(fp)
|
||||
if h.Headers["User-Agent"] != fp.UserAgent {
|
||||
t.Fatalf("UA mismatch")
|
||||
}
|
||||
if h.Headers["Accept-Language"] == "" || h.Headers["Sec-CH-UA-Platform"] == "" {
|
||||
t.Fatalf("missing client hints: %+v", h.Headers)
|
||||
}
|
||||
if len(h.Advisories) == 0 {
|
||||
t.Fatal("expected TLS/JA3 advisory")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user