Ejemplo n.º 1
0
def display_database_stats():
    data = database.Proxy().stats()

    place = 5

    q1 = round(data["q1"], place)
    avg = round(data["avg"], place)
    min = round(data["min"], place)
    max = round(data["max"], place)
    total = data["total"]
    health = (
        "Dead"
        if avg == 0
        else "Very-ill"
        if avg <= 0.10
        else "Ill"
        if avg <= 0.30
        else "Somewhat-ill"
        if avg <= 0.50
        else "Normal"
        if avg <= 0.70
        else "Healthy"
        if avg <= 0.9
        else "Very-healthy"
    )

    print(f"\nTotal Proxies: {total}\nDatabase's Health: {health}")
    print(
        f"Q1: {q1} :: Avg Score: {avg}  ::  Min Score: {min}  ::  Max Score: {max}"
    )
    time.sleep(0.65)
    def __init__(self):
        self.proxies = Queue()
        self.db_proxy = database.Proxy()
        self.proxy_finder = ProxyFinder()
        self.active_proxies: typing.List[dict] = []

        self.lock_active_proxies = threading.RLock()

        self.__offset: int = 0
        self.__limit: int = 256
        self.__min_score: float = 0.0
Ejemplo n.º 3
0
def main():
    arguments = args()
    mode = arguments.mode
    username = arguments.username
    passlist = arguments.passlist
    proxylist = arguments.proxylist
    prune = arguments.prune
    stats = arguments.stats
    prune_db = prune > 0

    if prune_db > 0 or stats:
        if prune_db > 0:
            prune_database(prune)
        if stats:
            display_database_stats()
    else:
        if proxylist:
            if not os.path.exists(proxylist):
                print("Invalid path to proxy list")
                exit()

            print(f"<<< Writing proxies to the database >>>")
            time.sleep(0.65)

            total_written = ProxyManager().write2db(proxylist)

            print(f"Proxies written to the database: {total_written}")
            time.sleep(0.65)

        total_proxies = len(database.Proxy().get_proxies())

        if username and passlist and total_proxies:

            if not os.path.exists(passlist):
                print("Invalid path to password list")
                exit()

            Engine(
                username, modes[mode], passlist, not arguments.color
            ).start()

        else:
            if not proxylist or total_proxies == 0:
                print("No proxies in the database and no proxy list provided")
    def write2db(self, proxylist_path: str) -> int:
        """Read proxies from the file and write it into the database.

        File must contain ip:port format.
        Returns: Number of rows written into the database.
        """

        total_written = 0
        with io.open(proxylist_path, mode="rt", encoding="utf-8") as f:
            proxy = database.Proxy()

            for line in f:
                ip, port = line.split(":")

                ip = ip.strip()
                port = port.split()[0].strip()

                if proxy.add_proxy(ip=ip, port=port):
                    total_written += 1
        return total_written