def websocket_start(self, f): if ctx.options.stream_websockets: f.stream = True ctx.log.info( "Streaming WebSocket messages between {client} and {server}". format(client=human.format_address(f.client_conn.address), server=human.format_address(f.server_conn.address)))
def message_info(self, message: WebSocketMessage) -> str: return "{client} {direction} WebSocket {type} message {direction} {server}{endpoint}".format( type=message.type, client=human.format_address(self.client_conn.address), server=human.format_address(self.server_conn.address), direction="->" if message.from_client else "<-", endpoint=self.handshake_flow.request.path, )
def __repr__(self): if self.tls_established: tls = "[{}] ".format(self.tls_version) else: tls = "" if self.alpn_proto_negotiated: alpn = "[ALPN: {}] ".format( strutils.bytes_to_escaped_str(self.alpn_proto_negotiated)) else: alpn = "" return "<ClientConnection: {tls}{alpn}{address}>".format( tls=tls, alpn=alpn, address=human.format_address(self.address), )
def log(self, msg, level): msg = "{}: {}".format(human.format_address(self.client_conn.address), msg) self.channel.tell("log", log.LogEntry(msg, level))