Bjo53 commited on
Commit
44a6638
·
verified ·
1 Parent(s): b17ced8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -34,9 +34,10 @@ def run_curl(method, url, data=None):
34
  cmd = [
35
  "curl", "-X", method, url,
36
  "--resolve", f"{domain}:443:{CLOUDFLARE_IP}",
37
- "-H", "User-Agent: Mozilla/5.0",
 
38
  "-H", "Content-Type: application/json",
39
- "-k", "-s", "--max-time", "30"
40
  ]
41
 
42
  input_str = None
@@ -45,11 +46,16 @@ def run_curl(method, url, data=None):
45
  input_str = json.dumps(data)
46
 
47
  try:
 
48
  result = subprocess.run(cmd, input=input_str, capture_output=True, text=True, timeout=35)
 
49
  if not result.stdout:
50
- return json.dumps({"ok": False, "description": "Empty Curl Response", "error_code": 500})
 
 
51
  return result.stdout
52
  except Exception as e:
 
53
  return json.dumps({"ok": False, "description": str(e), "error_code": 500})
54
 
55
  @bridge_app.route('/bot<token>/<method>', methods=['POST', 'GET'])
 
34
  cmd = [
35
  "curl", "-X", method, url,
36
  "--resolve", f"{domain}:443:{CLOUDFLARE_IP}",
37
+ # ⚡️ THE FIX: Full Windows Browser Spoof to bypass Cloudflare Bot Protection
38
+ "-H", "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
39
  "-H", "Content-Type: application/json",
40
+ "-k", "--max-time", "30"
41
  ]
42
 
43
  input_str = None
 
46
  input_str = json.dumps(data)
47
 
48
  try:
49
+ # I removed '-s' so curl will actually tell us if it fails
50
  result = subprocess.run(cmd, input=input_str, capture_output=True, text=True, timeout=35)
51
+
52
  if not result.stdout:
53
+ print(f" [CURL FAILED] STDERR: {result.stderr}")
54
+ return json.dumps({"ok": False, "description": f"Empty Curl Response. Error: {result.stderr}", "error_code": 500})
55
+
56
  return result.stdout
57
  except Exception as e:
58
+ print(f"❌ [BRIDGE CRASH] {e}")
59
  return json.dumps({"ok": False, "description": str(e), "error_code": 500})
60
 
61
  @bridge_app.route('/bot<token>/<method>', methods=['POST', 'GET'])