def _getrealname(addr):
    """
    Return a 2-tuple of socket IP and port for IPv4 and a 4-tuple of
    socket IP, port, flowInfo, and scopeID for IPv6.  For IPv6, it
    returns the interface portion (the part after the %) as a part of
    the IPv6 address, which Python 3.7+ does not include.

    @param addr: A 2-tuple for IPv4 information or a 4-tuple for IPv6
        information.
    """
    if len(addr) == 4:
        # IPv6
        host = socket.getnameinfo(
            addr, socket.NI_NUMERICHOST | socket.NI_NUMERICSERV)[0]
        return tuple([host] + list(addr[1:]))
    else:
        return addr[:2]

    Return a 2-tuple of socket IP and port for IPv4 and a 4-tuple of
    socket IP, port, flowInfo, and scopeID for IPv6.  For IPv6, it
    returns the interface portion (the part after the %) as a part of
    the IPv6 address, which Python 3.7+ does not include.

    @param addr: A 2-tuple for IPv4 information or a 4-tuple for IPv6
        information.
    
stackoverflow/venv/lib/python3.6/site-packages/twisted/internet/tcp.py