Search code examples
pythongoogle-app-engineweb2pyreverse-lookup

Finding the domain name of a site that is hotlinking in Google app engine using web2py


Let's say we have an image in the Google App Engine and sites are hotlinking it. How can I find the domain names of the sites?

My first thought was:

request.client

and then do a reverse lookup but that it's not possible in GAE and would take a lot of time. I am pretty sure that there is a property that allows me to get the url of the site that is requesting the file (somewhere in request?). GAE has a Request class but I couldn't make it work inside web2py.

Any ideas?


Solution

  • You can easily get the referrer from the request headers. This referrer can be spoofed, but most people do not spoof it and it is already resolved.

    There is no automatic way to resolve the DNS other than manually resolving it. Like you said, a DNS resolution takes extra time and it makes no sense for Web2Py or any other framework to do it.