17 |
18 | ### Credits
19 |
20 | This project uses the easy install scripts by [Nyr](https://github.com/Nyr) for setting up the OpenVPN and WireGuard services.
--------------------------------------------------------------------------------
/frontend/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "frontend",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^5.16.5",
7 | "@testing-library/react": "^13.4.0",
8 | "@testing-library/user-event": "^13.5.0",
9 | "axios": "^1.4.0",
10 | "react": "^18.2.0",
11 | "react-dom": "^18.2.0",
12 | "react-scripts": "5.0.1",
13 | "web-vitals": "^2.1.4"
14 | },
15 | "scripts": {
16 | "start": "react-scripts start",
17 | "build": "react-scripts build",
18 | "test": "react-scripts test",
19 | "eject": "react-scripts eject"
20 | },
21 | "eslintConfig": {
22 | "extends": [
23 | "react-app",
24 | "react-app/jest"
25 | ]
26 | },
27 | "browserslist": {
28 | "production": [
29 | ">0.2%",
30 | "not dead",
31 | "not op_mini all"
32 | ],
33 | "development": [
34 | "last 1 chrome version",
35 | "last 1 firefox version",
36 | "last 1 safari version"
37 | ]
38 | },
39 | "devDependencies": {
40 | "daisyui": "^3.2.1",
41 | "tailwindcss": "^3.3.2"
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/frontend/build/static/js/main.49f28130.js.LICENSE.txt:
--------------------------------------------------------------------------------
1 | /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
2 |
3 | /**
4 | * @license React
5 | * react-dom.production.min.js
6 | *
7 | * Copyright (c) Facebook, Inc. and its affiliates.
8 | *
9 | * This source code is licensed under the MIT license found in the
10 | * LICENSE file in the root directory of this source tree.
11 | */
12 |
13 | /**
14 | * @license React
15 | * react-jsx-runtime.production.min.js
16 | *
17 | * Copyright (c) Facebook, Inc. and its affiliates.
18 | *
19 | * This source code is licensed under the MIT license found in the
20 | * LICENSE file in the root directory of this source tree.
21 | */
22 |
23 | /**
24 | * @license React
25 | * react.production.min.js
26 | *
27 | * Copyright (c) Facebook, Inc. and its affiliates.
28 | *
29 | * This source code is licensed under the MIT license found in the
30 | * LICENSE file in the root directory of this source tree.
31 | */
32 |
33 | /**
34 | * @license React
35 | * scheduler.production.min.js
36 | *
37 | * Copyright (c) Facebook, Inc. and its affiliates.
38 | *
39 | * This source code is licensed under the MIT license found in the
40 | * LICENSE file in the root directory of this source tree.
41 | */
42 |
--------------------------------------------------------------------------------
/docs/manual installation.md:
--------------------------------------------------------------------------------
1 | Open ports in Azure portal then these in VM
2 |
3 | ```
4 | sudo ufw allow 80
5 | sudo ufw allow 443
6 | sudo ufw allow 4000
7 | ```
8 |
9 | Create 1GB Swap memeory `(1M * 1000 ~= 1GB)`
10 |
11 | ```
12 | mkdir -p /var/swapmemory
13 | cd /var/swapmemory
14 | dd if=/dev/zero of=swapfile bs=1M count=1000
15 | mkswap swapfile
16 | swapon swapfile
17 | chmod 600 swapfile
18 | free -m
19 | ```
20 |
21 | Boost network performance
22 |
23 | ```
24 | sudo sysctl -w net.core.rmem_max=26214400
25 | sudo sysctl -w net.core.rmem_default=26214400
26 | ```
27 |
28 | Install python
29 |
30 | ```
31 | sudo apt update && sudo apt install python3 python3-pip screen
32 | ```
33 |
34 | Install caddy
35 |
36 | ```
37 | sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
38 | curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
39 | curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
40 | sudo apt update
41 | sudo apt install caddy
42 | ```
43 |
44 | Create Caddyfile
45 |
46 | ```
47 | xvpn-username.dashroshan.com {
48 | reverse_proxy localhost:5000
49 | }
50 | ```
51 |
52 | Reload caddy
53 |
54 | ```
55 | sudo caddy reload
56 | ```
57 |
58 | Setup desired vpn service
59 |
60 | > OpenVPN
61 |
62 | ```
63 | wget https://git.io/vpn -O openvpn-install.sh
64 | sudo chmod +x openvpn-install.sh
65 | sudo bash openvpn-install.sh
66 | ```
67 |
68 | > Wireguard
69 |
70 | ```
71 | wget https://git.io/wireguard -O wireguard-install.sh
72 | sudo chmod +x wireguard-install.sh
73 | sudo bash wireguard-install.sh
74 | ```
75 |
76 | Setup this admin portal
77 |
78 | ```
79 | git clone https://github.com/dashroshan/openvpn-wireguard-admin ov
80 | cd ov
81 | sudo python3 -m pip install -r requirements.txt
82 | sudo nano config.py
83 | ```
84 |
85 | Fill config.py with below content and uncomment desired vpn
86 |
87 | ```py
88 | # import openvpn as vpn
89 | # import wireguard as vpn
90 |
91 | creds = {
92 | "username": "roshan",
93 | "password": "dash",
94 | }
95 | ```
96 |
97 | If using wireguard create configWireguard.py with
98 |
99 | ```py
100 | wireGuardBlockAds = False
101 | ```
102 |
103 | Start portal in screen session
104 |
105 | ```
106 | screen -S ov
107 | sudo python3 main.py
108 | ```
109 |
110 | `Ctrl+A+D` to deattach screen session and `screen -r ov` to reattach. `screen -ls` can be used to list screen session, and `screen -r ov -X quit` can be used to delete the session.
111 |
--------------------------------------------------------------------------------
/main.py:
--------------------------------------------------------------------------------
1 | from flask import *
2 | import os
3 | import psutil
4 | from config import creds, vpn
5 | from hashlib import sha256
6 | import logging
7 |
8 | username = creds["username"]
9 | password = creds["password"]
10 |
11 |
12 | log = logging.getLogger("werkzeug")
13 | log.setLevel(logging.ERROR)
14 |
15 | app = Flask(
16 | f"{vpn.vpnName} Admin",
17 | static_folder=os.path.abspath("frontend/build/static"),
18 | template_folder=os.path.abspath("frontend/build"),
19 | )
20 |
21 | app.logger.disabled = True
22 | log.disabled = True
23 |
24 |
25 | def isAdmin(reqArgs):
26 | adminUserName = reqArgs.get("username")
27 | adminPassWord = reqArgs.get("password")
28 |
29 | hashedInput = sha256(adminPassWord.encode('utf-8')).hexdigest()
30 |
31 | return adminUserName == username and hashedInput == password
32 |
33 |
34 | @app.route("/")
35 | def homePage():
36 | return render_template("index.html")
37 |
38 |
39 | @app.route("/type")
40 | def vpnType():
41 | return {"type": vpn.vpnName}
42 |
43 |
44 | @app.route("/login")
45 | def loginCheck():
46 | return {
47 | "success": isAdmin(request.args),
48 | "memory": max(
49 | (psutil.swap_memory().used + psutil.virtual_memory().used)
50 | / (psutil.swap_memory().total + psutil.virtual_memory().total)
51 | * 100,
52 | 5,
53 | ),
54 | "cpu": max(psutil.cpu_percent(), 5),
55 | }
56 |
57 |
58 | @app.route("/list")
59 | def listUsers():
60 | if isAdmin(request.args):
61 | return vpn.listUsers()
62 | else:
63 | return []
64 |
65 |
66 | @app.route("/create/| Actions | 178 |User | 179 |
|---|---|
| 185 | 186 | 187 | 188 | 195 | | 196 |{e} | 197 |