2020-10-18 07:10:13 +02:00
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
|
|
<title>Wireguard Dashboard</title>
|
|
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
|
|
|
|
<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='dashboard.css') }}">
|
2020-10-18 18:23:38 +02:00
|
|
|
<link href="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/css/bootstrap4-toggle.min.css" rel="stylesheet">
|
2020-12-26 06:17:42 +01:00
|
|
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
2020-10-18 07:10:13 +02:00
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
|
|
|
|
<a class="navbar-brand col-md-3 col-lg-2 mr-0 px-3" href="#">Wireguard Dashboard</a>
|
|
|
|
<button class="navbar-toggler position-absolute d-md-none collapsed" type="button" data-toggle="collapse"
|
|
|
|
data-target="#sidebarMenu" aria-controls="sidebarMenu" aria-expanded="false" aria-label="Toggle navigation">
|
|
|
|
<span class="navbar-toggler-icon"></span>
|
|
|
|
</button>
|
|
|
|
</nav>
|
|
|
|
<div class="container-fluid">
|
|
|
|
<div class="row">
|
|
|
|
<div class="row">
|
|
|
|
<nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
|
|
|
|
<div class="sidebar-sticky pt-3">
|
|
|
|
<ul class="nav flex-column">
|
|
|
|
<li class="nav-item"><a class="nav-link" href="/">Home</a></li>
|
|
|
|
</ul>
|
|
|
|
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
|
|
|
|
<span>Configurations</span>
|
|
|
|
</h6>
|
|
|
|
<ul class="nav flex-column">
|
|
|
|
{% for i in conf%}
|
|
|
|
<li class="nav-item"><a class="nav-link" href="/configuration/{{i['conf']}}">{{i['conf']}}</a></li>
|
|
|
|
{%endfor%}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</nav>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4 mt-4">
|
|
|
|
<div class="info mt-4">
|
|
|
|
<div class="row">
|
2020-10-18 18:23:38 +02:00
|
|
|
<div class="col-sm">
|
|
|
|
<small class="text-muted"><strong>CONFIGURATION</strong></small>
|
|
|
|
<h1 class="mb-3">{{conf_data['name']}}</h1>
|
|
|
|
</div>
|
|
|
|
<div class="col-sm">
|
|
|
|
<small class="text-muted"><strong>ACTION</strong></small><br>
|
2020-10-23 07:31:10 +02:00
|
|
|
<input class="mt-2 switch" id="{{conf_data['name']}}" type="checkbox" data-toggle="toggle" {{conf_data['checked']}} data-size="sm">
|
2020-10-18 18:23:38 +02:00
|
|
|
</div>
|
|
|
|
<div class="w-100"></div>
|
2020-10-18 07:10:13 +02:00
|
|
|
<div class="col-sm">
|
|
|
|
<small class="text-muted"><strong>STATUS</strong></small>
|
|
|
|
<h6 style="text-transform: uppercase;">{{conf_data['status']}}<span class="dot dot-{{conf_data['status']}}"></span></h6>
|
|
|
|
</div>
|
2020-12-26 06:17:42 +01:00
|
|
|
<div class="col-sm">
|
|
|
|
<small class="text-muted"><strong>CONNECTED PEERS</strong></small>
|
|
|
|
<h6 style="text-transform: uppercase;">{{conf_data['running_peer']}}</h6>
|
|
|
|
</div>
|
2020-10-18 07:10:13 +02:00
|
|
|
<div class="col-sm">
|
|
|
|
<small class="text-muted"><strong>TOTAL DATA USAGE</strong></small>
|
|
|
|
<h6 style="text-transform: uppercase;">{{conf_data['total_data_usage'][0]}} GB</h6>
|
|
|
|
</div>
|
|
|
|
<div class="col-sm">
|
|
|
|
<small class="text-muted"><strong>TOTAL RECIEVED</strong></small>
|
|
|
|
<h6 style="text-transform: uppercase;">{{conf_data['total_data_usage'][1]}} GB</h6>
|
|
|
|
</div>
|
|
|
|
<div class="col-sm">
|
|
|
|
<small class="text-muted"><strong>TOTAL SENT</strong></small>
|
|
|
|
<h6 style="text-transform: uppercase;">{{conf_data['total_data_usage'][2]}} GB</h6>
|
|
|
|
</div>
|
|
|
|
<div class="w-100"></div>
|
|
|
|
<div class="col-sm">
|
|
|
|
<small class="text-muted"><strong>PUBLIC KEY</strong></small>
|
|
|
|
<h6 style="text-transform: uppercase;"><samp>{{conf_data['public_key']}}</samp></h6>
|
|
|
|
</div>
|
|
|
|
<div class="col-sm">
|
|
|
|
<small class="text-muted"><strong>LISTEN PORT</strong></small>
|
|
|
|
<h6 style="text-transform: uppercase;"><samp>{{conf_data['listen_port']}}</samp></h6>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<hr>
|
2020-10-23 07:31:10 +02:00
|
|
|
<div class="button-div" style="text-align: right;">
|
2020-12-26 06:17:42 +01:00
|
|
|
<button type="button" class="btn btn-outline-primary btn-sm mb-3" data-toggle="modal" data-target="#add_modal">
|
2020-10-23 07:31:10 +02:00
|
|
|
<strong>ADD PEER</strong>
|
|
|
|
</button>
|
|
|
|
|
|
|
|
</div>
|
2020-10-18 07:10:13 +02:00
|
|
|
</div>
|
2020-10-18 18:23:38 +02:00
|
|
|
|
2020-10-18 07:10:13 +02:00
|
|
|
{% for i in conf_data['peer_data']%}
|
2020-10-18 07:42:45 +02:00
|
|
|
<div class="card mb-3">
|
2020-10-18 07:10:13 +02:00
|
|
|
<div class="card-body">
|
|
|
|
<div class="row">
|
2020-10-18 07:42:45 +02:00
|
|
|
<div class="col-sm">
|
|
|
|
<small class="text-muted"><strong>STATUS</strong></small>
|
|
|
|
<h6 style="text-transform: uppercase;">{{conf_data['peer_data'][i]['status']}}<span class="dot dot-{{conf_data['peer_data'][i]['status']}}"></span></h6>
|
|
|
|
</div>
|
|
|
|
<div class="col-sm">
|
|
|
|
<small class="text-muted"><strong>PEER</strong></small>
|
2020-12-27 05:42:41 +01:00
|
|
|
<h6><samp>{{i}}</samp></h6>
|
2020-10-18 07:42:45 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="w-100"></div>
|
2020-10-18 07:10:13 +02:00
|
|
|
<div class="col-sm">
|
|
|
|
<small class="text-muted"><strong>ALLOWED IP</strong></small>
|
|
|
|
<h6 style="text-transform: uppercase;">{{conf_data['peer_data'][i]['allowed_ip']}}</h6>
|
|
|
|
</div>
|
|
|
|
<div class="col-sm">
|
|
|
|
<small class="text-muted"><strong>LATEST HANDSHAKE</strong></small>
|
|
|
|
<h6 style="text-transform: uppercase;">{{conf_data['peer_data'][i]['latest_handshake']}}</h6>
|
|
|
|
</div>
|
|
|
|
<div class="col-sm">
|
|
|
|
<small class="text-muted"><strong>END POINT</strong></small>
|
|
|
|
<h6 style="text-transform: uppercase;">{{conf_data['peer_data'][i]['endpoint']}}</h6>
|
|
|
|
</div>
|
|
|
|
<div class="w-100"></div>
|
|
|
|
<div class="col-sm">
|
|
|
|
<small class="text-muted"><strong>TOTAL DATA USAGE</strong></small>
|
|
|
|
<h6 style="text-transform: uppercase;">{{conf_data['peer_data'][i]['total_data']}} GB</h6>
|
|
|
|
</div>
|
|
|
|
<div class="col-sm">
|
|
|
|
<small class="text-muted"><strong>TOTAL RECIEVED</strong></small>
|
|
|
|
<h6 style="text-transform: uppercase;">{{conf_data['peer_data'][i]['total_recive']}} GB</h6>
|
|
|
|
</div>
|
|
|
|
<div class="col-sm">
|
|
|
|
<small class="text-muted"><strong>TOTAL SENT</strong></small>
|
|
|
|
<h6 style="text-transform: uppercase;">{{conf_data['peer_data'][i]['total_sent']}} GB</h6>
|
|
|
|
</div>
|
2020-10-19 02:19:41 +02:00
|
|
|
<div class="w-100"></div>
|
|
|
|
<div class="col-sm">
|
2020-12-26 06:17:42 +01:00
|
|
|
<!-- <small class="text-muted"><strong>ACTION</strong></small> -->
|
2020-10-19 02:19:41 +02:00
|
|
|
<div class="button-group">
|
2020-12-26 06:17:42 +01:00
|
|
|
<button type="button" class="btn btn-outline-danger btn-sm btn-delete-peer" id="{{i}}" data-toggle="modal" data-target="#delete_modal"><span class="material-icons">delete_forever</span></button>
|
2020-10-19 02:19:41 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
2020-10-18 07:10:13 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{%endfor%}
|
|
|
|
</main>
|
|
|
|
</div>
|
2020-12-26 06:17:42 +01:00
|
|
|
<div class="modal fade" id="add_modal" data-backdrop="static" data-keyboard="false" tabindex="-1"
|
2020-10-23 07:31:10 +02:00
|
|
|
aria-labelledby="staticBackdropLabel" aria-hidden="true">
|
|
|
|
<div class="modal-dialog modal-dialog-centered">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
|
|
|
<h5 class="modal-title" id="staticBackdropLabel">Add a new peer</h5>
|
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
|
|
<span aria-hidden="true">×</span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div class="modal-body">
|
2020-12-27 05:42:41 +01:00
|
|
|
<div id="add_peer_alert" class="alert alert-danger alert-dismissible fade show d-none" role="alert">
|
|
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
|
|
<span aria-hidden="true">×</span>
|
|
|
|
</button>
|
|
|
|
</div>
|
2020-10-23 07:31:10 +02:00
|
|
|
<form>
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="public_key">Public Key</label>
|
|
|
|
<input type="text" class="form-control" id="public_key" aria-describedby="public_key">
|
|
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="allowed_ips">Allowed IPs</label>
|
|
|
|
<input type="text" class="form-control" id="allowed_ips">
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
|
|
|
<button type="button" class="btn btn-primary" id="save_peer" conf_id={{conf_data['name']}}>Save</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-12-26 06:17:42 +01:00
|
|
|
<div class="modal fade" id="delete_modal" data-backdrop="static" data-keyboard="false" tabindex="-1"
|
|
|
|
aria-labelledby="staticBackdropLabel" aria-hidden="true">
|
|
|
|
<div class="modal-dialog modal-dialog-centered">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
|
|
|
<h5 class="modal-title" id="staticBackdropLabel">Are you sure to delete this peer?</h5>
|
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
|
|
<span aria-hidden="true">×</span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div class="modal-body">
|
2020-12-27 05:42:41 +01:00
|
|
|
<div id="remove_peer_alert" class="alert alert-danger alert-dismissible fade show d-none" role="alert">
|
|
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
|
|
<span aria-hidden="true">×</span>
|
|
|
|
</button>
|
|
|
|
</div>
|
2020-12-26 06:17:42 +01:00
|
|
|
<h6>This action is not reversible.</h6>
|
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">No</button>
|
|
|
|
<button type="button" class="btn btn-danger" id="delete_peer" conf_id={{conf_data['name']}} peer_id="">Yes</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-10-18 07:10:13 +02:00
|
|
|
</body>
|
2020-10-23 07:31:10 +02:00
|
|
|
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
|
2020-10-18 07:10:13 +02:00
|
|
|
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"
|
|
|
|
integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN"
|
|
|
|
crossorigin="anonymous"></script>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.min.js"
|
|
|
|
integrity="sha384-w1Q4orYjBQndcko6MimVbzY0tgp4pWB4lZ7lr30WKz0vr/aWKhXdBNmNb5D92v7s"
|
|
|
|
crossorigin="anonymous"></script>
|
2020-10-18 18:23:38 +02:00
|
|
|
<script src="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/js/bootstrap4-toggle.min.js"></script>
|
2020-10-18 07:10:13 +02:00
|
|
|
<script>
|
2020-10-19 02:19:41 +02:00
|
|
|
$('.switch').change(function() {
|
2020-10-23 07:31:10 +02:00
|
|
|
if ($(this).prop('checked') == false){
|
|
|
|
if (confirm('Are you sure you want to turn off this connection?')){
|
2020-12-27 05:42:41 +01:00
|
|
|
location.replace("/switch/"+$(this).attr('id'));
|
2020-10-23 07:31:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
2020-12-27 05:42:41 +01:00
|
|
|
location.replace("/switch/"+$(this).attr('id'));
|
2020-10-23 07:31:10 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#save_peer").click(function(){
|
|
|
|
if ($("#allowed_ips") != "" && $("#public_key") != ""){
|
|
|
|
var conf = $(this).attr('conf_id')
|
2020-10-19 17:48:08 +02:00
|
|
|
|
2020-10-23 07:31:10 +02:00
|
|
|
$.ajax({
|
|
|
|
method: "POST",
|
|
|
|
url: "/add_peer/"+conf,
|
|
|
|
headers:{
|
|
|
|
"Content-Type": "application/json"
|
|
|
|
},
|
|
|
|
data: JSON.stringify({"public_key":$("#public_key").val(), "allowed_ips": $("#allowed_ips").val()}),
|
|
|
|
success: function (response){
|
2020-12-27 05:42:41 +01:00
|
|
|
if(response != "true"){
|
|
|
|
$("#add_peer_alert").html(response+$("#add_peer_alert").html());
|
|
|
|
$("#add_peer_alert").removeClass("d-none");
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
location.reload();
|
|
|
|
}
|
2020-10-23 07:31:10 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
2020-10-19 17:48:08 +02:00
|
|
|
|
2020-12-26 06:17:42 +01:00
|
|
|
$(".btn-delete-peer").click(function(){
|
|
|
|
var peer_id = $(this).attr("id");
|
|
|
|
$("#delete_peer").attr("peer_id", peer_id);
|
|
|
|
});
|
|
|
|
|
2020-12-27 05:42:41 +01:00
|
|
|
$("#delete_peer").click(function(){
|
2020-12-26 06:17:42 +01:00
|
|
|
var peer_id = $(this).attr("peer_id");
|
|
|
|
var config = $(this).attr("conf_id");
|
|
|
|
$.ajax({
|
|
|
|
method: "POST",
|
2020-12-27 05:42:41 +01:00
|
|
|
url: "/remove_peer/"+config,
|
2020-12-26 06:17:42 +01:00
|
|
|
headers:{
|
|
|
|
"Content-Type": "application/json"
|
|
|
|
},
|
2020-12-27 05:42:41 +01:00
|
|
|
data: JSON.stringify({"action": "delete", "peer_id": peer_id}),
|
2020-12-26 06:17:42 +01:00
|
|
|
success: function (response){
|
2020-12-27 05:42:41 +01:00
|
|
|
if(response != "true"){
|
|
|
|
$("#remove_peer_alert").html(response+$("#add_peer_alert").html());
|
|
|
|
$("#remove_peer_alert").removeClass("d-none");
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
location.reload();
|
|
|
|
}
|
2020-12-26 06:17:42 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-23 07:31:10 +02:00
|
|
|
// setInterval(function(){
|
|
|
|
// location.reload();
|
|
|
|
// }, 10000)
|
2020-10-18 07:10:13 +02:00
|
|
|
</script>
|
2020-10-23 07:31:10 +02:00
|
|
|
</html>
|