From 40d05f3434b4ea53e97ef30621c6e97b1c60d920 Mon Sep 17 00:00:00 2001 From: donaldzou Date: Sun, 18 Oct 2020 01:10:13 -0400 Subject: [PATCH] First Commit --- .DS_Store | Bin 0 -> 6148 bytes dashboard.py | 137 +++++++++++++++++++++++++++++++++++ static/dashboard.css | 124 +++++++++++++++++++++++++++++++ templates/configuration.html | 130 +++++++++++++++++++++++++++++++++ templates/index.html | 71 ++++++++++++++++++ test.py | 5 ++ 6 files changed, 467 insertions(+) create mode 100644 .DS_Store create mode 100644 dashboard.py create mode 100644 static/dashboard.css create mode 100644 templates/configuration.html create mode 100644 templates/index.html create mode 100644 test.py diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a580bdfa4f58bbd6ddd40e9566b76e176687eb88 GIT binary patch literal 6148 zcmeHKIc~#13?vg54$`P}xnIZ+7J~BveZT<{xUpp;K5A8YSDxnKfgpnHCV-n@2#~YO z<*cA7L{UVvJ-xq(G$JyG8_Ji3soA;t#2zxEKsfH$$eSGHLk{O|QhhyP+$ZO3W&fN1 z*>86JI&QvBWtIw10V+TRr~noCg96rjVe{ueMk+uBsKAc`_I)UD!kdX>d zfw2OQv2CpXzrt_K|6>w&RDcTnD+P46?3OKFDSPYW<*e5h_zG?{-*7Xmor2))80hU7 g8*9f4FN(TiYn<1_A<*f_I~~ZM0n>#>1@5iD1$', methods=['GET']) +def conf(config_name): + + conf_data = { + "name": config_name, + "status": get_conf_status(config_name), + "total_data_usage": get_conf_total_data(config_name), + "public_key": get_conf_pub_key(config_name), + "listen_port": get_conf_listen_port(config_name), + "peer_data":get_conf_peers_data(config_name) + } + return render_template('configuration.html', conf=get_conf_list(), conf_data=conf_data) + + +app.run(host='0.0.0.0',debug=False, port=10086) diff --git a/static/dashboard.css b/static/dashboard.css new file mode 100644 index 0000000..895ad7a --- /dev/null +++ b/static/dashboard.css @@ -0,0 +1,124 @@ +body { + font-size: .875rem; +} + +.feather { + width: 16px; + height: 16px; + vertical-align: text-bottom; +} + +/* + * Sidebar + */ + +.sidebar { + position: fixed; + top: 0; + bottom: 0; + left: 0; + z-index: 100; /* Behind the navbar */ + padding: 48px 0 0; /* Height of navbar */ + box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1); +} + +@media (max-width: 767.98px) { + .sidebar { + top: 5rem; + } +} + +.sidebar-sticky { + position: relative; + top: 0; + height: calc(100vh - 48px); + padding-top: .5rem; + overflow-x: hidden; + overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */ +} + +@supports ((position: -webkit-sticky) or (position: sticky)) { + .sidebar-sticky { + position: -webkit-sticky; + position: sticky; + } +} + +.sidebar .nav-link { + font-weight: 500; + color: #333; +} + +.sidebar .nav-link .feather { + margin-right: 4px; + color: #999; +} + +.sidebar .nav-link.active { + color: #007bff; +} + +.sidebar .nav-link:hover .feather, +.sidebar .nav-link.active .feather { + color: inherit; +} + +.sidebar-heading { + font-size: .75rem; + text-transform: uppercase; +} + +/* + * Navbar + */ + +.navbar-brand { + padding-top: .75rem; + padding-bottom: .75rem; + font-size: 1rem; + background-color: rgba(0, 0, 0, .25); + box-shadow: inset -1px 0 0 rgba(0, 0, 0, .25); +} + +.navbar .navbar-toggler { + top: .25rem; + right: 1rem; +} + +.navbar .form-control { + padding: .75rem 1rem; + border-width: 0; + border-radius: 0; +} + +.form-control-dark { + color: #fff; + background-color: rgba(255, 255, 255, .1); + border-color: rgba(255, 255, 255, .1); +} + +.form-control-dark:focus { + border-color: transparent; + box-shadow: 0 0 0 3px rgba(255, 255, 255, .25); +} + +.dot{ + width: 10px; + height: 10px; + border-radius: 50px; + display: inline-block; + margin-left: 10px; +} + +.dot-running{ + background-color: #28a745!important; +} + +.dot-stopped{ + background-color: #6c757d!important; +} + + +.info h6{ + line-break: anywhere; +} \ No newline at end of file diff --git a/templates/configuration.html b/templates/configuration.html new file mode 100644 index 0000000..94cd97b --- /dev/null +++ b/templates/configuration.html @@ -0,0 +1,130 @@ + + + + + + Wireguard Dashboard + + + + + + +
+
+
+ +
+
+
+
+ CONFIGURATION +

{{conf_data['name']}}

+
+
+ STATUS +
{{conf_data['status']}}
+
+
+ TOTAL DATA USAGE +
{{conf_data['total_data_usage'][0]}} GB
+
+
+ TOTAL RECIEVED +
{{conf_data['total_data_usage'][1]}} GB
+
+
+ TOTAL SENT +
{{conf_data['total_data_usage'][2]}} GB
+
+
+
+ PUBLIC KEY +
{{conf_data['public_key']}}
+
+
+ LISTEN PORT +
{{conf_data['listen_port']}}
+
+
+
+
+ {% for i in conf_data['peer_data']%} +
+
+
+
+ ALLOWED IP +
{{conf_data['peer_data'][i]['allowed_ip']}}
+
+
+ LATEST HANDSHAKE +
{{conf_data['peer_data'][i]['latest_handshake']}}
+
+
+
+ PEER +
{{i}}
+
+
+ END POINT +
{{conf_data['peer_data'][i]['endpoint']}}
+
+
+
+ TOTAL DATA USAGE +
{{conf_data['peer_data'][i]['total_data']}} GB
+
+
+ TOTAL RECIEVED +
{{conf_data['peer_data'][i]['total_recive']}} GB
+
+
+ TOTAL SENT +
{{conf_data['peer_data'][i]['total_sent']}} GB
+
+
+
+
+ {%endfor%} + +
+
+ + + + + + \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..9bde758 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,71 @@ + + + + + + Wireguard Dashboard + + + + + + +
+
+
+ +
+
+
+ {% for i in conf%} +
+
+ +
{{i['conf']}}
+
+
Status: {{i['status']}} + +
+
+
+ {%endfor%} +
+
+ + + + + + \ No newline at end of file diff --git a/test.py b/test.py new file mode 100644 index 0000000..bbca88c --- /dev/null +++ b/test.py @@ -0,0 +1,5 @@ +import os +import subprocess +try: status = subprocess.check_output("wg show wg0", shell=True) +except Exception: print("false") +else:print(status.decode("UTF-8")) \ No newline at end of file