Compare commits

...

18 commits

Author SHA1 Message Date
heiye1024 16db3adb12
Merge 1c267b732b into a97a91b844 2024-09-19 14:36:02 +08:00
Donald Zou a97a91b844
Merge pull request #395 from donaldzou/fix-#391
Fixed issue where Preshared Key is not added when unrestricted peers
2024-09-19 14:31:41 +08:00
Donald Zou f1c577ab76 Fixed issue mentioned in #391 2024-09-19 14:21:38 +08:00
heiye1024 1c267b732b
Merge branch 'donaldzou:main' into main 2024-07-22 09:01:35 +08:00
heiye1024 c7c0b76beb
Merge pull request #7 from donaldzou/main
update
2022-02-07 10:33:35 +08:00
Aidan 9ad638733a fix docker 2022-01-24 17:23:37 +08:00
Aidan c9b9ef3c3f fix docker 2022-01-24 10:47:43 +08:00
root b3a5fd9c6c fix docker 2022-01-24 09:46:05 +08:00
heiye1024 80059d6950
Merge pull request #6 from donaldzou/main
update 3.03
2022-01-24 09:09:26 +08:00
heiye1024 f7603dff65
Create docker-compose.yaml 2022-01-22 16:07:09 +08:00
heiye1024 9d7f986343
Update Dockerfile 2022-01-22 16:06:19 +08:00
heiye1024 a8c589b22c
Merge pull request #5 from donaldzou/main
update to 3.0
2022-01-21 11:36:36 +08:00
heiye1024 205aaa9c62
Merge pull request #4 from donaldzou/main
update to 3.0
2022-01-19 09:25:26 +08:00
heiye1024 eed7a2ff22
合并Donaldzou/main的拉取请求#3
update
2022-01-15 10:24:05 +08:00
heiye1024 def837f0bc
Merge pull request #2 from donaldzou/main
Update Code
2021-12-25 17:28:11 +08:00
heiye1024 f6bc7f4a78
Merge pull request #1 from donaldzou/main
update
2021-12-23 11:37:02 +08:00
root daaa50fd9e add Dockerfile 2021-12-22 10:50:19 +08:00
root 602f0dbca3 add Dockerfile 2021-12-22 10:34:14 +08:00
3 changed files with 58 additions and 3 deletions

29
src/Dockerfile Executable file
View file

@ -0,0 +1,29 @@
FROM python:3.10.2-alpine3.15 as base
RUN apk --update-cache upgrade && apk add --no-cache gcc g++ libffi-dev jpeg-dev zlib-dev libjpeg wireguard-tools iptables ip6tables inotify-tools \
&& rm -rf /var/cache/apk/*
RUN mkdir -p /etc/wireguard/
# configure wireguard
RUN wg genkey | tee /etc/wireguard/privatekey | wg pubkey | tee /etc/wireguard/publick
RUN cd /etc/wireguard/ && echo "[Interface]" >> wg0.conf && echo -n "PrivateKey = " >> wg0.conf && cat privatekey >> wg0.conf \
&& echo "ListenPort = 51820" >> wg0.conf && echo "Address = 10.1.1.1/32" >> wg0.conf && chmod 700 wg0.conf
COPY requirements.txt /opt/wgdashboard/
RUN pip3 install -r /opt/wgdashboard/requirements.txt --no-cache-dir
FROM base
COPY . /opt/WGDashboard/src
WORKDIR /opt/WGDashboard/src
EXPOSE 10086
EXPOSE 51820/udp

View file

@ -693,8 +693,6 @@ class WireguardConfiguration:
return False, None
def allowAccessPeers(self, listOfPublicKeys):
# numOfAllowedPeers = 0
# numOfFailedToAllowPeers = 0
if not self.getStatus():
self.toggleConfiguration()
@ -705,7 +703,15 @@ class WireguardConfiguration:
% (self.Name, self.Name,), (p['id'],))
sqlUpdate("DELETE FROM '%s_restrict_access' WHERE id = ?"
% self.Name, (p['id'],))
subprocess.check_output(f"wg set {self.Name} peer {p['id']} allowed-ips {p['allowed_ip']}",
presharedKeyExist = len(p['preshared_key']) > 0
rd = random.Random()
uid = uuid.UUID(int=rd.getrandbits(128), version=4)
if presharedKeyExist:
with open(f"{uid}", "w+") as f:
f.write(p['preshared_key'])
subprocess.check_output(f"wg set {self.Name} peer {p['id']} allowed-ips {p['allowed_ip']}{f' preshared-key {uid}' if presharedKeyExist else ''}",
shell=True, stderr=subprocess.STDOUT)
else:
return ResponseObject(False, "Failed to allow access of peer " + i)

20
src/docker-compose.yaml Normal file
View file

@ -0,0 +1,20 @@
version: "3.7"
services:
web:
build:
context: .
container_name: WGDashboard
cap_add:
- NET_ADMIN
- SYS_MODULE
command: python dashboard.py
#command: gunicorn --bind 0.0.0.0:10086 dashboard:app
restart: unless-stopped
volumes:
- ./dashboard.py:/opt/WGDashboard/src/dashboard.py:rw
ports:
- 10086:10086
- 51820:51820/udp
sysctls:
- net.ipv4.conf.all.src_valid_mark=1