gethostbyaddr

Django get client's domain name/host name

别等时光非礼了梦想. 提交于 2019-12-14 03:42:32
问题 What is the easiest way to obtain the user's host/domain name, if available? Or is there a function to lookup the IP address of the user to see if it is bound to a named address? (i.e. gethostbyaddr() in PHP) HttpRequest.get_host() only returns the IP address of the user. 回答1: You can't rely on it, but you can try the request.META['REMOTE_HOST'] or request.META['HTTP_HOST'] from the META dictionary of the request : A standard Python dictionary containing all available HTTP headers. Available

Python Sockets: gethostbyaddr : Reverse DNS Lookup Failure

我只是一个虾纸丫 提交于 2019-12-12 23:42:12
问题 I've been having a problem with getting the host name while using socket.gethostbyaddr(ip_addr) on specific sites. I will not go into detail about which site this is not working for. so getting the host by name works fine for every site I've tried so far , but then when I try to get the site name from I get an error say ing host not found . A fix or an alternative would be nice for this to have complete data. If there is no fix I can merely leave out the host name. no biggie. Thanks for the

herror deprecated

萝らか妹 提交于 2019-12-12 14:31:32
问题 Answering another question, I stumbled upon the man page of a function called herror . It appears to be very much like perror except it prints errors related to some host lookup problem. The man page states that this function is “obsolete”. A function hsterror which could be used to turn the error number into a string without printing it is marked obsolete as well. What I don't see is any indication as to why either of them is obsolete, and what replacement should be used instead. So what is

Django get client's domain name/host name

℡╲_俬逩灬. 提交于 2019-12-04 17:48:32
What is the easiest way to obtain the user's host/domain name, if available? Or is there a function to lookup the IP address of the user to see if it is bound to a named address? (i.e. gethostbyaddr() in PHP) HttpRequest.get_host() only returns the IP address of the user. You can't rely on it, but you can try the request.META['REMOTE_HOST'] or request.META['HTTP_HOST'] from the META dictionary of the request : A standard Python dictionary containing all available HTTP headers. Available headers depend on the client and server, but here are some examples: - REMOTE_HOST -- The hostname of the

Difficulty using Python's socket.gethostbyaddr()

给你一囗甜甜゛ 提交于 2019-11-30 18:59:00
I am trying to reverse dns a list of IPs using socket.gethostbyaddr() in python, which returns 'Unknown Host' for some values, but using dig for the same ip returns the Hostname. Also, dig seems to be significantly faster than using python module, is there any specific reasons for that? import socket # This returns 'Unknown Host' name, alias, addresslist = socket.gethostbyaddr('114.143.51.197') I'm sorry, but you are mistaken. 114.143.51.197 does not have a PTR record... therefore socket.gethostbyaddr() should throw an error... you certainly need a try / except clause that traps for socket

Difficulty using Python's socket.gethostbyaddr()

放肆的年华 提交于 2019-11-30 03:04:14
问题 I am trying to reverse dns a list of IPs using socket.gethostbyaddr() in python, which returns 'Unknown Host' for some values, but using dig for the same ip returns the Hostname. Also, dig seems to be significantly faster than using python module, is there any specific reasons for that? import socket # This returns 'Unknown Host' name, alias, addresslist = socket.gethostbyaddr('114.143.51.197') 回答1: I'm sorry, but you are mistaken. 114.143.51.197 does not have a PTR record... therefore socket

InetAddress.getCanonicalHostName() returns IP instead of Hostname

不问归期 提交于 2019-11-28 07:07:31
问题 I looked for how to do IP lookup in Java on Stack Overflow but the answers match what I am already doing and do not resolve my problem. Here is my code: public void printHostname( String ip ) { System.out.println( InetAddresses.forString( ip ).getCanonicalHostName( ) ); } InetAddresses is just a utility class from guava library to get a InetAdress . The problem: This code works as expected with some IP adresses and not with some others. A working example For example, for IP 157.55.39.29, the