mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2024-11-22 15:20:09 +01:00
v2.0-beta-2 Commit
This commit is contained in:
parent
9ffb537cfb
commit
b83aec4965
2
.gitignore
vendored
2
.gitignore
vendored
@ -7,3 +7,5 @@ wg.db
|
|||||||
src/test.py
|
src/test.py
|
||||||
tmp
|
tmp
|
||||||
__pycache__
|
__pycache__
|
||||||
|
src/wg-dashboard.ini
|
||||||
|
src/wg-dashboard.ini
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
Flask==1.1.2
|
Flask==1.1.2
|
||||||
tinydb==4.3.0
|
tinydb==4.3.0
|
||||||
ifcfg==0.21
|
ifcfg==0.21
|
||||||
configparser==5.0.2
|
|
@ -7,12 +7,13 @@ from operator import itemgetter
|
|||||||
import secrets
|
import secrets
|
||||||
import hashlib
|
import hashlib
|
||||||
import json, urllib.request
|
import json, urllib.request
|
||||||
|
import configparser
|
||||||
# PIP installed library
|
# PIP installed library
|
||||||
import ifcfg
|
import ifcfg
|
||||||
from tinydb import TinyDB, Query
|
from tinydb import TinyDB, Query
|
||||||
import configparser
|
|
||||||
|
|
||||||
|
|
||||||
|
dashboard_version = 'v2.0'
|
||||||
dashboard_conf = 'wg-dashboard.ini'
|
dashboard_conf = 'wg-dashboard.ini'
|
||||||
conf_location = "/etc/wireguard"
|
conf_location = "/etc/wireguard"
|
||||||
app = Flask("Wireguard Dashboard")
|
app = Flask("Wireguard Dashboard")
|
||||||
@ -491,10 +492,39 @@ def get_peer_name(config_name):
|
|||||||
result = db.search(peers.id == id)
|
result = db.search(peers.id == id)
|
||||||
return result[0]['name']
|
return result[0]['name']
|
||||||
|
|
||||||
|
def init_dashboard():
|
||||||
|
# Set Default INI File
|
||||||
|
conf = configparser.ConfigParser(strict=False)
|
||||||
|
if os.path.isfile("wg-dashboard.ini") == False:
|
||||||
|
conf_file = open("wg-dashboard.ini", "w+")
|
||||||
|
config = configparser.ConfigParser(strict=False)
|
||||||
|
config.read(dashboard_conf)
|
||||||
|
|
||||||
|
if "Account" not in config:
|
||||||
|
config['Account'] = {}
|
||||||
|
if "username" not in config['Account']:
|
||||||
|
config['Account']['username'] = 'admin'
|
||||||
|
if "password" not in config['Account']:
|
||||||
|
config['Account']['password'] = '8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918'
|
||||||
|
|
||||||
|
if "Server" not in config:
|
||||||
|
config['Server'] = {}
|
||||||
|
if 'app_ip' not in config['Server']:
|
||||||
|
config['Server']['app_ip'] = '0.0.0.0'
|
||||||
|
if 'app_port' not in config['Server']:
|
||||||
|
config['Server']['app_port'] = '10086'
|
||||||
|
if 'auth_req' not in config['Server']:
|
||||||
|
config['Server']['auth_req'] = 'true'
|
||||||
|
if 'version' not in config['Server'] or config['Server']['version'] != dashboard_version:
|
||||||
|
config['Server']['version'] = dashboard_version
|
||||||
|
config.write(open(dashboard_conf, "w"))
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
init_dashboard()
|
||||||
config = configparser.ConfigParser(strict=False)
|
config = configparser.ConfigParser(strict=False)
|
||||||
config.read('wg-dashboard.ini')
|
config.read('wg-dashboard.ini')
|
||||||
app_ip = config.get("Server", "app_ip")
|
app_ip = config.get("Server", "app_ip")
|
||||||
app_port = config.get("Server", "app_port")
|
app_port = config.get("Server", "app_port")
|
||||||
config.clear()
|
config.clear()
|
||||||
app.run(host=app_ip, debug=False, port=app_port)
|
app.run(host=app_ip, debug=False, port=app_port)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user