def contact_address(self): """ The contact address as a string. """ host, port = self.get_host_port() host = ensure_concrete_host(host, default_host=self.default_host) return self.prefix + unparse_host_port(host, port)
def peer_addr(self): if self.is_closed: return "<closed>" peername = self._transport.get_extra_info("peername") if peername is not None: return unparse_host_port(*peername[:2]) return "<unknown>"
def local_addr(self): if self.is_closed: return "<closed>" sockname = self._transport.get_extra_info("sockname") if sockname is not None: return unparse_host_port(*sockname[:2]) return "<unknown>"
def get_local_address_for(self, loc): host, port = parse_host_port(loc) host = ensure_ip(host) if ":" in host: local_host = get_ipv6(host) else: local_host = get_ip(host) return unparse_host_port(local_host, None)
def get_stream_address(comm): """ Get a stream's local address. """ if comm.closed(): return "<closed>" try: return unparse_host_port(*comm.socket.getsockname()[:2]) except OSError: # Probably EBADF return "<closed>"
async def _handle_stream(self, stream, address): address = self.prefix + unparse_host_port(*address[:2]) stream = await self._prepare_stream(stream, address) if stream is None: # Preparation failed return logger.debug("Incoming connection from %r to %r", address, self.contact_address) local_address = self.prefix + get_stream_address(stream) comm = self.comm_class(stream, local_address, address, self.deserialize) comm.allow_offload = self.allow_offload try: await self.on_connection(comm) except CommClosedError: logger.info("Connection from %s closed before handshake completed", address) return await self.comm_handler(comm)
def resolve_address(self, loc): host, port = parse_host_port(loc) return unparse_host_port(ensure_ip(host), port)
def listen_address(self): """ The listening address as a string. """ return self.prefix + unparse_host_port(*self.get_host_port())
def contact_address(self): host, port = self.get_host_port() host = ensure_concrete_host(host) # TODO: ensure_concrete_host return self.prefix + unparse_host_port(host, port)
def listen_address(self): return self.prefix + unparse_host_port(*self.get_host_port())