Harden dedicated-IP parser against real IPRoyal response (proxy_data.ip/ports/user/pass)
This commit is contained in:
33
app.py
33
app.py
@@ -334,21 +334,24 @@ def poll_provisioning():
|
||||
o = iproyal.get_order(row["iproyal_order_id"])
|
||||
status = o.get("status")
|
||||
if status == "confirmed":
|
||||
creds = o.get("proxies") or o.get("proxy") or o.get("data") or {}
|
||||
# creds may be a list of {host,port,username,password} or {ip,...}
|
||||
if isinstance(creds, list) and creds:
|
||||
creds = creds[0]
|
||||
host = creds.get("host") or creds.get("ip") or ""
|
||||
port = str(creds.get("port", ""))
|
||||
user = creds.get("username") or ""
|
||||
pw = creds.get("password") or ""
|
||||
d = db.get_db()
|
||||
d.execute("UPDATE dedicated_ips SET status='active', proxy_host=?, proxy_port=?,"
|
||||
"proxy_user=?, proxy_pass=?, expires_at=? WHERE id=?",
|
||||
(host, port, user, pw, int(time.time()) + row["plan_days"] * 86400, row["id"]))
|
||||
d.commit()
|
||||
d.close()
|
||||
ok += 1
|
||||
pd = o.get("proxy_data") or {}
|
||||
proxies = pd.get("proxies") or []
|
||||
ports = pd.get("ports") or {}
|
||||
if proxies:
|
||||
p = proxies[0]
|
||||
host = p.get("ip") or ""
|
||||
user = p.get("username") or ""
|
||||
pw = p.get("password") or ""
|
||||
socks_port = str(ports.get("socks5", ""))
|
||||
http_port = str(ports.get("http|https", ""))
|
||||
d = db.get_db()
|
||||
d.execute("UPDATE dedicated_ips SET status='active', proxy_host=?, proxy_port=?,"
|
||||
"http_port=?, proxy_user=?, proxy_pass=?, expires_at=? WHERE id=?",
|
||||
(host, socks_port, http_port, user, pw,
|
||||
int(time.time()) + row["plan_days"] * 86400, row["id"]))
|
||||
d.commit()
|
||||
d.close()
|
||||
ok += 1
|
||||
elif status in ("refunded", "expired"):
|
||||
d = db.get_db()
|
||||
d.execute("UPDATE dedicated_ips SET status='failed' WHERE id=?", (row["id"],))
|
||||
|
||||
Reference in New Issue
Block a user