def getChild(self, path, request): """ Create and return a proxy resource with the same proxy configuration as this one, except that its path also contains the segment given by C{path} at the end. """ print "Requesting url: " + self.host + b'/' + urlquote( path, safe=b"").encode('utf-8') return SSLReverseProxyResource( self.host, self.port, self.path + b'/' + urlquote(path, safe=b"").encode('utf-8'), self.reactor)
def getChild(self, path, request): """ Create and return a proxy resource with the same proxy configuration as this one, except that its path also contains the segment given by C{path} at the end. """ self.uuid = str(uuid.uuid1()) self.logDebug( "getChild", "Requesting url: " + self.host + b'/' + urlquote(path, safe=b"").encode('utf-8')) return SSLActiveSyncProxyResource( self.host, self.port, self.path + b'/' + urlquote(path, safe=b"").encode('utf-8'), self.reactor, newuuid=self.uuid)
def getChild(self, path, request): return ExtReverseProxyResource( self.host, self.port, self.path + b'/' + urlquote(path, safe=b"").encode('utf-8'), forwarded_port=self._forwarded_port, forwarded_proto=self._forwarded_proto)
def getChild(self, path, request): """ see ReverseProxyResource.getChild() """ return ExtractionReverseProxyResource( self._extraction, self._backend, self._hostport, self._path + b"/" + urlquote(path, safe=b"").encode("utf-8"))
def _reconstitute(self): """ Reconstitute this L{URLPath} from all its given attributes. """ urltext = urlquote( urlparse.urlunsplit((self._scheme, self._netloc, self._path, self._query, self._fragment)), safe=_allascii ) self._url = _URL.fromText(urltext.encode("ascii").decode("ascii"))
def _reconstitute(self): """ Reconstitute this L{URLPath} from all its given attributes. """ urltext = urlquote(urlparse.urlunsplit( (self._scheme, self._netloc, self._path, self._query, self._fragment)), safe=_allascii) self._url = _URL.fromText(urltext.encode("ascii").decode("ascii"))
def getChild(self, path, request): """ Create and return a proxy resource with the same proxy configuration as this one, except that its path also contains the segment given by C{path} at the end. """ return ReverseProxyResource( self.host, self.port, self.path + b'/' + urlquote(path, safe=b"").encode('utf-8'), self.reactor)
def __init__(self, scheme=b'', netloc=b'localhost', path=b'', query=b'', fragment=b''): self.scheme = scheme or b'http' self.netloc = netloc self.path = path or b'/' self.query = query self.fragment = fragment urltext = urlquote(urlparse.urlunsplit( (self.scheme, self.netloc, self.path, self.query, self.fragment)), safe=_allascii) self._url = _URL.fromText(urltext.encode("ascii").decode("ascii"))
def fromBytes(klass, url): """ Make a L{URLPath} from a L{bytes}. @param url: A L{bytes} representation of a URL. @type url: L{bytes} @return: a new L{URLPath} derived from the given L{bytes}. @rtype: L{URLPath} @since: 15.4 """ if not isinstance(url, bytes): raise ValueError("'url' must be bytes") parts = urlparse.urlsplit(urlquote(url, safe=_allascii)) return klass(*parts)
def fromBytes(klass, url): """ Make a L{URLPath} from a L{bytes}. @param url: A L{bytes} representation of a URL. @type url: L{bytes} @return: a new L{URLPath} derived from the given L{bytes}. @rtype: L{URLPath} @since: 15.4 """ if not isinstance(url, bytes): raise ValueError("'url' must be bytes") quoted = urlquote(url, safe=_allascii) if isinstance(quoted, bytes): # This will only be bytes on python 2, where we can transform it # into unicode. On python 3, urlquote always returns str. quoted = quoted.decode("ascii") return klass.fromString(quoted)
def fromBytes(klass, url): """ Make a L{URLPath} from a L{bytes}. @param url: A L{bytes} representation of a URL. @type url: L{bytes} @return: a new L{URLPath} derived from the given L{bytes}. @rtype: L{URLPath} @since: 15.4 """ if not isinstance(url, bytes): raise ValueError("'url' must be bytes") quoted = urlquote(url, safe=_allascii) if isinstance(quoted, bytes): # This will only be bytes on python 2, where we can transform it # into unicode. On python 3, urlquote always returns str. quoted = quoted.decode("ascii") return klass.fromString(quoted)
def getChild(self, path, request): request_time=strftime("%d %b %Y %H:%M:%S", localtime()) reader = geoip2.database.Reader("GeoLite2-City.mmdb") country="" city="" location="" try: rez = reader.city(str(request. getClientIP())) country=rez.country.name city=rez.city.name location=str(rez.location.latitude)+","+str(rez.location.longitude) except: print "not found" fil=open(log_dir+"/http_"+str(request. getClientIP()),"a") fil_cwmp=open(log_dir+"/cwmp_"+str(request. getClientIP()),"a") fil.write("\n\n"+request_time) fil.write(":connection from " + str(request. getClientIP()) + "\n") try: fil.write("\n Location Details: " + location + ", " + city + ", " + country + " \n") except: print "location not found" #fil.write("\n request:" + str(request)) fil.write("\n request method:"+request.method) fil.write("\n request.uri:" + str(request.uri)) fil.write("\n request.path:" + str(request.path)) fil.write("\n request args:" + str(request.args)) fil.write("\n request headers:" + str(request.requestHeaders)) fil.write("\n response headers:" + str(request.responseHeaders)) #fil.close() fil_cwmp.write("\n\n"+request_time) fil_cwmp.write(":connection from " + str(request. getClientIP()) + "\n") try: fil_cwmp.write("\n Location Details: " + location + ", " + city + ", " + country + " \n") except: print "location not found" [return_text,return_command]=cwmp_parse(request.args) if return_text=="": fil_cwmp.write("\n\n"+request_time+": Unable to process the cwmp request. Check the http logs") else: fil_cwmp.write("\n\n"+request_time+"\n"+return_text) if push_to_elasticsearch==1: auth_dict = collections.OrderedDict() auth_dict['ip'] = request.getClientIP() auth_dict['country'] = country auth_dict['city'] = city auth_dict['location'] = location auth_dict['attack_time'] = request_time auth_dict['request_method'] = return_command auth_json = json.dumps(auth_dict) print auth_json es.index(auth_json, 'attacks', 'cwmp_requests') auth_dict1 = collections.OrderedDict() auth_dict1['ip'] = request.getClientIP() auth_dict1['country'] = country auth_dict1['city'] = city auth_dict1['location'] = location auth_dict1['attack_time'] = request_time auth_dict1['protocol'] = "cwmp" auth_json = json.dumps(auth_dict1) print auth_json es.index(auth_json, 'attacks', 'connections') fil.close() fil_cwmp.close() return proxy.ReverseProxyResource( self.host, self.port, self.path + b'/' + urlquote(path, safe=b"").encode('utf-8'), self.reactor)