diff --git a/config.cfg b/config.cfg
index 7d8b423..3f9bed7 100644
--- a/config.cfg
+++ b/config.cfg
@@ -6,6 +6,8 @@ rotation_wait_time = 30
max_img_rotation = 10
hours_spanned = 48
zoomlevel = 15
+# [1->12]
+size_dashboard_left_width = 5
size_openStreet_pannel_perc = 55
size_world_pannel_perc = 35
@@ -26,3 +28,4 @@ port=6250
db=1
channelProc=CoordToProcess
channelDisp=PicToDisplay
+pathMaxMindDB=/home/sami/Downloads/GeoLite2-City_20171003/GeoLite2-City.mmdb
diff --git a/server.py b/server.py
index e4a2221..235513d 100755
--- a/server.py
+++ b/server.py
@@ -97,6 +97,7 @@ def index():
]
return render_template('index.html',
pannelSize=pannelSize,
+ size_dashboard_width=[cfg.getint('Dashboard' ,'size_dashboard_left_width'), 12-cfg.getint('Dashboard', 'size_dashboard_left_width')],
graph_log_refresh_rate=cfg.getint('Dashboard' ,'graph_log_refresh_rate'),
char_separator=cfg.get('Log', 'char_separator'),
rotation_wait_time=cfg.getint('Dashboard' ,'rotation_wait_time'),
diff --git a/static/js/index/index.js b/static/js/index/index.js
index 864f516..2476ae6 100644
--- a/static/js/index/index.js
+++ b/static/js/index/index.js
@@ -240,18 +240,10 @@ function updateLogTable(feedName, log, zmqName) {
createRow(tableBody, log);
// Remove old row
- var logSel = document.getElementById("log_select");
- //get height of pannel, find max num of item
- var maxNumLogItem = document.getElementById('divLogTable').clientHeight/37;
- maxNumLogItem -= 2; //take heading/padding/... into account
- if (maxNumLogItem - parseInt(maxNumLogItem) < 0.5) { //beautifier
- maxNumLogItem -= 1;
- }
- if (tableBody.rows.length > maxNumLogItem) {
- while (tableBody.rows.length >= maxNumLogItem){
- tableBody.deleteRow(0);
- }
+ while ($("#table_log").height() >= $("#panelLogTable").height()-26){ //26 for margin
+ tableBody.deleteRow(0);
}
+
} else if (feedName == "Keepalive") {
// do nothing
} else {
diff --git a/static/js/index/index_map.js b/static/js/index/index_map.js
index 8b037e2..e1b3d7c 100644
--- a/static/js/index/index_map.js
+++ b/static/js/index/index_map.js
@@ -90,7 +90,7 @@ class MapEventManager {
myOpenStreetMap.flyTo([mapEvent.coord.lat, mapEvent.coord.lon], ZOOMLEVEL);
mapEvent.marker.bindPopup(mapEvent.textMarker).openPopup();
- $("#textMap1").fadeOut(400, function(){ $(this).text(mapEvent.text); }).fadeIn(400);
+ $("#textMap1").text(mapEvent.text);
if(ROTATIONWAITTIME != 0) {
this._timeoutRotate = setTimeout(function(){ mapEventManager.rotateMap(); }, ROTATIONWAITTIME);
}
diff --git a/templates/index.html b/templates/index.html
index 86a9aa4..d85b575 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -123,7 +123,7 @@ small {
-
+
@@ -168,7 +168,7 @@ small {
-
+
@@ -179,7 +179,7 @@ small {
-
+
-
+
diff --git a/zmq_subscriber.py b/zmq_subscriber.py
index 46d43c7..6948fcf 100755
--- a/zmq_subscriber.py
+++ b/zmq_subscriber.py
@@ -15,13 +15,11 @@ configfile = os.path.join(os.environ['VIRTUAL_ENV'], '../config.cfg')
cfg = configparser.ConfigParser()
cfg.read(configfile)
-zmq_url = cfg.get('RedisLog', 'zmq_url')
-channel = cfg.get('RedisLog', 'channel')
-context = zmq.Context()
-socket = context.socket(zmq.SUB)
-socket.connect(zmq_url)
-socket.setsockopt_string(zmq.SUBSCRIBE, '')
-channelDisp = cfg.get('RedisMap', 'channelDisp')
+ZMQ_URL = cfg.get('RedisLog', 'zmq_url')
+CHANNEL = cfg.get('RedisLog', 'channel')
+CHANNELDISP = cfg.get('RedisMap', 'channelDisp')
+CHANNEL_PROC = cfg.get('RedisMap', 'channelProc')
+PATH_TO_DB = cfg.get('RedisMap', 'pathMaxMindDB')
redis_server = redis.StrictRedis(
host=cfg.get('RedisLog', 'host'),
@@ -31,14 +29,13 @@ serv_coord = redis.StrictRedis(
host=cfg.get('RedisMap', 'host'),
port=cfg.getint('RedisMap', 'port'),
db=cfg.getint('RedisMap', 'db'))
-path_to_db = "/home/sami/Downloads/GeoLite2-City_20171003/GeoLite2-City.mmdb"
-reader = geoip2.database.Reader(path_to_db)
-channel_proc = "CoordToProcess"
+reader = geoip2.database.Reader(PATH_TO_DB)
+
def publish_log(zmq_name, name, content):
to_send = { 'name': name, 'log': json.dumps(content), 'zmqName': zmq_name }
- redis_server.publish(channel, json.dumps(to_send))
+ redis_server.publish(CHANNEL, json.dumps(to_send))
def ip_to_coord(ip):
@@ -70,7 +67,7 @@ def getCoordAndPublish(zmq_name, supposed_ip, categ):
"cityName": rep['full_rep'].city.name,
"regionCode": rep['full_rep'].country.iso_code,
}
- serv_coord.publish(channelDisp, json.dumps(to_send))
+ serv_coord.publish(CHANNELDISP, json.dumps(to_send))
except ValueError:
print("can't resolve ip")
@@ -94,6 +91,8 @@ def handler_event(zmq_name, jsonevent):
#redirect to handler_attribute
if 'Attribute' in jsonevent:
attributes = jsonevent['Attribute']
+ print("+--------- EVENTS -----------+")
+ print(attributes)
if attributes is list:
for attr in attributes:
handler_attribute(zmq_name, attr)
@@ -102,6 +101,7 @@ def handler_event(zmq_name, jsonevent):
def handler_attribute(zmq_name, jsonattr):
+ print("+--------- ATTRIBUTE -----------+")
jsonattr = jsonattr['Attribute']
print(jsonattr)
to_push = []
@@ -128,6 +128,11 @@ def process_log(zmq_name, event):
def main(zmqName):
+ context = zmq.Context()
+ socket = context.socket(zmq.SUB)
+ socket.connect(ZMQ_URL)
+ socket.setsockopt_string(zmq.SUBSCRIBE, '')
+
while True:
content = socket.recv()
content.replace(b'\n', b'') # remove \n...
@@ -150,6 +155,7 @@ if __name__ == "__main__":
parser = argparse.ArgumentParser(description='A zmq subscriber. It subscribe to a ZNQ then redispatch it to the misp-dashboard')
parser.add_argument('-n', '--name', required=False, dest='zmqname', help='The ZMQ feed name', default="Misp Standard ZMQ")
+ parser.add_argument('-u', '--url', required=False, dest='zmqurl', help='The URL to connect to', default=ZMQ_URL)
args = parser.parse_args()
main(args.zmqname)