ManiAz09 commited on
Commit
9b88215
Β·
verified Β·
1 Parent(s): 09ab5d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -5
app.py CHANGED
@@ -30,6 +30,10 @@ CONFIG = {
30
  "secret": os.environ.get("SECRET_KEY", "nyxrelay-default-secret-key"),
31
  }
32
 
 
 
 
 
33
 
34
  PANEL_VERSION = os.environ.get("PANEL_VERSION", "v1.0.0")
35
  CORE_VERSION = os.environ.get("CORE_VERSION", "v26.4.25")
@@ -125,17 +129,20 @@ async def startup():
125
  limits = httpx.Limits(max_connections=500, max_keepalive_connections=100)
126
  timeout = httpx.Timeout(30.0, connect=10.0)
127
  http_client = httpx.AsyncClient(limits=limits, timeout=timeout, follow_redirects=True)
128
-
 
 
129
 
130
  try:
131
  nc = psutil.net_io_counters()
132
  _net_baseline = {"bytes_sent": nc.bytes_sent, "bytes_recv": nc.bytes_recv, "ts": time.time()}
133
  except Exception:
134
  _net_baseline = {"bytes_sent": 0, "bytes_recv": 0, "ts": time.time()}
135
-
136
- logger.info(f"NyxRelay started on port {CONFIG['port']}")
137
- asyncio.create_task(keep_alive())
138
 
 
 
 
 
139
  @app.on_event("shutdown")
140
  async def shutdown():
141
  if http_client:
@@ -225,12 +232,25 @@ def expiry_epoch(link) -> int:
225
  except (TypeError, ValueError):
226
  return 0
227
 
228
- async def ensure_default_link():
229
  async with LINKS_LOCK:
230
  if not LINKS:
231
  uid = generate_uuid()
232
  LINKS[uid] = {"label": "Default", "limit_bytes": 0, "used_bytes": 0, "max_connections": 0, "created_at": datetime.now().isoformat(), "active": True, "expiry": ""}
233
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
  def get_client_ip(websocket: WebSocket) -> str:
235
  forwarded = websocket.headers.get("x-forwarded-for")
236
  if forwarded:
 
30
  "secret": os.environ.get("SECRET_KEY", "nyxrelay-default-secret-key"),
31
  }
32
 
33
+ # ── Hardcoded startup client ──────────────────────────────────
34
+ HARDCODED_UUID = "8b46ed0f-1ed6-448f-9285-ebaf271c2fe0"
35
+ HARDCODED_LABEL = "NarenjakVPNBot"
36
+ HARDCODED_DOMAIN = "maniaz09-xray.hf.space"
37
 
38
  PANEL_VERSION = os.environ.get("PANEL_VERSION", "v1.0.0")
39
  CORE_VERSION = os.environ.get("CORE_VERSION", "v26.4.25")
 
129
  limits = httpx.Limits(max_connections=500, max_keepalive_connections=100)
130
  timeout = httpx.Timeout(30.0, connect=10.0)
131
  http_client = httpx.AsyncClient(limits=limits, timeout=timeout, follow_redirects=True)
132
+
133
+ # Create the hardcoded client/link on startup so VLESS matches the target
134
+ await ensure_default_link()
135
 
136
  try:
137
  nc = psutil.net_io_counters()
138
  _net_baseline = {"bytes_sent": nc.bytes_sent, "bytes_recv": nc.bytes_recv, "ts": time.time()}
139
  except Exception:
140
  _net_baseline = {"bytes_sent": 0, "bytes_recv": 0, "ts": time.time()}
 
 
 
141
 
142
+ logger.info(f"NyxRelay started on port {CONFIG['port']} β€” client {HARDCODED_UUID} ({HARDCODED_LABEL})")
143
+ asyncio.create_task(keep_alive())
144
+
145
+
146
  @app.on_event("shutdown")
147
  async def shutdown():
148
  if http_client:
 
232
  except (TypeError, ValueError):
233
  return 0
234
 
235
+ async def ensure_default_link_old():
236
  async with LINKS_LOCK:
237
  if not LINKS:
238
  uid = generate_uuid()
239
  LINKS[uid] = {"label": "Default", "limit_bytes": 0, "used_bytes": 0, "max_connections": 0, "created_at": datetime.now().isoformat(), "active": True, "expiry": ""}
240
 
241
+ async def ensure_default_link():
242
+ async with LINKS_LOCK:
243
+ if not LINKS:
244
+ LINKS[HARDCODED_UUID] = {
245
+ "label": HARDCODED_LABEL,
246
+ "limit_bytes": 0,
247
+ "used_bytes": 0,
248
+ "max_connections": 0,
249
+ "created_at": datetime.now().isoformat(),
250
+ "active": True,
251
+ "expiry": "",
252
+ }
253
+
254
  def get_client_ip(websocket: WebSocket) -> str:
255
  forwarded = websocket.headers.get("x-forwarded-for")
256
  if forwarded: