Commit e73764de authored by Maiken's avatar Maiken
Browse files

Merge branch 'twisted-get-client-fix' into 'master'

Fix issue with twisted getClient()

See merge request !243
parents d3821a81 1c705968
......@@ -2,6 +2,8 @@
resource to fetch a bloom filter from
"""
import socket
from twisted.python import log
from twisted.web import resource
......@@ -18,10 +20,22 @@ class CacheResource(resource.Resource):
def render_GET(self, request):
try:
clienthost = request.getClientAddress() # twisted >= 18.4
clienthost = request.getClientAddress().host # twisted >= 18.4
except:
clienthost = request.getClient() # twisted < 18.4
client = clienthost + "/" + request.getClientIP()
clienthost = request.getClientIP() # twisted < 18.4
def getClient(host):
try:
name, names, addresses = socket.gethostbyaddr(host)
except socket.error:
return host
names.insert(0, name)
for name in names:
if '.' in name:
return name
return names[0]
client = getClient(clienthost) + "/" + clienthost
log.msg("GET request on cache from %s" % client)
gen_time, hashes, cache, cache_url = self.cache_service.getCache()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment