def exit_function(signum, frame): global exit_fn_called if exit_fn_called: return exit_fn_called = True l = logging.getLogger("server") signame = "SIGTERM" if signum == signal.SIGINT: signame = "SIGINT" if signum == signal.SIGQUIT: signame = "SIGQUIT" l.info("%s CAUGHT" % (signame, )) m_param.set_decrypting(0, always_on_db) m_param.set_recording(0, always_on_db) m_param.set_id_session(0, always_on_db) mono_mitm.stop_mitm() always_on_db.close() sys.exit(0) #TODO find a better way to quit
def test_set_get(self): #setup print("\n#test_set_get") db = connect(mc.db_host, mc.db_user_name, mc.db_password, mc.db_db_name) #host, user, password, db mono_param.set_recording(0, db) self.assertEqual(mono_param.get_recording(db), 0) mono_param.set_recording(1, db) self.assertEqual(mono_param.get_recording(db), 1) mono_param.set_decrypting(0, db) self.assertEqual(mono_param.get_decrypting(db), 0) mono_param.set_decrypting(1, db) self.assertEqual(mono_param.get_decrypting(db), 1) mono_param.set_id_session(0, db) self.assertEqual(mono_param.get_id_session(db), 0) mono_param.set_id_session(33, db) self.assertEqual(mono_param.get_id_session(db), 33) #print "packet1_time: %s packet_time2 %s"%(format(packet.time, '.10f'), format(packet2.time, '.10f') ) db.close()
logging.getLogger("mono_mitm.callback").setLevel(logging.INFO) #speficic log levels # logging.getLogger("mono_param").setLevel(logging.INFO) # logging.getLogger("mono_packet").setLevel(logging.INFO) # logging.getLogger("mono_mitm").setLevel(logging.INFO) # logging.getLogger("mono_tools").setLevel(logging.INFO) # logging.getLogger("mono_conversation").setLevel(logging.INFO) # logging.getLogger("mono_packet_conversation").setLevel(logging.INFO) # logging.getLogger("mono_session").setLevel(logging.INFO) #logging level for dependencies logging.getLogger("werkzeug").setLevel(logging.ERROR) logging.getLogger("watchdog").setLevel(logging.ERROR) context = None #default settings m_param.set_decrypting(0, always_on_db) m_param.set_recording(0, always_on_db) m_param.set_id_session(0, always_on_db) signal.signal(signal.SIGTERM, exit_function) signal.signal(signal.SIGINT, exit_function) signal.signal(signal.SIGQUIT, exit_function) if mc.use_tls: context = (mc.certificate, mc.key) app.run(host='0.0.0.0', port=mc.server_port, debug=mc.flask_debug, ssl_context=context) ### TODO try catch SIGTERM + close always on db connector #@application.route('/') #def showMachineList(): # return render_template('index.html')