code: def from_localhost(self) -> bool:
          
          sock_family = self.socket.family
          if sock_family == _socket.AF_UNIX:
              return True
          elif sock_family not in (_socket.AF_INET, _socket.AF_INET6):
              return False
          sock_address, *_ = self.peername
          ip = ipaddress.ip_address(sock_address)
          if ip.version == 6 and ip.ipv4_mapped is not None:
              ip = ipaddress.ip_address(ip.ipv4_mapped)
          return ip.is_loopback
docs: True if :attr:`.peername` is a connection from a ``localhost``
          address.