Get the reverse DNS entry for this connection.
Used later on for webirc, etc functionality
776871
function initialiseSocket(socket, callback) {
    var request = socket.request,
        address = request.meta.remote_address,
        revdns;

    // Key/val data stored to the socket to be read later on
    // May also be synced to a redis DB to lookup clients
    socket.meta = socket.request.meta;

    // If a forwarded-for header is found, switch the source address
    if (request.headers[global.config.http_proxy_ip_header || 'x-forwarded-for']) {
        // Check we're connecting from a whitelisted proxy
        if (!global.config.http_proxies || !rangeCheck(address, global.config.http_proxies)) {
            winston.info('Unlisted proxy: %s', address);
            callback(null, false);
            return;
        }

        // We're sent from a whitelisted proxy, replace the hosts
        address = request.headers[global.config.http_proxy_ip_header || 'x-forwarded-for'];

        // Multiple reverse proxies will have a comma delimited list of IPs. We only need the first
        address = address.split(',')[0].trim();

        // Some reverse proxies (IIS) may include the port, so lets remove that (if ipv4)
        if (address.indexOf('.') > -1) {
            address = (address || '').split(':')[0];
        }
    }

    socket.meta.real_address = address;

    // If enabled, don't go over the connection limit
    if (global.config.max_client_conns && global.config.max_client_conns > 0) {
        if (global.clients.numOnAddress(address) + 1 > global.config.max_client_conns) {
            return callback(null, false);
        }
    }


    try {
        dns.reverse(address, function (err, domains) {
            if (!err && domains.length > 0) {
                revdns = _.first(domains);
            }

            if (!revdns) {
                // No reverse DNS found, use the IP
                socket.meta.revdns = address;
                callback(null, true);

            } else {
                // Make sure the reverse DNS matches the A record to use the hostname..
                dns.lookup(revdns, function (err, ip_address, family) {
                    if (!err && ip_address == address) {
                        // A record matches PTR, perfectly valid hostname
                        socket.meta.revdns = revdns;
                    } else {
                        // A record does not match the PTR, invalid hostname
                        socket.meta.revdns = address;
                    }

                    // We have all the info we need, proceed with the connection
                    callback(null, true);
                });
            }
        });

    } catch (err) {
        socket.meta.revdns = address;
        callback(null, true);
    }
}
739751
def to_address(name):
    
    if name.is_subdomain(ipv4_reverse_domain):
        name = name.relativize(ipv4_reverse_domain)
        labels = list(name.labels)
        labels.reverse()
        text = '.'.join(labels)
        # run through inet_aton() to check syntax and make pretty.
        return dns.ipv4.inet_ntoa(dns.ipv4.inet_aton(text))
    elif name.is_subdomain(ipv6_reverse_domain):
        name = name.relativize(ipv6_reverse_domain)
        labels = list(name.labels)
        labels.reverse()
        parts = []
        i = 0
        l = len(labels)
        while i < l:
            parts.append(''.join(labels[i:i+4]))
            i += 4
        text = ':'.join(parts)
        # run through inet_aton() to check syntax and make pretty.
        return dns.ipv6.inet_ntoa(dns.ipv6.inet_aton(text))
    else:
        raise dns.exception.SyntaxError('unknown reverse-map address family')
257677
def reverse(viewname, urlconf=None, args=None, kwargs=None, prefix=None):
    """"""
    prefixer = get_url_prefix()

    if prefixer:
        prefix = prefix or '/'
    url = django_reverse(viewname, urlconf, args, kwargs, prefix)
    if prefixer:
        url = prefixer.fix(url)

    # Ensure any unicode characters in the URL are escaped.
    return iri_to_uri(url)
622111
public String getHostByAddr(byte [] addr) throws UnknownHostException {
	Name name = ReverseMap.fromAddress(InetAddress.getByAddress(addr));
	Record [] records = new Lookup(name, Type.PTR).run();
	if (records == null)
		throw new UnknownHostException();
	return ((PTRRecord) records[0]).getTarget().toString();
}
838681
def get_dyndns_records(login, password):
    """"""
    params = dict(action='getdyndns', sha=get_auth_key(login, password))
    response = requests.get('http://freedns.afraid.org/api/', params=params, timeout=timeout)
    raw_records = (line.split('|') for line in response.content.split())

    try:
        records = frozenset(DnsRecord(*record) for record in raw_records)
    except TypeError:
        raise ApiError("Couldn't parse the server's response",
                response.content)

    return records
