proxy.core.acceptor package#

Submodules#

Module contents#

proxy.py#

⚡⚡⚡ Fast, Lightweight, Pluggable, TLS interception capable proxy server focused on Network monitoring, controls & Application development, testing, debugging.

copyright
  1. 2013-present by Abhinav Singh and contributors.

license

BSD, see LICENSE for more details.

class proxy.core.acceptor.Acceptor(idd: int, fd_queue: multiprocessing.connection.Connection, flags: argparse.Namespace, lock: multiprocessing.synchronize.Lock, executor_queues: List[multiprocessing.connection.Connection], executor_pids: List[int], executor_locks: List[multiprocessing.synchronize.Lock], event_queue: Optional[proxy.core.event.queue.EventQueue] = None)[source]#

Bases: multiprocessing.context.Process

Work acceptor process.

On start-up, Acceptor accepts a file descriptor which will be used to accept new work. File descriptor is accepted over a fd_queue.

Acceptor goes on to listen for new work over the received server socket. By default, Acceptor will spawn a new thread to handle each work.

However, when --threadless option is enabled without --local-executor, Acceptor process will also pre-spawns a Threadless process during start-up. Accepted work is delegated to these Threadless processes. Acceptor process shares accepted work with a Threadless process over it’s dedicated pipe.

_recv_and_setup_socks() None[source]#
_start_local() None[source]#
_stop_local() None[source]#
_work(conn: socket.socket, addr: Optional[Tuple[str, int]]) None[source]#
accept(events: List[Tuple[selectors.SelectorKey, int]]) List[Tuple[socket.socket, Optional[Tuple[str, int]]]][source]#
run() None[source]#

Method to be run in sub-process; can be overridden in sub-class

run_once() None[source]#
class proxy.core.acceptor.AcceptorPool(flags: argparse.Namespace, listeners: proxy.core.listener.pool.ListenerPool, executor_queues: List[multiprocessing.connection.Connection], executor_pids: List[int], executor_locks: List[multiprocessing.synchronize.Lock], event_queue: Optional[EventQueue] = None)[source]#

Bases: object

AcceptorPool is a helper class which pre-spawns Acceptor processes to utilize all available CPU cores for accepting new work.

A file descriptor to consume work from is shared with Acceptor processes over a pipe. Each Acceptor process then concurrently accepts new work over the shared file descriptor.

Example usage:

with AcceptorPool(flags=…) as pool:
while True:

time.sleep(1)

flags.work_klass must implement Work class.

_start() None[source]#

Start acceptor processes.

setup() None[source]#

Setup acceptors.

shutdown() None[source]#