0

Similar to:

remote_addr - The remote user's IP address.

self.request.remote_addr

Instead, is there a way to get the remote user's hostname ? Something similar maybe like,

self.request.hostname

As from the official document, The Request Class, doesn't seem to have the option to get the remote user's hostname.

I'm trying to uniquely identify a machine, with the combination of hostname+ip, because there are some users may share the internet gateway, thus having same IP address is possible and that would make ip address not unique enough.

Any advice on this ? or at least, could anyone suggest alternative way to uniquely identify an machine with anonymous identity ?

MrCooL
  • 926
  • 3
  • 15
  • 30
  • The remote host's notion of its own name isn't transmitted over HTTP, so App Engine can't pass on this information to you. If reverse DNS were possible (which it isn't, because the socket library is unavailable), you could look up *a* name for a remote_addr, but that would be the same for every client with that IP, and therefore not be useful to you. – Adam Thomason Jul 12 '12 at 23:01
  • @AdamThomason, Exactly. I've searched around, and there were quite few people asked quite similar questions, and there seemed to be no answer for Sandbox restricted environment within App Engine. But, as you said, even if it's available, it would not be useful for my case. But appreciate for your sharing for me to understand better. Thanks. :) – MrCooL Jul 13 '12 at 02:17

2 Answers2

2

No, there's no way to do reverse DNS lookups on App Engine, and the information is not supplied by HTTP or the App Engine environment. Further, this wouldn't help you, for a couple of reasons:

  • The reverse DNS will be the same for every user with a given IP, since it depends only on the IP.
  • Anyone who has control over their reverse DNS can set it to anything they like.
Nick Johnson
  • 100,655
  • 16
  • 128
  • 198
  • do you have any suggestions for the best reliable way to achieve what I wanted as I described from my questions ? – MrCooL Jul 16 '12 at 13:14
  • No. If you come up with something reliable, feel free to start an abuse-detection company and become an instant millionaire! – Nick Johnson Jul 17 '12 at 04:57
1

I don't think this is possible over HTTP. Generally, cookies are used for this purpose.

dragonx
  • 14,963
  • 27
  • 44
  • Hi there, could you give more specific examples on how cookies will be able to grab the remote user's hostname ? – MrCooL Jul 12 '12 at 18:20
  • You can't get the hostname, that's at a lower level than HTTP knows about. But you can use cookies to uniquely identify machines. The first time a machine accesses your site, you generate and store a unique cookie on that machine's browser. When they access your site again, they'll send you the cookie. When two different machines behind the same IP access your site, you will see the two different cookies. If there's no cookie, then it's a new user. It's not 100% accurate though, since people can clear their cookies. – dragonx Jul 12 '12 at 18:49
  • This is what I'm worrying as most hackers are able to ignore the cookies or clear it off, but served as a pretty good alternative that I just thought of as well. Earlier, I thought your cookie solution would be able to grab the hostname, which is more reliable for my assumption. Thanks a lot though for the suggestion. – MrCooL Jul 13 '12 at 02:14