From 97109f5e3c345aab5885684e9bad9f6de43473ff Mon Sep 17 00:00:00 2001 From: wotschel Date: Wed, 30 Oct 2019 10:50:50 +0100 Subject: [PATCH] Added example for checking sync servers --- examples/server_sync_check_conn.py | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 examples/server_sync_check_conn.py diff --git a/examples/server_sync_check_conn.py b/examples/server_sync_check_conn.py new file mode 100755 index 0000000..8833236 --- /dev/null +++ b/examples/server_sync_check_conn.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +import requests +import json + +# Suppress those "Unverified HTTPS request is being made" +import urllib3 +urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) + +from keys import misp_url, misp_key, misp_verifycert +proxies = { + +} + +''' +Checks if the connection to a sync server works +returns json object +''' + +def check_connection(connection_number): + + misp_headers = {'Content-Type': 'application/json', 'Accept': 'application/json', 'Authorization': misp_key} + req = requests.get(misp_url + 'servers/testConnection/{}'.format(connection_number), verify=misp_verifycert, headers=misp_headers, proxies=proxies) + + result = json.loads(req.text) + return(result) + + +if __name__ == "__main__": + + result = check_connection(1) + print(result)