proxy.http.websocket 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.http.websocket.WebSocketTransportBasePlugin(flags: argparse.Namespace, client: HttpClientConnection, event_queue: proxy.core.event.queue.EventQueue)[source]#

Bases: abc.ABC

Abstract class for plugins extending dashboard websocket API.

_abc_impl = <_abc._abc_data object>#
connected() None[source]#

Invoked when client websocket handshake finishes.

disconnected() None[source]#

Invoked when client websocket connection gets closed.

abstract handle_message(message: Dict[str, Any]) None[source]#

Handle messages for registered methods.

abstract methods() List[str][source]#

Return list of methods that this plugin will handle.

reply(data: Dict[str, Any]) None[source]#
class proxy.http.websocket.WebsocketClient(hostname: bytes, port: int, path: bytes = b'/', on_message: Optional[Callable[[proxy.http.websocket.frame.WebsocketFrame], None]] = None)[source]#

Bases: proxy.core.connection.connection.TcpConnection

Websocket client connection.

TODO: Make me compatible with the work framework.

_abc_impl = <_abc._abc_data object>#
property connection: Union[ssl.SSLSocket, socket.socket]#

Must return the socket connection to use in this class.

handshake() None[source]#

Start websocket upgrade & handshake protocol

run() None[source]#
run_once() bool[source]#
shutdown(_data: Optional[bytes] = None) None[source]#

Closes connection with the server.

upgrade() None[source]#

Creates a key and sends websocket handshake packet to upstream. Receives response from the server and asserts that websocket accept header is valid in the response.

class proxy.http.websocket.WebsocketFrame[source]#

Bases: object

Websocket frames parser and constructor.

GUID = b'258EAFA5-E914-47DA-95CA-C5AB0DC85B11'#
static apply_mask(data: bytes, mask: bytes) bytes[source]#
build() bytes[source]#
static key_to_accept(key: bytes) bytes[source]#
parse(raw: bytes) bytes[source]#
parse_fin_and_rsv(byte: int) None[source]#
parse_mask_and_payload(byte: int) None[source]#
reset() None[source]#
classmethod text(data: bytes) bytes[source]#