mirror of https://github.com/D4-project/d4-core
chg: [server UI v0.2] blacklist/unblacklist by network + add navfooter + fix css
parent
d0a2bee4f2
commit
8538792da1
|
@ -60,6 +60,13 @@ def is_valid_ip(ip):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def is_valid_network(ip_network):
|
||||||
|
try:
|
||||||
|
ipaddress.ip_network(ip_network)
|
||||||
|
return True
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
|
||||||
# server_management input handler
|
# server_management input handler
|
||||||
def get_server_management_input_handler_value(value):
|
def get_server_management_input_handler_value(value):
|
||||||
if value is not None:
|
if value is not None:
|
||||||
|
@ -303,6 +310,7 @@ def unblacklist_uuid():
|
||||||
def blacklist_ip():
|
def blacklist_ip():
|
||||||
ip = request.args.get('ip')
|
ip = request.args.get('ip')
|
||||||
user = request.args.get('redirect')
|
user = request.args.get('redirect')
|
||||||
|
|
||||||
if is_valid_ip(ip):
|
if is_valid_ip(ip):
|
||||||
res = redis_server_metadata.sadd('blacklist_ip', ip)
|
res = redis_server_metadata.sadd('blacklist_ip', ip)
|
||||||
if user:
|
if user:
|
||||||
|
@ -310,6 +318,14 @@ def blacklist_ip():
|
||||||
return redirect(url_for('server_management', blacklisted_ip=2))
|
return redirect(url_for('server_management', blacklisted_ip=2))
|
||||||
else:
|
else:
|
||||||
return redirect(url_for('server_management', blacklisted_ip=1))
|
return redirect(url_for('server_management', blacklisted_ip=1))
|
||||||
|
elif is_valid_network(ip):
|
||||||
|
for addr in ipaddress.ip_network(ip):
|
||||||
|
res = redis_server_metadata.sadd('blacklist_ip', str(addr))
|
||||||
|
if user:
|
||||||
|
if res==0:
|
||||||
|
return redirect(url_for('server_management', blacklisted_ip=2))
|
||||||
|
else:
|
||||||
|
return redirect(url_for('server_management', blacklisted_ip=1))
|
||||||
else:
|
else:
|
||||||
if user:
|
if user:
|
||||||
return redirect(url_for('server_management', blacklisted_ip=0))
|
return redirect(url_for('server_management', blacklisted_ip=0))
|
||||||
|
@ -326,6 +342,14 @@ def unblacklist_ip():
|
||||||
return redirect(url_for('server_management', unblacklisted_ip=2))
|
return redirect(url_for('server_management', unblacklisted_ip=2))
|
||||||
else:
|
else:
|
||||||
return redirect(url_for('server_management', unblacklisted_ip=1))
|
return redirect(url_for('server_management', unblacklisted_ip=1))
|
||||||
|
elif is_valid_network(ip):
|
||||||
|
for addr in ipaddress.ip_network(ip):
|
||||||
|
res = redis_server_metadata.srem('blacklist_ip', str(addr))
|
||||||
|
if user:
|
||||||
|
if res==0:
|
||||||
|
return redirect(url_for('server_management', unblacklisted_ip=2))
|
||||||
|
else:
|
||||||
|
return redirect(url_for('server_management', unblacklisted_ip=1))
|
||||||
else:
|
else:
|
||||||
if user:
|
if user:
|
||||||
return redirect(url_for('server_management', unblacklisted_ip=0))
|
return redirect(url_for('server_management', unblacklisted_ip=0))
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 18 KiB |
|
@ -6,6 +6,7 @@
|
||||||
<link rel="icon" href="{{ url_for('static', filename='img/d4-logo.png')}}">
|
<link rel="icon" href="{{ url_for('static', filename='img/d4-logo.png')}}">
|
||||||
<!-- Core CSS -->
|
<!-- Core CSS -->
|
||||||
<link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
|
<link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
|
||||||
|
<link href="{{ url_for('static', filename='font-awesome/css/font-awesome.css') }}" rel="stylesheet">
|
||||||
|
|
||||||
<!-- JS -->
|
<!-- JS -->
|
||||||
<script src="{{ url_for('static', filename='js/bootstrap.min.js')}}"></script>
|
<script src="{{ url_for('static', filename='js/bootstrap.min.js')}}"></script>
|
||||||
|
@ -56,13 +57,13 @@
|
||||||
<li class="nav-item active">
|
<li class="nav-item active">
|
||||||
<a class="nav-link mr-3" href="{{ url_for('index') }}">Home <span class="sr-only">(current)</span></a>
|
<a class="nav-link mr-3" href="{{ url_for('index') }}">Home <span class="sr-only">(current)</span></a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item" mr-3>
|
<li class="nav-item" mr-3>
|
||||||
<a class="nav-link mr-3" href="{{ url_for('sensors_status') }}">Sensors Status</a>
|
<a class="nav-link mr-3" href="{{ url_for('sensors_status') }}">Sensors Status</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item mr-3">
|
<li class="nav-item mr-3">
|
||||||
<a class="nav-link" href="{{ url_for('server_management') }}" tabindex="-1" aria-disabled="true">Server Management</a>
|
<a class="nav-link" href="{{ url_for('server_management') }}" tabindex="-1" aria-disabled="true">Server Management</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,17 +95,15 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex justify-content-center mt-4">
|
|
||||||
<img src="{{ url_for('static', filename='img/circl.png')}}" alt="circl" class="h-75 mt-4">
|
|
||||||
<img src="{{ url_for('static', filename='img/cef.png')}}" alt="cef">
|
|
||||||
</div>
|
|
||||||
<div class="d-flex justify-content-center">
|
<div class="d-flex justify-content-center">
|
||||||
<a href="{{ url_for('delete_data') }}">
|
<a href="{{ url_for('delete_data') }}">
|
||||||
<button type="button" class="btn btn-primary mt-3">Delete All Data (Demo)</button>
|
<button type="button" class="btn btn-primary mt-3 mb-2">Delete All Data (Demo)</button>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{% include 'navfooter.html' %}
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
<hr/ class="mb-0">
|
||||||
|
<nav class="navbar bottom navbar-expand-sm navbar-light bg-light">
|
||||||
|
<a class="navbar-brand" href="https://www.circl.lu/">
|
||||||
|
<img src="{{ url_for('static', filename='img/circl.png')}}" alt="circl" class="h-100" style="width: 180px;">
|
||||||
|
</a>
|
||||||
|
<img src="{{ url_for('static', filename='img/cef.png')}}" alt="cef" class="h-100" style="width: 500px;">
|
||||||
|
<ul class="navbar-nav ml-auto">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="navbar-brand" href="https://www.d4-project.org/">
|
||||||
|
<img src="{{ url_for('static', filename='img/d4-logo.png')}}" alt="D4 Project" style="width:70px;">
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="navbar-brand" href="https://github.com/D4-project/d4-core">
|
||||||
|
<i class="fa fa-github fa-3x mt-1"></i>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
|
@ -114,9 +114,5 @@
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
<script>
|
{% include 'navfooter.html' %}
|
||||||
var res = $('#show_active_connection').val();
|
|
||||||
console.log(res)
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<link rel="icon" href="{{ url_for('static', filename='img/d4-logo.png')}}">
|
<link rel="icon" href="{{ url_for('static', filename='img/d4-logo.png')}}">
|
||||||
<!-- Core CSS -->
|
<!-- Core CSS -->
|
||||||
<link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
|
<link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
|
||||||
|
<link href="{{ url_for('static', filename='font-awesome/css/font-awesome.css') }}" rel="stylesheet">
|
||||||
<link href="{{ url_for('static', filename='css/dataTables.bootstrap.min.css') }}" rel="stylesheet">
|
<link href="{{ url_for('static', filename='css/dataTables.bootstrap.min.css') }}" rel="stylesheet">
|
||||||
|
|
||||||
<!-- JS -->
|
<!-- JS -->
|
||||||
|
@ -39,7 +40,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div class="card-deck justify-content-center">
|
<div class="card-deck justify-content-center ml-0 mr-0">
|
||||||
<div class="card text-center mt-3 ml-4">
|
<div class="card text-center mt-3 ml-4">
|
||||||
<div class="card-header bg-danger text-white">
|
<div class="card-header bg-danger text-white">
|
||||||
Blacklist IP
|
Blacklist IP
|
||||||
|
@ -145,7 +146,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-deck justify-content-center">
|
<div class="card-deck justify-content-center ml-0 mr-0">
|
||||||
<div class="card border-dark mt-3 ml-4 mr-4">
|
<div class="card border-dark mt-3 ml-4 mr-4">
|
||||||
<div class="card-header bg-dark text-white">
|
<div class="card-header bg-dark text-white">
|
||||||
Header Accepted Types
|
Header Accepted Types
|
||||||
|
@ -193,6 +194,7 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% include 'navfooter.html' %}
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
|
@ -157,6 +157,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% include 'navfooter.html' %}
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
Loading…
Reference in New Issue