small cookie fix

This commit is contained in:
2026-03-11 18:41:49 +01:00 Unverified
parent 369ef93d66
commit 1bb5c00876
+14 -1
View File
@@ -2,6 +2,7 @@
import argparse
import re
import urllib.error
import urllib.parse
import urllib.request
from pathlib import Path
@@ -86,6 +87,7 @@ def parseCookieFile(file: Path, domain: str) -> None:
def getSeedboxes(domain: str) -> tuple[list[dict], str]:
global COOKIE_HEADER
try:
req = urllib.request.Request(
f"https://{domain}/users/{parsed_args.username}/seedboxes",
@@ -94,6 +96,12 @@ def getSeedboxes(domain: str) -> tuple[list[dict], str]:
with urllib.request.urlopen(req) as resp:
html = resp.read().decode("utf-8")
for header, value in resp.getheaders():
if header.lower() == "set-cookie":
cookie_val = value.split(";")[0]
if cookie_val not in COOKIE_HEADER:
COOKIE_HEADER += f"; {cookie_val}"
token_match = re.search(
r'<meta\s+name="csrf-token"\s+content="([^"]+)"', html, re.IGNORECASE
)
@@ -187,7 +195,12 @@ def main():
data=data,
headers=generateHeaders(domain),
)
urllib.request.urlopen(req)
try:
urllib.request.urlopen(req)
except urllib.error.HTTPError as e:
if e.code != 302:
print(f"Failed to delete {sbox['name']}: HTTP {e.code}", flush=True)
if parsed_args.ip:
if addSeedbox(domain, add_token):