def test_get_remote_addr_with_socket(): transport = MockTransport({"socket": MockSocket(family=socket.AF_IPX)}) assert get_remote_addr(transport) is None transport = MockTransport( {"socket": MockSocket(family=socket.AF_INET6, peername=["::1", 123])} ) assert get_remote_addr(transport) == ("::1", 123) transport = MockTransport( {"socket": MockSocket(family=socket.AF_INET, peername=["123.45.6.7", 123])} ) assert get_remote_addr(transport) == ("123.45.6.7", 123)
def connection_made(self, transport): self.connections.add(self) self.transport = transport self.server = get_local_addr(transport) self.client = get_remote_addr(transport) self.scheme = "wss" if is_ssl(transport) else "ws" super().connection_made(transport)
def connection_made(self, transport): self.connections.add(self) self.transport = transport self.server = get_local_addr(transport) self.client = get_remote_addr(transport) self.scheme = "wss" if is_ssl(transport) else "ws" if self.logger.level <= TRACE_LOG_LEVEL: prefix = "%s:%d - " % tuple(self.client) if self.client else "" self.logger.log(TRACE_LOG_LEVEL, "%sWebSocket connection made", prefix)
def test_get_remote_addr_with_socket(): transport = MockTransport({"socket": MockSocket(family=socket.AF_IPX)}) assert get_remote_addr(transport) is None transport = MockTransport( {"socket": MockSocket(family=socket.AF_INET6, peername=("::1", 123))} ) assert get_remote_addr(transport) == ("::1", 123) transport = MockTransport( {"socket": MockSocket(family=socket.AF_INET, peername=("123.45.6.7", 123))} ) assert get_remote_addr(transport) == ("123.45.6.7", 123) if hasattr(socket, "AF_UNIX"): transport = MockTransport( {"socket": MockSocket(family=socket.AF_UNIX, peername=("127.0.0.1", 8000))} ) assert get_remote_addr(transport) == ("127.0.0.1", 8000)
def connection_made(self, transport): self.connections.add(self) self.transport = transport self.flow = FlowControl(transport) self.server = get_local_addr(transport) self.client = get_remote_addr(transport) self.scheme = "https" if is_ssl(transport) else "http" if self.logger.level <= logging.DEBUG: self.logger.debug("%s - Connected", self.client)
def connection_made(self, transport): self.connections.add(self) self.transport = transport self.flow = FlowControl(transport) self.server = get_local_addr(transport) self.client = get_remote_addr(transport) self.scheme = "https" if is_ssl(transport) else "http" if self.logger.level <= TRACE_LOG_LEVEL: prefix = "%s:%d - " % tuple(self.client) if self.client else "" self.logger.log(TRACE_LOG_LEVEL, "%sHTTP connection made", prefix)
def connection_made(self, transport: asyncio.Transport): self.connections.add(self) self.transport = transport self.flow = FlowControl(transport) self.addr_local = get_local_addr(transport) self.addr_remote = get_remote_addr(transport) self.scheme = "https" if is_ssl(transport) else "http" if self.logger.level <= TRACE_LOG_LEVEL: prefix = "%s:%d - " % tuple( self.addr_remote) if self.addr_remote else "" self.logger.log(TRACE_LOG_LEVEL, "%sConnection made", prefix)
def connection_made( # type: ignore[override] self, transport: asyncio.Transport) -> None: self.connections.add(self) self.transport = transport self.flow = FlowControl(transport) self.server = get_local_addr(transport) self.client = get_remote_addr(transport) self.scheme = "https" if is_ssl(transport) else "http" if self.logger.level <= TRACE_LOG_LEVEL: prefix = "%s:%d - " % self.client if self.client else "" self.logger.log(TRACE_LOG_LEVEL, "%sHTTP connection made", prefix)
def test_get_remote_addr(): transport = MockTransport({"peername": None}) assert get_remote_addr(transport) is None transport = MockTransport({"peername": ["123.45.6.7", 123]}) assert get_remote_addr(transport) == ("123.45.6.7", 123)