mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2024-11-22 15:20:09 +01:00
Commit
This commit is contained in:
parent
b17575b197
commit
040f6a8393
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,3 +9,4 @@ tmp
|
|||||||
__pycache__
|
__pycache__
|
||||||
src/wg-dashboard.ini
|
src/wg-dashboard.ini
|
||||||
src/wg-dashboard.ini
|
src/wg-dashboard.ini
|
||||||
|
src/static/pic.xd
|
||||||
|
144
README.md
144
README.md
@ -7,42 +7,39 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="http://ForTheBadge.com/images/badges/made-with-python.svg">
|
<img src="http://ForTheBadge.com/images/badges/made-with-python.svg">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://github.com/donaldzou/wireguard-dashboard/releases/latest"><img src="https://img.shields.io/github/v/release/donaldzou/wireguard-dashboard"></a>
|
<a href="https://github.com/donaldzou/wireguard-dashboard/releases/latest"><img src="https://img.shields.io/github/v/release/donaldzou/wireguard-dashboard"></a>
|
||||||
</p>
|
</p>
|
||||||
<p align="center">Monitoring Wireguard is not convinient, need to login into server and type <code>wg show</code>. That's why this platform is being created, to view all configurations in a more straight forward way.</p>
|
<p align="center">Monitoring Wireguard is not convinient, need to login into server and type <code>wg show</code>. That's why this platform is being created, to view all configurations and manage them in a easier way.</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 📣 What's New: Version 2.0
|
||||||
|
|
||||||
|
- Added login function to dashboard
|
||||||
|
- ***I'm not using the most ideal way to store the username and password, feel free to provide a better way to do this if you any good idea!***
|
||||||
|
- Added a config file to the dashboard
|
||||||
|
- Dashboard config can be change within the **Setting** tab on the side bar
|
||||||
|
- Adjusted UI
|
||||||
|
- And much more!
|
||||||
|
|
||||||
## 💡 Features
|
## 💡 Features
|
||||||
|
|
||||||
- Add peers in configuration
|
- Add peers for each WireGuard configuration
|
||||||
- Manage peer names
|
- Manage peer
|
||||||
- Delete peers
|
- Delete peers
|
||||||
- And many more coming up! Welcome to contribute to this project!
|
- And many more coming up! Welcome to contribute to this project!
|
||||||
|
|
||||||
## 📝 Requirement
|
## 📝 Requirement
|
||||||
|
|
||||||
- Ubuntu 18.04.1 LTS, other OS might work, but haven't test yet.
|
- Ubuntu or Debian based OS, other might work, but haven't test yet. Tested on the following OS:
|
||||||
- ‼️ Make sure you have **Wireguard** installed.‼️ <a href="https://www.wireguard.com/install/">How to install?</a>
|
- [x] Ubuntu 18.04.1 LTS
|
||||||
|
- [ ] If you have tested on other OS and it works perfectly please provide it to me!
|
||||||
|
|
||||||
|
- ‼️ Make sure you have **Wireguard** and **Wireguard-Tools (`wg-quick`)** installed.‼️ <a href="https://www.wireguard.com/install/">How to install?</a>
|
||||||
- Configuration files under **/etc/wireguard**
|
- Configuration files under **/etc/wireguard**
|
||||||
|
|
||||||
***Example `.conf` file***
|
- **Note: For peers, `PublicKey` & `AllowedIPs` is required.**
|
||||||
```
|
|
||||||
[Interface]
|
|
||||||
Address = 192.168.0.1/24
|
|
||||||
SaveConfig = true
|
|
||||||
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -A FORWARD -o wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
|
||||||
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -D FORWARD -o wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
|
|
||||||
ListenPort = 12345
|
|
||||||
PrivateKey = ABCDEFGHIJKLMNOPQRSTUVWXYZ1234
|
|
||||||
|
|
||||||
[Peer]
|
|
||||||
PublicKey = HABCDEFGHIJKLMNOPQRSTUVWXYZ123123123123
|
|
||||||
AllowedIPs = 192.168.0.2/32
|
|
||||||
|
|
||||||
...
|
|
||||||
```
|
|
||||||
**Note: For peers, `PublicKey` & `AllowedIPs` is required.**
|
|
||||||
- Python 3.7+ & Pip3
|
- Python 3.7+ & Pip3
|
||||||
```
|
```
|
||||||
$ sudo apt-get install python3 python3-pip
|
$ sudo apt-get install python3 python3-pip
|
||||||
@ -50,36 +47,98 @@
|
|||||||
|
|
||||||
## 🛠 Install
|
## 🛠 Install
|
||||||
|
|
||||||
**1. Install Python Dependencies**
|
1. Download Wireguard Dashboard
|
||||||
|
|
||||||
```
|
```
|
||||||
$ python3 -m pip install flask tinydb
|
$ git clone https://github.com/donaldzou/Wireguard-Dashboard.git
|
||||||
```
|
```
|
||||||
|
|
||||||
**2. Install Wireguard Dashboard**
|
**2. Install Python Dependencies**
|
||||||
|
|
||||||
```
|
|
||||||
$ git clone -b v1.1.2 https://github.com/donaldzou/Wireguard-Dashboard.git
|
|
||||||
$ cd Wireguard-Dashboard/src
|
|
||||||
$ python3 dashboard.py
|
|
||||||
```
|
|
||||||
|
|
||||||
Access your server with port `10086` ! e.g (http://your_server_ip:10086)
|
|
||||||
|
|
||||||
**3. Install with Production Mode (Optional), not tested yet. ‼️ Proceed with caution. ‼️**
|
|
||||||
|
|
||||||
```
|
```
|
||||||
$ cd Wireguard-Dashboard/src
|
$ cd Wireguard-Dashboard/src
|
||||||
$ export FLASK_APP=dashboard.py
|
$ python3 -m pip install -r requirements.txt
|
||||||
$ export FLASK_RUN_HOST=0.0.0.0
|
|
||||||
$ export FLASK_ENV=development
|
|
||||||
$ export FLASK_DEBUG=0
|
|
||||||
$ flask run
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**3. Install & run Wireguard Dashboard**
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo sh wgd.sh start
|
||||||
|
```
|
||||||
|
|
||||||
|
Access your server with port `10086` ! e.g (http://your_server_ip:10086), continue to read to on how to change port and ip that dashboard is running with.
|
||||||
|
|
||||||
|
## 🪜 Usage
|
||||||
|
|
||||||
|
**1. Start/Stop/Restart Wireguard Dashboard**
|
||||||
|
|
||||||
|
```
|
||||||
|
$ cd Wireguard-Dashboard/src
|
||||||
|
$ sudo sh wgd.sh start # Start the dashboard in background
|
||||||
|
$ sudo sh wgd.sh debug # Start the dashboard in foreground (debug mode)
|
||||||
|
$ sudo sh wgd.sh stop # Stop the dashboard
|
||||||
|
$ sudo sh wgd.sh restart # Restart the dasboard
|
||||||
|
$ sudo sh wgd.sh update # Update the dashboard
|
||||||
|
```
|
||||||
|
|
||||||
|
⚠️ **For first time user please also read the next section.**
|
||||||
|
|
||||||
|
## ✂️ Dashboard Configuration
|
||||||
|
|
||||||
|
Since version 2.0, Wireguard Dashboard will be using a configuration file called `wg-dashboard.ini`, (It will generate automatically after first time running the dashboard). More options will include in future versions, and for now it included the following config:
|
||||||
|
|
||||||
|
- `[Account]`
|
||||||
|
- `username` - Username (Default: `admin`)
|
||||||
|
- `password` - Password, will be hash with SHA256 (Default: `admin`).
|
||||||
|
- `[Server]`
|
||||||
|
- `app_ip` - IP address the flask will run with (Default: `0.0.0.0`)
|
||||||
|
- `app_port` - Port the flask will run with (Default: `10086`)
|
||||||
|
- `auth_req` - Does the dashboard need authentication (Default: `true`)
|
||||||
|
- If `auth_req = false` , user will not be access the **Setting** tab due to security consideration. **Can only changing the file directly in system**.
|
||||||
|
- `version` - Dashboard Version
|
||||||
|
|
||||||
|
All these settings***** will be able to configure within the dashboard in **Settings** on the sidebar, without changing the actual file.
|
||||||
|
|
||||||
|
- Example
|
||||||
|
|
||||||
|
```
|
||||||
|
[Account]
|
||||||
|
username = admin
|
||||||
|
password = 8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918
|
||||||
|
|
||||||
|
[Server]
|
||||||
|
app_ip = 0.0.0.0
|
||||||
|
app_port = 10086
|
||||||
|
auth_req = true
|
||||||
|
version = v2.0
|
||||||
|
```
|
||||||
|
|
||||||
|
**: Except `version` and `auth_req` due to security consideration.*
|
||||||
|
|
||||||
|
## ❓ How to update the dashboard?
|
||||||
|
|
||||||
|
```
|
||||||
|
$ cd wireguard-dashboard
|
||||||
|
$ sudo sh wgd.sh update # Perform update
|
||||||
|
$ sudo sh wgd.sh start # Start dashboard
|
||||||
|
|
||||||
## 🔍 Example
|
## 🔍 Example
|
||||||
|
|
||||||
![Index Image](https://github.com/donaldzou/Wireguard-Dashboard/raw/main/src/static/index.png)
|
![Index Image](https://github.com/donaldzou/Wireguard-Dashboard/raw/main/src/static/index.png)
|
||||||
![Conf Image](https://github.com/donaldzou/Wireguard-Dashboard/raw/main/src/static/configuration.png)
|
|
||||||
|
<p align=center>Index Page</p>
|
||||||
|
|
||||||
|
![Signin Image](https://github.com/donaldzou/Wireguard-Dashboard/raw/main/src/static/signin.png)
|
||||||
|
|
||||||
|
<p align=center>Signin Page</p>
|
||||||
|
|
||||||
|
![Configuration Image](https://github.com/donaldzou/Wireguard-Dashboard/raw/main/src/static/configuration.png)
|
||||||
|
|
||||||
|
<p align=center>Configuration Page</p>
|
||||||
|
|
||||||
|
![Settings Image](https://github.com/donaldzou/Wireguard-Dashboard/raw/main/src/static/settings.png)
|
||||||
|
|
||||||
|
<p align=center>Settings Page</p>
|
||||||
|
|
||||||
## Contributors ✨
|
## Contributors ✨
|
||||||
|
|
||||||
@ -105,3 +164,4 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|||||||
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
||||||
|
|
||||||
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
||||||
|
|
||||||
|
@ -11,17 +11,17 @@ import configparser
|
|||||||
# PIP installed library
|
# PIP installed library
|
||||||
import ifcfg
|
import ifcfg
|
||||||
from tinydb import TinyDB, Query
|
from tinydb import TinyDB, Query
|
||||||
|
|
||||||
|
|
||||||
dashboard_version = 'v2.0'
|
dashboard_version = 'v2.0'
|
||||||
dashboard_conf = 'wg-dashboard.ini'
|
dashboard_conf = 'wg-dashboard.ini'
|
||||||
conf_location = "/etc/wireguard"
|
update = ""
|
||||||
|
|
||||||
app = Flask("Wireguard Dashboard")
|
app = Flask("Wireguard Dashboard")
|
||||||
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
|
||||||
conf_data = {}
|
conf_data = {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_conf_peer_key(config_name):
|
def get_conf_peer_key(config_name):
|
||||||
keys = []
|
keys = []
|
||||||
try:
|
try:
|
||||||
@ -53,7 +53,7 @@ def get_conf_running_peer_number(config_name):
|
|||||||
|
|
||||||
def read_conf_file(config_name):
|
def read_conf_file(config_name):
|
||||||
# Read Configuration File Start
|
# Read Configuration File Start
|
||||||
conf_location = "/etc/wireguard/" + 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")
|
||||||
conf_peer_data = {
|
conf_peer_data = {
|
||||||
@ -188,7 +188,7 @@ def get_peers(config_name):
|
|||||||
|
|
||||||
def get_conf_pub_key(config_name):
|
def get_conf_pub_key(config_name):
|
||||||
conf = configparser.ConfigParser(strict=False)
|
conf = configparser.ConfigParser(strict=False)
|
||||||
conf.read(conf_location+"/"+config_name+".conf")
|
conf.read(wg_conf_path + "/" + config_name + ".conf")
|
||||||
pri = conf.get("Interface", "PrivateKey")
|
pri = conf.get("Interface", "PrivateKey")
|
||||||
pub = subprocess.check_output("echo '" + pri + "' | wg pubkey", shell=True)
|
pub = subprocess.check_output("echo '" + pri + "' | wg pubkey", shell=True)
|
||||||
conf.clear()
|
conf.clear()
|
||||||
@ -197,7 +197,7 @@ def get_conf_pub_key(config_name):
|
|||||||
|
|
||||||
def get_conf_listen_port(config_name):
|
def get_conf_listen_port(config_name):
|
||||||
conf = configparser.ConfigParser(strict=False)
|
conf = configparser.ConfigParser(strict=False)
|
||||||
conf.read(conf_location + "/" + config_name + ".conf")
|
conf.read(wg_conf_path + "/" + config_name + ".conf")
|
||||||
port = conf.get("Interface", "ListenPort")
|
port = conf.get("Interface", "ListenPort")
|
||||||
conf.clear()
|
conf.clear()
|
||||||
return port
|
return port
|
||||||
@ -224,7 +224,7 @@ def get_conf_status(config_name):
|
|||||||
|
|
||||||
def get_conf_list():
|
def get_conf_list():
|
||||||
conf = []
|
conf = []
|
||||||
for i in os.listdir(conf_location):
|
for i in os.listdir(wg_conf_path):
|
||||||
if not i.startswith('.'):
|
if not i.startswith('.'):
|
||||||
if ".conf" in i:
|
if ".conf" in i:
|
||||||
i = i.replace('.conf', '')
|
i = i.replace('.conf', '')
|
||||||
@ -246,6 +246,8 @@ def auth_req():
|
|||||||
conf = configparser.ConfigParser(strict=False)
|
conf = configparser.ConfigParser(strict=False)
|
||||||
conf.read(dashboard_conf)
|
conf.read(dashboard_conf)
|
||||||
req = conf.get("Server", "auth_req")
|
req = conf.get("Server", "auth_req")
|
||||||
|
session['update'] = update
|
||||||
|
session['dashboard_version'] = dashboard_version
|
||||||
if req == "true":
|
if req == "true":
|
||||||
if '/static/' not in request.path and \
|
if '/static/' not in request.path and \
|
||||||
request.endpoint != "signin" and \
|
request.endpoint != "signin" and \
|
||||||
@ -256,7 +258,7 @@ def auth_req():
|
|||||||
print("not loggedin")
|
print("not loggedin")
|
||||||
return redirect(url_for("signin"))
|
return redirect(url_for("signin"))
|
||||||
else:
|
else:
|
||||||
if request.endpoint in ['signin', 'signout', 'auth', 'settings', 'update_acct', 'update_pwd', 'update_app_ip_port']:
|
if request.endpoint in ['signin', 'signout', 'auth', 'settings', 'update_acct', 'update_pwd', 'update_app_ip_port', 'update_wg_conf_path']:
|
||||||
return redirect(url_for("index"))
|
return redirect(url_for("index"))
|
||||||
|
|
||||||
@app.route('/signin', methods=['GET'])
|
@app.route('/signin', methods=['GET'])
|
||||||
@ -289,7 +291,7 @@ def settings():
|
|||||||
session.pop("message")
|
session.pop("message")
|
||||||
session.pop("message_status")
|
session.pop("message_status")
|
||||||
required_auth = config.get("Server", "auth_req")
|
required_auth = config.get("Server", "auth_req")
|
||||||
return render_template('settings.html',conf=get_conf_list(),message=message, status=status, app_ip = config.get("Server", "app_ip"), app_port = config.get("Server", "app_port"), required_auth=required_auth)
|
return render_template('settings.html',conf=get_conf_list(),message=message, status=status, app_ip=config.get("Server", "app_ip"), app_port=config.get("Server", "app_port"), required_auth=required_auth, wg_conf_path=config.get("Server", "wg_conf_path"))
|
||||||
|
|
||||||
@app.route('/auth', methods=['POST'])
|
@app.route('/auth', methods=['POST'])
|
||||||
def auth():
|
def auth():
|
||||||
@ -362,19 +364,24 @@ def update_app_ip_port():
|
|||||||
config.clear()
|
config.clear()
|
||||||
os.system('bash wgd.sh restart')
|
os.system('bash wgd.sh restart')
|
||||||
|
|
||||||
@app.route('/check_update_dashboard', methods=['GET'])
|
@app.route('/update_wg_conf_path', methods=['POST'])
|
||||||
def check_update_dashboard():
|
def update_wg_conf_path():
|
||||||
conf = configparser.ConfigParser(strict=False)
|
config = configparser.ConfigParser(strict=False)
|
||||||
conf.read(dashboard_conf)
|
config.read(dashboard_conf)
|
||||||
data = urllib.request.urlopen("https://api.github.com/repos/donaldzou/wireguard-dashboard/releases").read()
|
config.set("Server", "wg_conf_path", request.form['wg_conf_path'])
|
||||||
output = json.loads(data)
|
config.write(open(dashboard_conf, "w"))
|
||||||
if conf.get("Server", "version") == output[0]["tag_name"]:
|
session['message'] = "WireGuard Configuration Path Update Successfully!"
|
||||||
return "false"
|
session['message_status'] = "success"
|
||||||
else:
|
config.clear()
|
||||||
return "true"
|
os.system('bash wgd.sh restart')
|
||||||
|
|
||||||
|
# @app.route('/check_update_dashboard', methods=['GET'])
|
||||||
|
# def check_update_dashboard():
|
||||||
|
# return have_update
|
||||||
|
|
||||||
@app.route('/', methods=['GET'])
|
@app.route('/', methods=['GET'])
|
||||||
def index():
|
def index():
|
||||||
|
print(request.referrer)
|
||||||
return render_template('index.html', conf=get_conf_list())
|
return render_template('index.html', conf=get_conf_list())
|
||||||
|
|
||||||
@app.route('/configuration/<config_name>', methods=['GET'])
|
@app.route('/configuration/<config_name>', methods=['GET'])
|
||||||
@ -427,7 +434,8 @@ def switch(config_name):
|
|||||||
status = subprocess.check_output("wg-quick up " + config_name, shell=True)
|
status = subprocess.check_output("wg-quick up " + config_name, shell=True)
|
||||||
except Exception:
|
except Exception:
|
||||||
return redirect('/')
|
return redirect('/')
|
||||||
return redirect('/')
|
|
||||||
|
return redirect(request.referrer)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/add_peer/<config_name>', methods=['POST'])
|
@app.route('/add_peer/<config_name>', methods=['POST'])
|
||||||
@ -453,6 +461,9 @@ def add_peer(config_name):
|
|||||||
|
|
||||||
@app.route('/remove_peer/<config_name>', methods=['POST'])
|
@app.route('/remove_peer/<config_name>', methods=['POST'])
|
||||||
def remove_peer(config_name):
|
def remove_peer(config_name):
|
||||||
|
if get_conf_status(config_name) == "stopped":
|
||||||
|
return "Your need to turn on "+config_name+" first."
|
||||||
|
|
||||||
db = TinyDB("db/" + config_name + ".json")
|
db = TinyDB("db/" + config_name + ".json")
|
||||||
peers = Query()
|
peers = Query()
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
@ -494,8 +505,7 @@ def get_peer_name(config_name):
|
|||||||
|
|
||||||
def init_dashboard():
|
def init_dashboard():
|
||||||
# Set Default INI File
|
# Set Default INI File
|
||||||
conf = configparser.ConfigParser(strict=False)
|
if not os.path.isfile("wg-dashboard.ini"):
|
||||||
if os.path.isfile("wg-dashboard.ini") == False:
|
|
||||||
conf_file = open("wg-dashboard.ini", "w+")
|
conf_file = open("wg-dashboard.ini", "w+")
|
||||||
config = configparser.ConfigParser(strict=False)
|
config = configparser.ConfigParser(strict=False)
|
||||||
config.read(dashboard_conf)
|
config.read(dashboard_conf)
|
||||||
@ -509,6 +519,8 @@ def init_dashboard():
|
|||||||
|
|
||||||
if "Server" not in config:
|
if "Server" not in config:
|
||||||
config['Server'] = {}
|
config['Server'] = {}
|
||||||
|
if 'wg_conf_path' not in config['Server']:
|
||||||
|
config['Server']['wg_conf_path'] = '/etc/wireguard'
|
||||||
if 'app_ip' not in config['Server']:
|
if 'app_ip' not in config['Server']:
|
||||||
config['Server']['app_ip'] = '0.0.0.0'
|
config['Server']['app_ip'] = '0.0.0.0'
|
||||||
if 'app_port' not in config['Server']:
|
if 'app_port' not in config['Server']:
|
||||||
@ -518,13 +530,27 @@ def init_dashboard():
|
|||||||
if 'version' not in config['Server'] or config['Server']['version'] != dashboard_version:
|
if 'version' not in config['Server'] or config['Server']['version'] != dashboard_version:
|
||||||
config['Server']['version'] = dashboard_version
|
config['Server']['version'] = dashboard_version
|
||||||
config.write(open(dashboard_conf, "w"))
|
config.write(open(dashboard_conf, "w"))
|
||||||
|
config.clear()
|
||||||
|
|
||||||
|
def check_update():
|
||||||
|
conf = configparser.ConfigParser(strict=False)
|
||||||
|
conf.read(dashboard_conf)
|
||||||
|
data = urllib.request.urlopen("https://api.github.com/repos/donaldzou/wireguard-dashboard/releases").read()
|
||||||
|
output = json.loads(data)
|
||||||
|
if conf.get("Server", "version") == output[0]["tag_name"]:
|
||||||
|
return "false"
|
||||||
|
else:
|
||||||
|
return "true"
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
init_dashboard()
|
init_dashboard()
|
||||||
|
update = check_update()
|
||||||
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")
|
||||||
|
wg_conf_path = config.get("Server", "wg_conf_path")
|
||||||
config.clear()
|
config.clear()
|
||||||
app.run(host=app_ip, debug=False, port=app_port)
|
app.run(host=app_ip, debug=False, port=app_port)
|
||||||
|
|
||||||
|
@ -108,13 +108,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
|
{% include "footer.html" %}
|
||||||
<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>
|
|
||||||
<script>
|
<script>
|
||||||
$(".sb-{{conf_data['name']}}-url").addClass("active");
|
$(".sb-{{conf_data['name']}}-url").addClass("active");
|
||||||
|
|
||||||
@ -129,11 +123,6 @@
|
|||||||
async:false,
|
async:false,
|
||||||
success: function (response){
|
success: function (response){
|
||||||
$("#config_body").html(response);
|
$("#config_body").html(response);
|
||||||
$.ajax({
|
|
||||||
url: "{{ url_for('static',filename='bootstrap4-toggle.min.js') }}",
|
|
||||||
dataType: "script",
|
|
||||||
cache: true
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -146,19 +135,14 @@
|
|||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
$("body").on("click", ".switch", function (){
|
$("body").on("click", ".switch", function (){
|
||||||
if ($(this).prop('checked') === true){
|
$(this).siblings($(".spinner-border")).css("display", "inline-block");
|
||||||
if (confirm('Are you sure you want to turn off this connection?')){
|
$(this).remove()
|
||||||
location.replace("/switch/"+$(this).attr('id'))
|
location.replace("/switch/"+$(this).attr('id'));
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
location.replace("/switch/"+$(this).attr('id'))
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
$("#save_peer").click(function(){
|
$("#save_peer").click(function(){
|
||||||
if ($("#allowed_ips") != "" && $("#public_key") != ""){
|
if ($("#allowed_ips") != "" && $("#public_key") != ""){
|
||||||
var conf = $(this).attr('conf_id')
|
var conf = $(this).attr('conf_id')
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "/add_peer/"+conf,
|
url: "/add_peer/"+conf,
|
||||||
|
@ -5,16 +5,4 @@
|
|||||||
crossorigin="anonymous"></script>
|
crossorigin="anonymous"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.min.js"
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.min.js"
|
||||||
integrity="sha384-w1Q4orYjBQndcko6MimVbzY0tgp4pWB4lZ7lr30WKz0vr/aWKhXdBNmNb5D92v7s"
|
integrity="sha384-w1Q4orYjBQndcko6MimVbzY0tgp4pWB4lZ7lr30WKz0vr/aWKhXdBNmNb5D92v7s"
|
||||||
crossorigin="anonymous"></script>
|
crossorigin="anonymous"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/js/bootstrap4-toggle.min.js"></script>
|
|
||||||
<script>
|
|
||||||
$.ajax({
|
|
||||||
method: "GET",
|
|
||||||
url: "/check_update_dashboard",
|
|
||||||
success: function (response){
|
|
||||||
if (response === "true"){
|
|
||||||
$(".sb-update-url").append("<span class=\"dot dot-running\"></span>")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
|
@ -1,26 +1,27 @@
|
|||||||
<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4 mt-4">
|
<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="info mt-4">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm">
|
<div class="col">
|
||||||
<small class="text-muted"><strong>CONFIGURATION</strong></small>
|
<small class="text-muted"><strong>CONFIGURATION</strong></small>
|
||||||
<h1 class="mb-3">{{conf_data['name']}}</h1>
|
<h1 class="mb-3">{{conf_data['name']}}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm">
|
<div class="col">
|
||||||
<small class="text-muted"><strong>ACTION</strong></small><br>
|
<small class="text-muted"><strong>ACTION</strong></small><br>
|
||||||
{# <input class="mt-2 switch" id="{{conf_data['name']}}" type="checkbox" data-toggle="toggle" {{conf_data['checked']}} data-size="sm">#}
|
|
||||||
|
|
||||||
{% if conf_data['checked'] == "checked" %}
|
{% if conf_data['checked'] == "checked" %}
|
||||||
<a href="#" id="{{conf_data['name']}}" {{conf_data['checked']}} class="switch text-primary"><i class="bi bi-toggle2-on"></i> ON</a>
|
<a href="#" id="{{conf_data['name']}}" {{conf_data['checked']}} class="switch text-primary"><i class="bi bi-toggle2-on"></i> ON</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="#" id="{{conf_data['name']}}" {{conf_data['checked']}} class="switch text-secondary"><i class="bi bi-toggle2-off"></i> OFF</a>
|
<a href="#" id="{{conf_data['name']}}" {{conf_data['checked']}} class="switch text-secondary"><i class="bi bi-toggle2-off"></i> OFF</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<div class="spinner-border text-primary" role="status" style="display: none; margin-top: 10px">
|
||||||
|
<span class="sr-only">Loading...</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="w-100"></div>
|
<div class="w-100"></div>
|
||||||
<div class="col-sm">
|
<div class="col">
|
||||||
<small class="text-muted"><strong>STATUS</strong></small>
|
<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>
|
<h6 style="text-transform: uppercase;">{{conf_data['status']}}<span class="dot dot-{{conf_data['status']}}"></span></h6>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm">
|
<div class="col">
|
||||||
<small class="text-muted"><strong>CONNECTED PEERS</strong></small>
|
<small class="text-muted"><strong>CONNECTED PEERS</strong></small>
|
||||||
<h6 style="text-transform: uppercase;">{{conf_data['running_peer']}}</h6>
|
<h6 style="text-transform: uppercase;">{{conf_data['running_peer']}}</h6>
|
||||||
</div>
|
</div>
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
{% include "sidebar.html" %}
|
{% include "sidebar.html" %}
|
||||||
<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4">
|
<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4">
|
||||||
|
<h1 class="pb-4 mt-4">Home</h1>
|
||||||
{% for i in conf%}
|
{% for i in conf%}
|
||||||
<div class="card mt-3">
|
<div class="card mt-3">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@ -25,10 +26,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-md">
|
<div class="col-md">
|
||||||
{% if i['checked'] == "checked" %}
|
{% if i['checked'] == "checked" %}
|
||||||
<a href="#" id="{{i['conf']}}" {{i['checked']}} class="switch text-primary"><i class="bi bi-toggle2-on"></i></a>
|
<a href="#" id="{{i['conf']}}" {{i['checked']}} class="switch text-primary tt"><i class="bi bi-toggle2-on"></i></a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="#" id="{{i['conf']}}" {{i['checked']}} class="switch text-secondary"><i class="bi bi-toggle2-off"></i></a>
|
<a href="#" id="{{i['conf']}}" {{i['checked']}} class="switch text-secondary"><i class="bi bi-toggle2-off"></i></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<div class="spinner-border text-primary" role="status" style="display: none">
|
||||||
|
<span class="sr-only">Loading...</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -40,6 +44,8 @@
|
|||||||
{% include "footer.html" %}
|
{% include "footer.html" %}
|
||||||
<script>
|
<script>
|
||||||
$('.switch').click(function() {
|
$('.switch').click(function() {
|
||||||
|
$(this).siblings($(".spinner-border")).css("display", "inline-block")
|
||||||
|
$(this).remove()
|
||||||
location.replace("/switch/"+$(this).attr('id'))
|
location.replace("/switch/"+$(this).attr('id'))
|
||||||
});
|
});
|
||||||
$(".sb-home-url").addClass("active")
|
$(".sb-home-url").addClass("active")
|
||||||
|
@ -22,6 +22,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<hr>
|
<hr>
|
||||||
|
<h3>WireGuard Configuration Path</h3>
|
||||||
|
<form action="/update_wg_conf_path" method="post" class="update_wg_conf_path">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="username">Path</label>
|
||||||
|
<input type="text" class="form-control mb-4" id="wg_conf_path" name="wg_conf_path" value="{{ wg_conf_path }}">
|
||||||
|
<button class="btn btn-danger change_path">Update Path & Restart Dashboard</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<hr>
|
||||||
<h3>Security</h3>
|
<h3>Security</h3>
|
||||||
<form action="/update_pwd", method="post">
|
<form action="/update_pwd", method="post">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@ -102,6 +111,21 @@
|
|||||||
$(".confirm_restart").html("Redirecting you in "+countdown+" seconds.")
|
$(".confirm_restart").html("Redirecting you in "+countdown+" seconds.")
|
||||||
countdown--;
|
countdown--;
|
||||||
},1000)
|
},1000)
|
||||||
})
|
});
|
||||||
|
|
||||||
|
$(".change_path").click(function (){
|
||||||
|
$(this).attr("disabled", "disabled");
|
||||||
|
countdown = 5;
|
||||||
|
setInterval(function (){
|
||||||
|
if (countdown === 0){
|
||||||
|
location.reload()
|
||||||
|
}
|
||||||
|
$(".change_path").html("Redirecting you in "+countdown+" seconds.")
|
||||||
|
countdown--;
|
||||||
|
},1000)
|
||||||
|
$.post('/update_wg_conf_path', $('.update_wg_conf_path').serialize())
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
@ -7,7 +7,9 @@
|
|||||||
{% if "username" in session %}
|
{% if "username" in session %}
|
||||||
<li class="nav-item"><a class="nav-link sb-settings-url" href="/settings">Settings</a></li>
|
<li class="nav-item"><a class="nav-link sb-settings-url" href="/settings">Settings</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li class="nav-item"><a class="nav-link sb-update-url" href="/">Check Update</a></li>
|
{% if session['update'] == "true" %}
|
||||||
|
<li class="nav-item sb-update-li"><a class="nav-link sb-update-url" href="/">New Update Available!<span class="dot dot-running"></span></a></li>
|
||||||
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
<hr>
|
<hr>
|
||||||
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
|
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
|
||||||
@ -24,6 +26,9 @@
|
|||||||
<li class="nav-item"><a class="nav-link text-danger" href="/signout" style="font-weight: bold">Sign Out</a></li>
|
<li class="nav-item"><a class="nav-link text-danger" href="/signout" style="font-weight: bold">Sign Out</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<ul class="nav flex-column">
|
||||||
|
<li class="nav-item"><a href="https://github.com/donaldzou/wireguard-dashboard"><small class="nav-link text-muted">{{ session['dashboard_version'] }}</small></a></li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
14
src/wgd.sh
14
src/wgd.sh
@ -43,6 +43,18 @@ start_wgd_debug() {
|
|||||||
python3 "$app_name"
|
python3 "$app_name"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update_wgd() {
|
||||||
|
git pull
|
||||||
|
if check_wgd_status; then
|
||||||
|
stop_wgd
|
||||||
|
sleep 2
|
||||||
|
printf "Wireguard Dashboard is stopped. \n"
|
||||||
|
start_wgd_debug
|
||||||
|
else
|
||||||
|
start_wgd_debug
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if [ "$#" != 1 ];
|
if [ "$#" != 1 ];
|
||||||
@ -63,7 +75,7 @@ if [ "$#" != 1 ];
|
|||||||
printf "Wireguard Dashboard is not running. \n"
|
printf "Wireguard Dashboard is not running. \n"
|
||||||
fi
|
fi
|
||||||
elif [ "$1" = "update" ]; then
|
elif [ "$1" = "update" ]; then
|
||||||
echo "update";
|
update_wgd
|
||||||
elif [ "$1" = "restart" ]; then
|
elif [ "$1" = "restart" ]; then
|
||||||
if check_wgd_status; then
|
if check_wgd_status; then
|
||||||
stop_wgd
|
stop_wgd
|
||||||
|
Loading…
Reference in New Issue
Block a user