Add Gmail+Email Worker hybrid mail path and private runtime config
Prefer Cloudflare Worker KV for verification codes with optional short IMAP fallback disabled for private deploy; track config.json/.env for private repo. Also add worker project, protocol mint backoff, and fail-fast Turnstile/mail timeouts from batch runs.
This commit is contained in:
1 parent
187792d6be
commit
55f56d27c9
19 files changed
+1225
-85
No files matched your search
+68
-19
@@ -57,26 +57,56 @@ def _patched_create_browser_options():
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
for cand in (
|
||||
"/snap/bin/chromium",
|
||||
"/usr/bin/chromium",
|
||||
"/usr/bin/chromium-browser",
|
||||
"/usr/bin/google-chrome",
|
||||
"/usr/bin/google-chrome-stable",
|
||||
):
|
||||
if os.path.isfile(cand):
|
||||
try:
|
||||
opts.set_browser_path(cand)
|
||||
except Exception:
|
||||
pass
|
||||
break
|
||||
|
||||
ext_path = os.path.join(os.path.dirname(os.path.abspath(reg.__file__)), "turnstilePatch")
|
||||
if os.path.isdir(ext_path):
|
||||
# Prefer Google Chrome for registration reliability; Chromium fallback for extension.
|
||||
browser_path = None
|
||||
resolve = getattr(reg, "resolve_browser_path", None)
|
||||
if callable(resolve):
|
||||
try:
|
||||
opts.add_extension(ext_path)
|
||||
browser_path = resolve()
|
||||
except Exception:
|
||||
browser_path = None
|
||||
if not browser_path:
|
||||
for cand in (
|
||||
"/usr/bin/google-chrome-stable",
|
||||
"/usr/bin/google-chrome",
|
||||
"/snap/bin/chromium",
|
||||
"/usr/bin/chromium",
|
||||
"/usr/bin/chromium-browser",
|
||||
):
|
||||
if os.path.isfile(cand) or os.path.islink(cand):
|
||||
browser_path = cand
|
||||
break
|
||||
if browser_path:
|
||||
try:
|
||||
opts.set_browser_path(browser_path)
|
||||
print(f"[browser] path={browser_path}", flush=True)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# create_browser_options already handles turnstilePatch (skip on Google Chrome).
|
||||
# Only re-add here for the fallback options path on Chromium.
|
||||
ext_path = os.path.join(os.path.dirname(os.path.abspath(reg.__file__)), "turnstilePatch")
|
||||
already = False
|
||||
try:
|
||||
already = any(
|
||||
os.path.abspath(str(p)) == os.path.abspath(ext_path)
|
||||
for p in (getattr(opts, "extensions", None) or [])
|
||||
)
|
||||
except Exception:
|
||||
already = False
|
||||
if os.path.isdir(ext_path) and not already:
|
||||
is_chrome = bool(
|
||||
browser_path
|
||||
and "chrome" in os.path.basename(browser_path)
|
||||
and "chromium" not in browser_path
|
||||
)
|
||||
if is_chrome:
|
||||
print("[ext] skip turnstilePatch on Google Chrome (--load-extension blocked)", flush=True)
|
||||
else:
|
||||
try:
|
||||
opts.add_extension(ext_path)
|
||||
except Exception:
|
||||
pass
|
||||
return opts
|
||||
|
||||
|
||||
@@ -272,14 +302,33 @@ def register_one(
|
||||
return None
|
||||
|
||||
try:
|
||||
cfg = getattr(reg, "config", {}) or {}
|
||||
try:
|
||||
profile_timeout = int(cfg.get("profile_timeout", 120) or 120)
|
||||
except Exception:
|
||||
profile_timeout = 120
|
||||
try:
|
||||
# Prefer faster fail+retry over long dead waits; cap via config.
|
||||
sso_timeout = int(cfg.get("sso_timeout_base", 120) or 120)
|
||||
except Exception:
|
||||
sso_timeout = 120
|
||||
# Fast-fail band: keep CF stalls from dominating wall clock.
|
||||
# batch10 lesson: success profiles finish in ~6–18s; 40–50s CF fail is enough.
|
||||
profile_timeout = max(35, min(profile_timeout, 70))
|
||||
sso_timeout = max(30, min(sso_timeout, 90))
|
||||
|
||||
log(worker_id, "4. 填写资料")
|
||||
profile = reg.fill_profile_and_submit(
|
||||
log_callback=lambda m: log(worker_id, m), cancel_callback=cancel
|
||||
timeout=profile_timeout,
|
||||
log_callback=lambda m: log(worker_id, m),
|
||||
cancel_callback=cancel,
|
||||
)
|
||||
log(worker_id, f"资料已填: {profile.get('given_name')} {profile.get('family_name')}")
|
||||
log(worker_id, "5. 等待 sso cookie")
|
||||
sso = reg.wait_for_sso_cookie(
|
||||
log_callback=lambda m: log(worker_id, m), cancel_callback=cancel
|
||||
timeout=sso_timeout,
|
||||
log_callback=lambda m: log(worker_id, m),
|
||||
cancel_callback=cancel,
|
||||
)
|
||||
password = profile.get("password", "") or ""
|
||||
line = f"{email}----{password}----{sso}\n"
|
||||
|
||||
Reference in new issue
Block a user