add sort by ip
This commit is contained in:
parent
ea39d5fa6a
commit
7429db3a03
@ -951,9 +951,12 @@ def create_app():
|
||||
elif request.args.get('flush_user_db') == 'true' and request.args.get('portal_username'):
|
||||
content = '''<p style="text-align: center;"><strong>Flushed auth DB for: ''' + request.args.get('portal_username') + '''</strong></strong></p>\n'''
|
||||
authlog_flush_user(request.args.get('portal_username'))
|
||||
elif request.args.get('flush_user_mmdvm') == 'true' and request.args.get('mmdvm_server'):
|
||||
elif request.args.get('flush_db_mmdvm') == 'true' and request.args.get('mmdvm_server'):
|
||||
content = '''<p style="text-align: center;"><strong>Flushed auth DB for: ''' + request.args.get('mmdvm_server') + '''</strong></strong></p>\n'''
|
||||
authlog_flush_mmdvm_server(request.args.get('mmdvm_server'))
|
||||
elif request.args.get('flush_db_ip') == 'true' and request.args.get('peer_ip'):
|
||||
content = '''<p style="text-align: center;"><strong>Flushed auth DB for: ''' + request.args.get('peer_ip') + '''</strong></strong></p>\n'''
|
||||
authlog_flush_ip(request.args.get('peer_ip'))
|
||||
elif request.args.get('flush_dmr_id_db') == 'true' and request.args.get('dmr_id'):
|
||||
content = '''<p style="text-align: center;"><strong>Flushed auth DB for: ''' + request.args.get('dmr_id') + '''</strong></strong></p>\n'''
|
||||
authlog_flush_dmr_id(request.args.get('dmr_id'))
|
||||
@ -1007,8 +1010,8 @@ def create_app():
|
||||
content = content + '''
|
||||
<tr >
|
||||
<td style="text-align: center;"> <strong><a href="auth_log?dmr_id=''' + str(i.login_dmr_id) + '''">''' + str(i.login_dmr_id) + '''</a></strong> </td>
|
||||
<td style="text-align: center;"> <a href="edit_user?callsign=''' + i.portal_username + '''">''' + i.portal_username + '''</a> </td>
|
||||
<td style="text-align: center;"> <strong>''' + i.peer_ip + '''</strong> </td>
|
||||
<td style="text-align: center;"> <a href="auth_log?portal_username=''' + i.portal_username + '''">''' + i.portal_username + '''</a> </td>
|
||||
<td style="text-align: center;"> <strong><a href="auth_log?peer_ip=''' + str(i.peer_ip) + '''">''' + str(i.peer_ip) + '''</a></strong> </td>
|
||||
<td style="text-align: center;"> ''' + i.login_auth_method + ''' </td>
|
||||
<td style="text-align: center;"> <a href="auth_log?mmdvm_server=''' + str(i.server_name) + '''">''' + str(i.server_name) + '''</a> </td>
|
||||
<td style="text-align: center;"> ''' + str(i.login_time) + ''' </td>
|
||||
@ -1019,8 +1022,8 @@ def create_app():
|
||||
content = content + '''
|
||||
<tr >
|
||||
<td style="text-align: center;"> <strong><a href="auth_log?dmr_id=''' + str(i.login_dmr_id) + '''">''' + str(i.login_dmr_id) + '''</a></strong> </td>
|
||||
<td style="text-align: center;"> <a href="edit_user?callsign=''' + i.portal_username + '''">''' + i.portal_username + '''</a> </td>
|
||||
<td style="text-align: center;"> <strong>''' + i.peer_ip + '''</strong> </td>
|
||||
<td style="text-align: center;"> <a href=auth_log?portal_username="''' + i.portal_username + '''">''' + i.portal_username + '''</a> </td>
|
||||
<td style="text-align: center;"> <strong><a href="auth_log?peer_ip=''' + str(i.peer_ip) + '''">''' + str(i.peer_ip) + '''</a></strong> </td>
|
||||
<td style="text-align: center;"> ''' + i.login_auth_method + ''' </td>
|
||||
<td style="text-align: center;"> <a href="auth_log?mmdvm_server=''' + str(i.server_name) + '''">''' + str(i.server_name) + '''</a> </td>
|
||||
<td style="text-align: center;"> ''' + str(i.login_time) + ''' </td>
|
||||
@ -1032,7 +1035,7 @@ def create_app():
|
||||
<tr >
|
||||
<td style="text-align: center;"> <strong><a href="auth_log?dmr_id=''' + str(i.login_dmr_id) + '''">''' + str(i.login_dmr_id) + '''</a></strong> </td>
|
||||
<td style="text-align: center;"> ''' + i.portal_username + ''' </a></td>
|
||||
<td style="text-align: center;"> <strong>''' + i.peer_ip + '''</strong> </td>
|
||||
<td style="text-align: center;"> <strong><a href="auth_log?peer_ip=''' + str(i.peer_ip) + '''">''' + str(i.peer_ip) + '''</a></strong> </td>
|
||||
<td style="text-align: center;"> ''' + i.login_auth_method + ''' </td>
|
||||
<td style="text-align: center;"> <a href="auth_log?mmdvm_server=''' + str(i.server_name) + '''">''' + str(i.server_name) + '''</a> </td>
|
||||
<td style="text-align: center;"> ''' + str(i.login_time) + ''' </td>
|
||||
@ -1041,8 +1044,7 @@ def create_app():
|
||||
'''
|
||||
content = content + '</tbody></table>'
|
||||
|
||||
elif request.args.get('mmdvm_server'):
|
||||
print('mmdvm')
|
||||
elif request.args.get('mmdvm_server') and not request.args.get('flush_db_mmdvm'):
|
||||
a = AuthLog.query.filter_by(server_name=request.args.get('mmdvm_server')).order_by(AuthLog.login_time.desc()).all()
|
||||
content = '''
|
||||
<p> </p>
|
||||
@ -1080,8 +1082,8 @@ def create_app():
|
||||
content = content + '''
|
||||
<tr >
|
||||
<td style="text-align: center;"> <strong><a href="auth_log?dmr_id=''' + str(i.login_dmr_id) + '''">''' + str(i.login_dmr_id) + '''</a></strong> </td>
|
||||
<td style="text-align: center;"> <a href="edit_user?callsign=''' + i.portal_username + '''">''' + i.portal_username + '''</a> </td>
|
||||
<td style="text-align: center;"> <strong>''' + i.peer_ip + '''</strong> </td>
|
||||
<td style="text-align: center;"> <a href="auth_log?portal_username=''' + i.portal_username + '''">''' + i.portal_username + '''</a> </td>
|
||||
<td style="text-align: center;"> <strong><a href="auth_log?peer_ip=''' + str(i.peer_ip) + '''">''' + str(i.peer_ip) + '''</a></strong> </td>
|
||||
<td style="text-align: center;"> ''' + i.login_auth_method + ''' </td>
|
||||
<td style="text-align: center;"> ''' + i.server_name + ''' </td>
|
||||
<td style="text-align: center;"> ''' + str(i.login_time) + ''' </td>
|
||||
@ -1092,8 +1094,8 @@ def create_app():
|
||||
content = content + '''
|
||||
<tr >
|
||||
<td style="text-align: center;"> <strong><a href="auth_log?dmr_id=''' + str(i.login_dmr_id) + '''">''' + str(i.login_dmr_id) + '''</a></strong> </td>
|
||||
<td style="text-align: center;"> <a href="edit_user?callsign=''' + i.portal_username + '''">''' + i.portal_username + '''</a> </td>
|
||||
<td style="text-align: center;"> <strong>''' + i.peer_ip + '''</strong> </td>
|
||||
<td style="text-align: center;"> <a href="auth_log?portal_username=''' + i.portal_username + '''">''' + i.portal_username + '''</a> </td>
|
||||
<td style="text-align: center;"> <strong><a href="auth_log?peer_ip=''' + str(i.peer_ip) + '''">''' + str(i.peer_ip) + '''</a></strong> </td>
|
||||
<td style="text-align: center;"> ''' + i.login_auth_method + ''' </td>
|
||||
<td style="text-align: center;"> ''' + i.server_name + ''' </td>
|
||||
<td style="text-align: center;"> ''' + str(i.login_time) + ''' </td>
|
||||
@ -1105,7 +1107,7 @@ def create_app():
|
||||
<tr >
|
||||
<td style="text-align: center;"> <strong><a href="auth_log?dmr_id=''' + str(i.login_dmr_id) + '''">''' + str(i.login_dmr_id) + '''</a></strong> </td>
|
||||
<td style="text-align: center;"> ''' + i.portal_username + ''' </a></td>
|
||||
<td style="text-align: center;"> <strong>''' + i.peer_ip + '''</strong> </td>
|
||||
<td style="text-align: center;"> <strong><a href="auth_log?peer_ip=''' + str(i.peer_ip) + '''">''' + str(i.peer_ip) + '''</a></strong> </td>
|
||||
<td style="text-align: center;"> ''' + i.login_auth_method + ''' </td>
|
||||
<td style="text-align: center;"> ''' + i.server_name + ''' </td>
|
||||
<td style="text-align: center;"> ''' + str(i.login_time) + ''' </td>
|
||||
@ -1113,6 +1115,78 @@ def create_app():
|
||||
</tr>
|
||||
'''
|
||||
content = content + '</tbody></table>'
|
||||
|
||||
elif request.args.get('peer_ip') and not request.args.get('flush_db_ip'):
|
||||
a = AuthLog.query.filter_by(peer_ip=request.args.get('peer_ip')).order_by(AuthLog.login_time.desc()).all()
|
||||
content = '''
|
||||
<p> </p>
|
||||
<p style="text-align: center;"><strong><a href="auth_log?flush_db_ip=true&peer_ip=''' + request.args.get('peer_ip') + '''">Flush authentication log for IP: ''' + request.args.get('peer_ip') + '''</a></strong></p>
|
||||
<p style="text-align: center;"><strong>Log for IP address: ''' + request.args.get('peer_ip') + '''</strong></p>
|
||||
|
||||
|
||||
<table style="width: 1000px; margin-left: auto; margin-right: auto;" border="1">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="text-align: center;">
|
||||
<h4> DMR ID </h4>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<h4> Portal Username </h4>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<h4> Login IP </h4>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<h4> Calculated Passphrase </h4>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<h4> Server </h4>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<h4> Time (UTC) </h4>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<h4> Login Status </h4>
|
||||
</td>
|
||||
</tr> \n'''
|
||||
for i in a:
|
||||
if i.login_type == 'Attempt':
|
||||
content = content + '''
|
||||
<tr >
|
||||
<td style="text-align: center;"> <strong><a href="auth_log?dmr_id=''' + str(i.login_dmr_id) + '''">''' + str(i.login_dmr_id) + '''</a></strong> </td>
|
||||
<td style="text-align: center;"> <a href="auth_log?portal_username=''' + i.portal_username + '''">''' + i.portal_username + '''</a> </td>
|
||||
<td style="text-align: center;"> <strong>''' + i.peer_ip + '''</strong> </td>
|
||||
<td style="text-align: center;"> ''' + i.login_auth_method + ''' </td>
|
||||
<td style="text-align: center;"> <a href="auth_log?mmdvm_server=''' + str(i.server_name) + '''">''' + str(i.server_name) + '''</a> </td>
|
||||
<td style="text-align: center;"> ''' + str(i.login_time) + ''' </td>
|
||||
<td style="text-align: center;"> <span style="color: #000000; background-color: #ffff00;"><strong>''' + str(i.login_type) + '''</span></strong> </td>
|
||||
</tr>
|
||||
'''
|
||||
if i.login_type == 'Confirmed':
|
||||
content = content + '''
|
||||
<tr >
|
||||
<td style="text-align: center;"> <strong><a href="auth_log?dmr_id=''' + str(i.login_dmr_id) + '''">''' + str(i.login_dmr_id) + '''</a></strong> </td>
|
||||
<td style="text-align: center;"> <a href="auth_log?portal_username=''' + i.portal_username + '''">''' + i.portal_username + '''</a> </td>
|
||||
<td style="text-align: center;"> <strong>''' + i.peer_ip + '''</strong> </td>
|
||||
<td style="text-align: center;"> ''' + i.login_auth_method + ''' </td>
|
||||
<td style="text-align: center;"> <a href="auth_log?mmdvm_server=''' + str(i.server_name) + '''">''' + str(i.server_name) + '''</a> </td>
|
||||
<td style="text-align: center;"> ''' + str(i.login_time) + ''' </td>
|
||||
<td style="text-align: center;"> <span style="color: #000000; background-color: #00ff00;"><strong>''' + str(i.login_type) + '''</span></strong> </td>
|
||||
</tr>
|
||||
'''
|
||||
if i.login_type == 'Failed':
|
||||
content = content + '''
|
||||
<tr >
|
||||
<td style="text-align: center;"> <strong><a href="auth_log?dmr_id=''' + str(i.login_dmr_id) + '''">''' + str(i.login_dmr_id) + '''</a></strong> </td>
|
||||
<td style="text-align: center;"> ''' + i.portal_username + ''' </a></td>
|
||||
<td style="text-align: center;"> <strong>''' + i.peer_ip + '''</strong> </td>
|
||||
<td style="text-align: center;"> ''' + i.login_auth_method + ''' </td>
|
||||
<td style="text-align: center;"> <a href="auth_log?mmdvm_server=''' + str(i.server_name) + '''">''' + str(i.server_name) + '''</a> </td>
|
||||
<td style="text-align: center;"> ''' + str(i.login_time) + ''' </td>
|
||||
<td style="text-align: center;"><span style="color: #000000; background-color: #FF2400;"> <strong>''' + str(i.login_type) + '''</span></strong> </td>
|
||||
</tr>
|
||||
'''
|
||||
content = content + '</tbody></table>'
|
||||
|
||||
else:
|
||||
#a = AuthLog.query.all().order_by(AuthLog.login_dmr_id)
|
||||
@ -1158,7 +1232,7 @@ def create_app():
|
||||
<tr >
|
||||
<td style="text-align: center;"> <strong><a href="auth_log?dmr_id=''' + str(i.login_dmr_id) + '''">''' + str(i.login_dmr_id) + '''</a></strong> </td>
|
||||
<td style="text-align: center;"> <a href="auth_log?portal_username=''' + i.portal_username + '''">''' + i.portal_username + '''</a> </td>
|
||||
<td style="text-align: center;"> <strong>''' + i.peer_ip + '''</strong> </td>
|
||||
<td style="text-align: center;"> <strong><a href="auth_log?peer_ip=''' + str(i.peer_ip) + '''">''' + str(i.peer_ip) + '''</a></strong> </td>
|
||||
<td style="text-align: center;"> ''' + i.login_auth_method + ''' </td>
|
||||
<td style="text-align: center;"> <a href="auth_log?mmdvm_server=''' + str(i.server_name) + '''">''' + str(i.server_name) + '''</a> </td>
|
||||
<td style="text-align: center;"> ''' + str(i.login_time) + ''' </td>
|
||||
@ -1170,7 +1244,7 @@ def create_app():
|
||||
<tr >
|
||||
<td style="text-align: center;"> <strong><a href="auth_log?dmr_id=''' + str(i.login_dmr_id) + '''">''' + str(i.login_dmr_id) + '''</a></strong> </td>
|
||||
<td style="text-align: center;"> <a href="auth_log?portal_username=''' + i.portal_username + '''">''' + i.portal_username + '''</a> </td>
|
||||
<td style="text-align: center;"> <strong>''' + i.peer_ip + '''</strong> </td>
|
||||
<td style="text-align: center;"> <strong><a href="auth_log?peer_ip=''' + str(i.peer_ip) + '''">''' + str(i.peer_ip) + '''</a></strong> </td>
|
||||
<td style="text-align: center;"> ''' + i.login_auth_method + ''' </td>
|
||||
<td style="text-align: center;"> <a href="auth_log?mmdvm_server=''' + str(i.server_name) + '''">''' + str(i.server_name) + '''</a> </td>
|
||||
<td style="text-align: center;"> ''' + str(i.login_time) + ''' </td>
|
||||
@ -1182,7 +1256,7 @@ def create_app():
|
||||
<tr >
|
||||
<td style="text-align: center;"> <strong><a href="auth_log?dmr_id=''' + str(i.login_dmr_id) + '''">''' + str(i.login_dmr_id) + '''</a></strong> </td>
|
||||
<td style="text-align: center;"> <a href="auth_log?portal_username=''' + i.portal_username + '''">''' + i.portal_username + '''</a> </a></td>
|
||||
<td style="text-align: center;"> <strong>''' + i.peer_ip + '''</strong> </td>
|
||||
<td style="text-align: center;"> <strong><a href="auth_log?peer_ip=''' + str(i.peer_ip) + '''">''' + str(i.peer_ip) + '''</a></strong> </td>
|
||||
<td style="text-align: center;"> ''' + i.login_auth_method + ''' </td>
|
||||
<td style="text-align: center;"> <a href="auth_log?mmdvm_server=''' + str(i.server_name) + '''">''' + str(i.server_name) + '''</a> </td>
|
||||
<td style="text-align: center;"> ''' + str(i.login_time) + ''' </td>
|
||||
@ -1362,6 +1436,11 @@ def create_app():
|
||||
for i in flush_e:
|
||||
db.session.delete(i)
|
||||
db.session.commit()
|
||||
def authlog_flush_ip(_ip):
|
||||
flush_e = AuthLog.query.filter_by(peer_ip=_ip).all()
|
||||
for i in flush_e:
|
||||
db.session.delete(i)
|
||||
db.session.commit()
|
||||
|
||||
@app.route('/add_user', methods=['POST', 'GET'])
|
||||
@login_required
|
||||
|
Loading…
Reference in New Issue
Block a user