proxywatchd: match specific regex per server/protocol
This commit is contained in:
@@ -19,6 +19,12 @@ config = Config()
|
|||||||
_run_standalone = False
|
_run_standalone = False
|
||||||
cached_dns = dict()
|
cached_dns = dict()
|
||||||
|
|
||||||
|
regexes = {
|
||||||
|
'www.facebook.com': 'X-FB-Debug',
|
||||||
|
'www.reddit.com': 'x-clacks-overhead',
|
||||||
|
'www.twitter.com': 'x-connection-hash'
|
||||||
|
}
|
||||||
|
|
||||||
def try_div(a, b):
|
def try_div(a, b):
|
||||||
if b != 0: return a/float(b)
|
if b != 0: return a/float(b)
|
||||||
return 0
|
return 0
|
||||||
@@ -150,9 +156,9 @@ class WorkerJob():
|
|||||||
recv = sock.recv(-1)
|
recv = sock.recv(-1)
|
||||||
#print(recv)
|
#print(recv)
|
||||||
|
|
||||||
regex = '^(:|NOTICE|ERROR)' if checktype == 'irc' else '(X-FB-Debug|x-clacks-overhead|x-connection-hash):'
|
regex = '^(:|NOTICE|ERROR)' if checktype == 'irc' else regexes[srv]
|
||||||
# good data
|
# good data
|
||||||
if (checktype == 'irc' and re.match(regex, recv, re.IGNORECASE)) or (checktype == 'http' and re.finditer(regex, recv, re.MULTILINE)):
|
if re.search(regex, recv, re.IGNORECASE):
|
||||||
duration = (time.time() - duration)
|
duration = (time.time() - duration)
|
||||||
|
|
||||||
if geolite and not self.country or self.country == 'unknown' or self.country == 'N/A':
|
if geolite and not self.country or self.country == 'unknown' or self.country == 'N/A':
|
||||||
|
|||||||
Reference in New Issue
Block a user