315642
def get_namespace_entry(self, url: str, name: str) -> Optional[NamespaceEntry]:
        
        entry_filter = and_(Namespace.url == url, NamespaceEntry.name == name)
        result = self.session.query(NamespaceEntry).join(Namespace).filter(entry_filter).all()

        if 0 == len(result):
            return

        if 1 < len(result):
            log.warning('result for get_namespace_entry is too long. Returning first of %s', [str(r) for r in result])

        return result[0]
783421
def reverse_http_proxy(length: int=100):
    """"""

    http_request = """
GET / HTTP/1.0\r\n\r\n
Host: www.google.com\r\n\r\n
\r\n\r\n
"""
    return http_socket.request(http_request, timeout=5.0).data.read()[0:length]
302829
def connection_check(addr, port=80, safe=False, ipv6=None):
    '''
    
    '''
    return dns_check(addr, port, safe, ipv6)
418746
def reverse_ip_whois(self, query=None, ip=None, country=None, server=None, include_total_count=False, page=1,
                         **kwargs):
        """"""
        if (ip and query) or not (ip or query):
            raise ValueError('Query or IP Address (but not both) must be defined')

        return self._results('reverse-ip-whois', '/v1/reverse-ip-whois', query=query, ip=ip, country=country,
                            server=server, include_total_count=include_total_count, page=page, items_path=('records', ),
                            **kwargs)
1084276
private static String getHostPort(SocketAddress address) {
        if (address instanceof ResourceAddress) {
            ResourceAddress lowest = getLowestTransportLayer((ResourceAddress)address);
            return format(HOST_PORT_FORMAT, lowest.getResource().getHost(), lowest.getResource().getPort());
        }
        if (address instanceof InetSocketAddress) {
            InetSocketAddress inet = (InetSocketAddress)address;
            // we don't use inet.toString() because it would include a leading /, for example "/127.0.0.1:21345"
            // use getHostString() to avoid a reverse DNS lookup
            return format(HOST_PORT_FORMAT, inet.getHostString(), inet.getPort());
        }
        return null;
    }
660810
def reverse(location, provider="google", **kwargs):
    
    return get(location, method='reverse', provider=provider, **kwargs)
800353
def modLocationPort(self, location):
        
        components = urlparse.urlparse(location)
        reverse_proxy_port = self.father.getHost().port
        reverse_proxy_host = self.father.getHost().host
        # returns an ordered dict of urlparse.ParseResult components
        _components = components._asdict()
        _components['netloc'] = '%s:%d' % (
            reverse_proxy_host, reverse_proxy_port
        )
        return urlparse.urlunparse(_components.values())
953224
def get_callback_url(self, provider):
        """"""
        info = self.model._meta.app_label, self.model._meta.model_name
        return reverse('admin:%s_%s_callback' % info, kwargs={'provider': provider.id})
234679
def getRequestedNameIface(self, iface_num=0, num=None, default_hostname=None, default_domain=None):
        """"""

        full_name = self.getValue("net_interface.%d.dns_name" % iface_num)

        if full_name:
            replaced_full_name = system.replaceTemplateName(full_name, num)
            (hostname, domain) = replaced_full_name
            if not domain:
                domain = default_domain
            return (hostname, domain)
        else:
            if default_hostname:
                (hostname, _) = system.replaceTemplateName(default_hostname, num)
                return (hostname, default_domain)
            else:
                return None
375012
def _getaddrinfo(self, host: str, family: int=socket.AF_UNSPEC) \
            -> List[tuple]:
        '''
        '''
        event_loop = asyncio.get_event_loop()
        query = event_loop.getaddrinfo(host, 0, family=family,
                                       proto=socket.IPPROTO_TCP)

        if self._timeout:
            query = asyncio.wait_for(query, self._timeout)

        try:
            results = yield from query
        except socket.error as error:
            if error.errno in (
                    socket.EAI_FAIL,
                    socket.EAI_NODATA,
                    socket.EAI_NONAME):
                raise DNSNotFound(
                    'DNS resolution failed: {error}'.format(error=error)
                ) from error
            else:
                raise NetworkError(
                    'DNS resolution error: {error}'.format(error=error)
                ) from error
        except asyncio.TimeoutError as error:
            raise NetworkError('DNS resolve timed out.') from error
        else:
            return results
1059084
def backend(entry):
    
    return '%s://%s%s' % (
        PROTOCOL, Site.objects.get_current().domain,
        reverse('zinnia:entry_shortlink', args=[base36(entry.pk)]))
1191769
def reverse_url(self, name: str, *args: Any) -> str:
        """"""
        return self.application.reverse_url(name, *args)