mirror of
https://github.com/donaldzou/WGDashboard
synced 2025-02-26 05:58:47 +00:00
Removed some unnecessary comments
This commit is contained in:
parent
3b478bcc2d
commit
f9dc9ebdb3
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,5 +1,4 @@
|
|||||||
.vscode/sftp.json
|
.vscode
|
||||||
src/.vscode/sftp.json
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.idea
|
.idea
|
||||||
src/db
|
src/db
|
||||||
|
@ -4,7 +4,6 @@ Under Apache-2.0 License
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import sqlite3
|
import sqlite3
|
||||||
from flask import g
|
|
||||||
import configparser
|
import configparser
|
||||||
import hashlib
|
import hashlib
|
||||||
import ipaddress
|
import ipaddress
|
||||||
@ -22,7 +21,7 @@ from datetime import datetime, timedelta
|
|||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
# PIP installed library
|
# PIP installed library
|
||||||
import ifcfg
|
import ifcfg
|
||||||
from flask import Flask, request, render_template, redirect, url_for, session, jsonify
|
from flask import Flask, request, render_template, redirect, url_for, session, jsonify, g
|
||||||
from flask_qrcode import QRcode
|
from flask_qrcode import QRcode
|
||||||
from icmplib import ping, traceroute
|
from icmplib import ping, traceroute
|
||||||
|
|
||||||
@ -32,21 +31,26 @@ from util import regex_match, check_DNS, check_Allowed_IPs, check_remote_endpoin
|
|||||||
|
|
||||||
# Dashboard Version
|
# Dashboard Version
|
||||||
DASHBOARD_VERSION = 'v3.0.5'
|
DASHBOARD_VERSION = 'v3.0.5'
|
||||||
|
|
||||||
# WireGuard's configuration path
|
# WireGuard's configuration path
|
||||||
WG_CONF_PATH = None
|
WG_CONF_PATH = None
|
||||||
|
|
||||||
# Dashboard Config Name
|
# Dashboard Config Name
|
||||||
configuration_path = os.getenv('CONFIGURATION_PATH', '.')
|
configuration_path = os.getenv('CONFIGURATION_PATH', '.')
|
||||||
DB_PATH = os.path.join(configuration_path, 'db')
|
DB_PATH = os.path.join(configuration_path, 'db')
|
||||||
if not os.path.isdir(DB_PATH):
|
if not os.path.isdir(DB_PATH):
|
||||||
os.mkdir(DB_PATH)
|
os.mkdir(DB_PATH)
|
||||||
DASHBOARD_CONF = os.path.join(configuration_path, 'wg-dashboard.ini')
|
DASHBOARD_CONF = os.path.join(configuration_path, 'wg-dashboard.ini')
|
||||||
|
|
||||||
# Upgrade Required
|
# Upgrade Required
|
||||||
UPDATE = None
|
UPDATE = None
|
||||||
|
|
||||||
# Flask App Configuration
|
# Flask App Configuration
|
||||||
app = Flask("WGDashboard")
|
app = Flask("WGDashboard")
|
||||||
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 5206928
|
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 5206928
|
||||||
app.secret_key = secrets.token_urlsafe(16)
|
app.secret_key = secrets.token_urlsafe(16)
|
||||||
app.config['TEMPLATES_AUTO_RELOAD'] = True
|
app.config['TEMPLATES_AUTO_RELOAD'] = True
|
||||||
|
|
||||||
# Enable QR Code Generator
|
# Enable QR Code Generator
|
||||||
QRcode(app)
|
QRcode(app)
|
||||||
|
|
||||||
@ -99,7 +103,6 @@ def get_conf_peer_key(config_name):
|
|||||||
return config_name + " is not running."
|
return config_name + " is not running."
|
||||||
|
|
||||||
|
|
||||||
# Get numbers of connected peer of a configuration
|
|
||||||
def get_conf_running_peer_number(config_name):
|
def get_conf_running_peer_number(config_name):
|
||||||
"""
|
"""
|
||||||
Get number of running peers on wireguard interface.
|
Get number of running peers on wireguard interface.
|
||||||
@ -128,7 +131,6 @@ def get_conf_running_peer_number(config_name):
|
|||||||
return running
|
return running
|
||||||
|
|
||||||
|
|
||||||
# Read [Interface] section from configuration file
|
|
||||||
def read_conf_file_interface(config_name):
|
def read_conf_file_interface(config_name):
|
||||||
"""
|
"""
|
||||||
Get interface settings.
|
Get interface settings.
|
||||||
@ -161,7 +163,6 @@ def read_conf_file(config_name):
|
|||||||
@rtype: dict
|
@rtype: dict
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Read Configuration File Start
|
|
||||||
conf_location = WG_CONF_PATH + "/" + config_name + ".conf"
|
conf_location = WG_CONF_PATH + "/" + config_name + ".conf"
|
||||||
f = open(conf_location, 'r')
|
f = open(conf_location, 'r')
|
||||||
file = f.read().split("\n")
|
file = f.read().split("\n")
|
||||||
@ -294,6 +295,7 @@ def get_endpoint(config_name):
|
|||||||
count += 2
|
count += 2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_allowed_ip(conf_peer_data, config_name):
|
def get_allowed_ip(conf_peer_data, config_name):
|
||||||
"""
|
"""
|
||||||
Get allowed ips from all peers of a configuration
|
Get allowed ips from all peers of a configuration
|
||||||
@ -626,7 +628,6 @@ def close_DB(exception):
|
|||||||
g.db.close()
|
g.db.close()
|
||||||
|
|
||||||
|
|
||||||
# Before request
|
|
||||||
@app.before_request
|
@app.before_request
|
||||||
def auth_req():
|
def auth_req():
|
||||||
"""
|
"""
|
||||||
@ -1700,7 +1701,6 @@ def get_host_bind():
|
|||||||
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")
|
||||||
|
|
||||||
return app_ip, app_port
|
return app_ip, app_port
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user