Skip to content
This repository has been archived by the owner on Dec 24, 2024. It is now read-only.

Commit

Permalink
_
Browse files Browse the repository at this point in the history
  • Loading branch information
xtsea authored Oct 4, 2024
1 parent 91f2a66 commit 998ae6c
Showing 1 changed file with 2 additions and 32 deletions.
34 changes: 2 additions & 32 deletions RyuzakiLib/hackertools/alldownloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import httpx
import requests
import wget
from fastapi import HTTPException


class DictToObj:
def __init__(self, dictionary):
Expand All @@ -25,40 +23,12 @@ class AkenoPlus:
def __init__(
self,
key: str = None,
api_endpoint: str = "https://private-akeno.randydev.my.id",
issue: bool = False,
ip_unban=None
api_endpoint: str = "https://private-akeno.randydev.my.id"
):
self.issue = issue

self.api_endpoint = api_endpoint
self.headers = {"x-akeno-key": key}

if isinstance(ip_unban, str):
self.ip_unban = [ip_unban]
elif isinstance(ip_unban, list):
self.ip_unban = ip_unban
else:
self.ip_unban = []

async def all_blacklist(self):
async with httpx.AsyncClient() as client:
try:
response = await client.get(f"{self.api_endpoint}/blacklist/list-ip/", headers=self.headers)
response.raise_for_status()
return response.json()["blacklisted_ips"]
except httpx.HTTPStatusError:
return []
except Exception:
return []

async def call_next(self, request, call_next):
banned_ips = await self.all_blacklist()
client_ip = request.headers.get("X-Real-IP") or request.client.host
if self.issue and client_ip in banned_ips and client_ip not in self.ip_unban:
raise HTTPException(status_code=403, detail="Your IP is banned.")
response = await call_next(request)
return response

async def download_now(self, data):
return wget.download(data)

Expand Down

0 comments on commit 998ae6c

Please sign in to comment.