Commit 5cf0b54a authored by Łukasz Nowak's avatar Łukasz Nowak

check_surykatka_json: Implement tcp_server

parent 65add3a8
...@@ -232,6 +232,53 @@ class RunPromise(GenericPromise): ...@@ -232,6 +232,53 @@ class RunPromise(GenericPromise):
"OK resolver %s returned expected set of IPs %s" % ( "OK resolver %s returned expected set of IPs %s" % (
entry['resolver_ip'], ' '.join(sorted(ip_set)),)) entry['resolver_ip'], ' '.join(sorted(ip_set)),))
def senseTcpServer(self):
key = 'tcp_server'
def appendError(msg, *args):
self.error = True
self.appendMessage(key + ': ERROR ' + msg % args)
if key not in self.surykatka_json:
appendError("%r not in %r", key, self.json_file)
return
url = self.getConfig('url')
parsed_url = urlparse(url)
hostname = parsed_url.hostname
if parsed_url.port is not None:
port = parsed_url.port
else:
if parsed_url.scheme == 'https':
port = 443
else:
port = 80
ip_set = set(self.getConfig('ip-list', '').split())
entry_list = [
q for q in self.surykatka_json[key]
if hostname in [
r.strip() for r in q['domain'].split(',')] and q['port'] == port]
if len(entry_list) == 0:
appendError('No data')
return
if len(ip_set) > 0:
self.appendMessage('%s:' % (key,))
for ip in sorted(ip_set):
ok = False
for entry in entry_list:
if entry['ip'] == ip:
if entry['state'] == 'closed':
ok = False
break
if entry['state'] == 'open':
ok = True
if ok:
self.appendMessage('OK IP %s:%s' % (ip, port))
else:
self.error = True
self.appendMessage('ERROR IP %s:%s' % (ip, port))
def senseElapsedTime(self): def senseElapsedTime(self):
key = 'elapsed_time' key = 'elapsed_time'
surykatka_key = 'http_query' surykatka_key = 'http_query'
...@@ -306,6 +353,7 @@ class RunPromise(GenericPromise): ...@@ -306,6 +353,7 @@ class RunPromise(GenericPromise):
self.senseBotStatus() self.senseBotStatus()
elif report == 'http_query': elif report == 'http_query':
self.senseDnsQuery() self.senseDnsQuery()
self.senseTcpServer()
self.senseHttpQuery() self.senseHttpQuery()
self.senseSslCertificate() self.senseSslCertificate()
self.senseElapsedTime() self.senseElapsedTime()
......
Markdown is supported
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