Add the Chrome fallback and the needs-human flow.
Bot checks escalate to headless Chrome with stealth, which claims the same identity as tls-client and hands its cookies back to the jar. The visit counts against the rate limits. If Chrome can't clear a check, the URL is marked needs-human. Pressing Enter on it in the TUI, or running 'dibs solve', opens a visible window; dibs carries on once the page loads. Processes now merge the cookie file on save, with the newest cookie winning.
This commit is contained in:
1 parent
f2ea1297e8
commit
e2cbc1a55c
20 files changed
+905
-73
No files matched your search
@@ -172,6 +172,42 @@ func TestJarSaveLoad(t *testing.T) {
|
||||
if err := NewJar().Load(filepath.Join(t.TempDir(), "missing.json")); err != nil { t.Errorf("missing file: %v", err) }
|
||||
}
|
||||
|
||||
// TestJarShared has two processes share a cookie file. Neither may undo the
|
||||
// other's newer cookies when it saves.
|
||||
func TestJarShared(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "cookies.json")
|
||||
u := mustURL(t, "https://www.amazon.de/")
|
||||
now := time.Now()
|
||||
set := func(j *Jar, name, value string, maxAge int) {
|
||||
j.SetCookies(u, []*fhttp.Cookie{{Name: name, Value: value, Path: "/", Expires: now.Add(time.Hour), MaxAge: maxAge}})
|
||||
}
|
||||
|
||||
watcher, solver := NewJar(), NewJar()
|
||||
watcher.now = func() time.Time { return now }
|
||||
solver.now = func() time.Time { return now.Add(time.Minute) }
|
||||
|
||||
set(watcher, "session", "old", 0)
|
||||
set(watcher, "tracking", "x", 0)
|
||||
if err := watcher.Save(path); err != nil { t.Fatal(err) }
|
||||
|
||||
// The solver gets a new session and drops the tracking cookie.
|
||||
if err := solver.Load(path); err != nil { t.Fatal(err) }
|
||||
set(solver, "session", "solved", 0)
|
||||
set(solver, "tracking", "", -1)
|
||||
if err := solver.Save(path); err != nil { t.Fatal(err) }
|
||||
|
||||
// The watcher saves again later, without having seen either change.
|
||||
watcher.now = func() time.Time { return now.Add(2 * time.Minute) }
|
||||
if err := watcher.Save(path); err != nil { t.Fatal(err) }
|
||||
|
||||
if got := cookieNames(watcher.Cookies(u)); got != "session=solved" { t.Errorf("watcher after saving: %q", got) }
|
||||
|
||||
fresh := NewJar()
|
||||
fresh.now = watcher.now
|
||||
if err := fresh.Load(path); err != nil { t.Fatal(err) }
|
||||
if got := cookieNames(fresh.Cookies(u)); got != "session=solved" { t.Errorf("file after both saved: %q", got) }
|
||||
}
|
||||
|
||||
// noLimit lets tests talk to their local server without the host floor.
|
||||
type noLimit struct{}
|
||||
|
||||
|
||||
Reference in new issue
Block a user