proxy.proxy module#

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.proxy.GroutClientBasePlugin[source]#

Bases: abc.ABC

Base class for dynamic grout client rules.

Implementation of this class must be stateless because a new instance is created for every route decision making.

_abc_impl = <_abc._abc_data object>#
abstract resolve_route(route: str, request: proxy.http.parser.parser.HttpParser, origin: Tuple[str, int], server: Tuple[str, int]) Tuple[Optional[str], proxy.http.parser.parser.HttpParser][source]#

Returns a valid grout route string.

You MUST override this method. This method returns 2-tuple where first value is the “route” and second the “request” object.

For a simple pass through, simply return the “route” argument value itself. You can also return a dynamic value based upon “request” and “origin” information. E.g. sending to different upstream services based upon request Host header. Return None as “route” value to drop the request.

You can also modify the original request object and return. Common examples include strip-path scenario, where you would like to strip the path before sending the request to upstream.

class proxy.proxy.Proxy(input_args: Optional[List[str]] = None, **opts: Any)[source]#

Bases: object

Proxy is a context manager to control proxy.py library core.

By default, AcceptorPool is started with HttpProtocolHandler work class. By definition, it expects HTTP traffic to flow between clients and server.

In --threadless mode and without --local-executor, a ThreadlessPool is also started. Executor pool receives newly accepted work by Acceptor and creates an instance of work class for processing the received work.

In --threadless mode and with --local-executor 0, acceptors will start a companion thread to handle accepted client connections.

Optionally, Proxy class also initializes the EventManager. A multi-process safe pubsub system which can be used to build various patterns for message sharing and/or signaling.

_delete_pid_file() None[source]#
_delete_port_file() None[source]#
static _handle_exit_signal(signum: int, _frame: Any) None[source]#
_handle_siginfo(_signum: int, _frame: Any) None[source]#
_register_signals() None[source]#
static _setup_tunnel(flags: argparse.Namespace, ssh_handler_klass: Optional[Type[BaseSshTunnelHandler]] = None, ssh_listener_klass: Optional[Any] = None, **kwargs: Any) proxy.core.ssh.base.BaseSshTunnelListener[source]#
_write_pid_file() None[source]#
_write_port_file() None[source]#
property remote_executors_enabled: bool#
setup() None[source]#
shutdown() None[source]#
proxy.proxy.entry_point() None[source]#
proxy.proxy.grout() None[source]#
proxy.proxy.main(**opts: Any) None[source]#
proxy.proxy.sleep_loop(p: Optional[proxy.proxy.Proxy] = None) None[source]#