Compare commits
6 Commits
codex/add-
...
codex/add-
| Author | SHA1 | Date | |
|---|---|---|---|
| f1267a46a1 | |||
| 9baf87cc33 | |||
| d57948af82 | |||
| 93310e3d99 | |||
| 00c72a78d2 | |||
| 2891466635 |
@@ -56,7 +56,7 @@ POLL_SECONDS = float(os.environ.get("POLL_SECONDS", "5"))
|
||||
|
||||
# JDownloader writes here inside container
|
||||
JD_OUTPUT_PATH = "/output"
|
||||
PROXY_EXPORT_PATH = os.environ.get("PROXY_EXPORT_PATH", "/output/jd-proxies.txt")
|
||||
PROXY_EXPORT_PATH = os.environ.get("PROXY_EXPORT_PATH", "/output/jd-proxies.jdproxies")
|
||||
|
||||
URL_RE = re.compile(r"^https?://", re.I)
|
||||
|
||||
@@ -366,15 +366,55 @@ def fetch_proxy_list(url: str) -> str:
|
||||
with urllib.request.urlopen(req, timeout=20) as resp:
|
||||
return resp.read().decode("utf-8", "replace")
|
||||
|
||||
def save_proxy_export(text: str) -> str:
|
||||
def build_jdproxies_payload(text: str) -> Dict[str, Any]:
|
||||
if not text.strip():
|
||||
raise ValueError("Keine Proxy-Einträge zum Speichern.")
|
||||
entries: List[Dict[str, Any]] = []
|
||||
type_map = {
|
||||
"socks5": "SOCKS5",
|
||||
"socks4": "SOCKS4",
|
||||
"http": "HTTP",
|
||||
}
|
||||
for line in text.splitlines():
|
||||
s = line.strip()
|
||||
if not s:
|
||||
continue
|
||||
parsed = urllib.parse.urlparse(s)
|
||||
if not parsed.scheme or not parsed.hostname or parsed.port is None:
|
||||
continue
|
||||
proxy_type = type_map.get(parsed.scheme.lower())
|
||||
if not proxy_type:
|
||||
continue
|
||||
entries.append({
|
||||
"filter": None,
|
||||
"proxy": {
|
||||
"address": parsed.hostname,
|
||||
"password": None,
|
||||
"port": int(parsed.port),
|
||||
"type": proxy_type,
|
||||
"username": None,
|
||||
"connectMethodPrefered": False,
|
||||
"preferNativeImplementation": False,
|
||||
"resolveHostName": False,
|
||||
},
|
||||
"enabled": True,
|
||||
"pac": False,
|
||||
"rangeRequestsSupported": True,
|
||||
"reconnectSupported": False,
|
||||
})
|
||||
if not entries:
|
||||
raise ValueError("Keine gültigen Proxy-Einträge gefunden.")
|
||||
return {"customProxyList": entries}
|
||||
|
||||
def save_proxy_export(text: str) -> str:
|
||||
payload = build_jdproxies_payload(text)
|
||||
export_path = PROXY_EXPORT_PATH
|
||||
export_dir = os.path.dirname(export_path)
|
||||
if export_dir:
|
||||
os.makedirs(export_dir, exist_ok=True)
|
||||
with open(export_path, "w", encoding="utf-8") as handle:
|
||||
handle.write(text.strip() + "\n")
|
||||
handle.write(json.dumps(payload, indent=2))
|
||||
handle.write("\n")
|
||||
return export_path
|
||||
|
||||
def pick_library_target(library_choice: str, filename: str, package_name: str) -> str:
|
||||
@@ -894,13 +934,13 @@ def render_proxies_page(
|
||||
<button type="button" onclick="navigator.clipboard.writeText(document.getElementById('out').value)">Kopieren</button>
|
||||
|
||||
<h2 style="margin-top:18px;">Datei für Connection Manager</h2>
|
||||
<p class="hint">Speichert die Liste als TXT im Container, z. B. zum Import in JDownloader → Verbindungsmanager → Importieren.</p>
|
||||
<p class="hint">Speichert die Liste als <code>.jdproxies</code> im Container, z. B. zum Import in JDownloader → Verbindungsmanager → Importieren.</p>
|
||||
|
||||
<form method="post" action="/proxies/save">
|
||||
<textarea name="socks5_in" style="display:none;">{socks5_in}</textarea>
|
||||
<textarea name="socks4_in" style="display:none;">{socks4_in}</textarea>
|
||||
<textarea name="http_in" style="display:none;">{http_in}</textarea>
|
||||
<button type="submit">Liste als TXT speichern</button>
|
||||
<button type="submit">Liste als JDProxies speichern</button>
|
||||
</form>
|
||||
|
||||
<p class="hint">Aktueller Pfad: <code>{export_path or PROXY_EXPORT_PATH}</code></p>
|
||||
|
||||
Reference in New Issue
Block a user