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
server/web
|
@ -60,6 +60,13 @@ def is_valid_ip(ip):
|
|||
except ValueError:
|
||||
return False
|
||||
|
||||
def is_valid_network(ip_network):
|
||||
try:
|
||||
ipaddress.ip_network(ip_network)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
# server_management input handler
|
||||
def get_server_management_input_handler_value(value):
|
||||
if value is not None:
|
||||
|
@ -303,6 +310,7 @@ def unblacklist_uuid():
|
|||
def blacklist_ip():
|
||||
ip = request.args.get('ip')
|
||||
user = request.args.get('redirect')
|
||||
|
||||
if is_valid_ip(ip):
|
||||
res = redis_server_metadata.sadd('blacklist_ip', ip)
|
||||
if user:
|
||||
|
@ -310,6 +318,14 @@ def blacklist_ip():
|
|||
return redirect(url_for('server_management', blacklisted_ip=2))
|
||||
else:
|
||||
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:
|
||||
if user:
|
||||
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))
|
||||
else:
|
||||
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:
|
||||
if user:
|
||||
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')}}">
|
||||
<!-- Core CSS -->
|
||||
<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 -->
|
||||
<script src="{{ url_for('static', filename='js/bootstrap.min.js')}}"></script>
|
||||
|
@ -56,13 +57,13 @@
|
|||
<li class="nav-item active">
|
||||
<a class="nav-link mr-3" href="{{ url_for('index') }}">Home <span class="sr-only">(current)</span></a>
|
||||
</li>
|
||||
<li class="nav-item" mr-3>
|
||||
<a class="nav-link mr-3" href="{{ url_for('sensors_status') }}">Sensors Status</a>
|
||||
</li>
|
||||
<li class="nav-item mr-3">
|
||||
<a class="nav-link" href="{{ url_for('server_management') }}" tabindex="-1" aria-disabled="true">Server Management</a>
|
||||
</li>
|
||||
</ul>
|
||||
<li class="nav-item" mr-3>
|
||||
<a class="nav-link mr-3" href="{{ url_for('sensors_status') }}">Sensors Status</a>
|
||||
</li>
|
||||
<li class="nav-item mr-3">
|
||||
<a class="nav-link" href="{{ url_for('server_management') }}" tabindex="-1" aria-disabled="true">Server Management</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
|
||||
|
@ -94,17 +95,15 @@
|
|||
</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">
|
||||
<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>
|
||||
</div>
|
||||
|
||||
|
||||
{% include 'navfooter.html' %}
|
||||
</body>
|
||||
|
||||
<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>
|
||||
{% endfor %}
|
||||
|
||||
<script>
|
||||
var res = $('#show_active_connection').val();
|
||||
console.log(res)
|
||||
</script>
|
||||
|
||||
{% include 'navfooter.html' %}
|
||||
</body>
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<link rel="icon" href="{{ url_for('static', filename='img/d4-logo.png')}}">
|
||||
<!-- Core CSS -->
|
||||
<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">
|
||||
|
||||
<!-- JS -->
|
||||
|
@ -39,7 +40,7 @@
|
|||
</ul>
|
||||
</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-header bg-danger text-white">
|
||||
Blacklist IP
|
||||
|
@ -145,7 +146,7 @@
|
|||
</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-header bg-dark text-white">
|
||||
Header Accepted Types
|
||||
|
@ -193,6 +194,7 @@
|
|||
|
||||
</div>
|
||||
|
||||
{% include 'navfooter.html' %}
|
||||
</body>
|
||||
|
||||
<script>
|
||||
|
|
|
@ -157,6 +157,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{% include 'navfooter.html' %}
|
||||
</body>
|
||||
|
||||
<script>
|
||||
|
|
Loading…
Reference in New Issue