1
0

feat:更新并调整wireguard-easy

This commit is contained in:
okxlin
2024-11-12 01:33:26 +08:00
parent da9a3b3964
commit ce3fce2e56
17 changed files with 540 additions and 306 deletions

View File

@@ -1,6 +1,11 @@
CONTAINER_NAME="wireguard-easy"
DATA_PATH="./data"
HOST_ADDRESS="172.17.0.1"
PANEL_APP_PORT_HTTP="40074"
WEBUI_PWD="password"
WIREGUARD_PORT="51820"
PANEL_APP_PORT_HTTP=40074
WG_ALLOWED_IPS="10.0.8.0/24"
WG_DEFAULT_ADDRESS="10.8.0.x"
WG_DEFAULT_DNS="119.29.29.29,1.1.1.1"
WG_MTU=1420
WG_PERSISTENT_KEEPALIVE=25
WIREGUARD_PORT=51820
PASSWORD_HASH="$$2a$$12$$0AL3hGeedv8fOfsNtfZY5OO3mMvBqlnZA8QmeBGfWPAQEoZ7LZ/7a"

View File

@@ -1,42 +1,74 @@
additionalProperties:
formFields:
- default: 40074
edit: true
envKey: PANEL_APP_PORT_HTTP
labelEn: WebUI Port
labelZh: 网页端口
required: true
rule: paramPort
type: number
- default: 51820
edit: true
envKey: WIREGUARD_PORT
labelEn: Wireguard port
labelZh: Wireguard端口
required: true
rule: paramPort
type: number
- default: ./data
edit: true
envKey: DATA_PATH
labelEn: Data folder path
labelZh: 数据文件夹路径
required: true
type: text
- default: "password"
edit: true
envKey: WEBUI_PWD
labelEn: Webui password
labelZh: 网页密码
random: false
required: true
rule: paramComplexity
type: password
- default: 172.17.0.1
edit: true
envKey: HOST_ADDRESS
labelEn: Local IP address (must change item)
labelZh: 本机IP地址(必改项)
required: true
rule: paramCommon
type: text
formFields:
- default: "40074"
edit: true
envKey: PANEL_APP_PORT_HTTP
labelEn: WebUI Port
labelZh: 网页端口
required: true
rule: paramPort
type: number
- default: "51820"
edit: true
envKey: WIREGUARD_PORT
labelEn: Wireguard port
labelZh: Wireguard 端口
required: true
rule: paramPort
type: number
- default: "./data"
edit: true
envKey: DATA_PATH
labelEn: Data folder path
labelZh: 数据文件夹路径
required: true
type: text
- default: "$$2a$$12$$0AL3hGeedv8fOfsNtfZY5OO3mMvBqlnZA8QmeBGfWPAQEoZ7LZ/7a"
edit: true
envKey: PASSWORD_HASH
labelEn: Webui password hash (Note to check the documentation for instructions, the default is `PAssw00rd`)
labelZh: 网页密码 hash (注意查看说明文档,默认为`PAssw00rd`)
required: true
type: password
- default: "172.17.0.1"
edit: true
envKey: HOST_ADDRESS
labelEn: Host address (must change item)
labelZh: 本机地址(必改项)
required: true
type: text
- default: "10.8.0.x"
edit: true
envKey: WG_DEFAULT_ADDRESS
labelEn: Default Wireguard Segment
labelZh: 默认 Wireguard 网段
required: true
type: text
- default: "119.29.29.29,1.1.1.1"
edit: true
envKey: WG_DEFAULT_DNS
labelEn: Default Wireguard DNS
labelZh: 默认 Wireguard DNS
required: true
type: text
- default: "1420"
edit: true
envKey: WG_MTU
labelEn: Wireguard MTU
labelZh: Wireguard MTU
required: true
type: number
- default: "10.0.8.0/24"
edit: true
envKey: WG_ALLOWED_IPS
labelEn: Wireguard Allowed IPs
labelZh: Wireguard 允许的 IP 段
required: true
type: text
- default: "25"
edit: true
envKey: WG_PERSISTENT_KEEPALIVE
labelEn: Wireguard Persistent Keepalive
labelZh: Wireguard 保活间隔
required: true
type: number

View File

@@ -6,32 +6,29 @@ services:
- 1panel-network
environment:
- WG_HOST=${HOST_ADDRESS}
- PASSWORD=${WEBUI_PWD}
- WG_PORT=${WIREGUARD_PORT}
# Optional:
# - WG_DEFAULT_ADDRESS=10.8.0.x
# - WG_DEFAULT_DNS=1.1.1.1
# - WG_MTU=1420
# - WG_ALLOWED_IPS=192.168.15.0/24, 10.0.1.0/24
# - WG_PRE_UP=echo "Pre Up" > /etc/wireguard/pre-up.txt
# - WG_POST_UP=echo "Post Up" > /etc/wireguard/post-up.txt
# - WG_PRE_DOWN=echo "Pre Down" > /etc/wireguard/pre-down.txt
# - WG_POST_DOWN=echo "Post Down" > /etc/wireguard/post-down.txt
- PORT=${PANEL_APP_PORT_HTTP}
- WG_DEFAULT_ADDRESS=${WG_DEFAULT_ADDRESS}
- WG_DEFAULT_DNS=${WG_DEFAULT_DNS}
- WG_MTU=${WG_MTU}
- WG_ALLOWED_IPS=${WG_ALLOWED_IPS}
- WG_PERSISTENT_KEEPALIVE=${WG_PERSISTENT_KEEPALIVE}
- PASSWORD_HASH=${PASSWORD_HASH}
volumes:
- ${DATA_PATH}:/etc/wireguard
ports:
- "${WIREGUARD_PORT}:${WIREGUARD_PORT}/udp"
- "${PANEL_APP_PORT_HTTP}:51821/tcp"
- "${PANEL_APP_PORT_HTTP}:${PANEL_APP_PORT_HTTP}/tcp"
cap_add:
- NET_ADMIN
- SYS_MODULE
sysctls:
- net.ipv4.ip_forward=1
- net.ipv4.conf.all.src_valid_mark=1
image: weejewel/wg-easy:latest
labels:
image: "ghcr.io/wg-easy/wg-easy:latest"
labels:
createdBy: "Apps"
networks:
1panel-network:
networks:
1panel-network:
external: true

View File

@@ -0,0 +1,70 @@
#!/bin/bash
# 检查 .env 文件是否存在
if [[ -f ./.env ]]; then
# 如果 .env 文件中有 WEBUI_PWD 的设置,删除该行
if grep -q 'WEBUI_PWD' ./.env; then
sed -i '/WEBUI_PWD/d' ./.env
echo "已移除 .env 文件中的 WEBUI_PWD 参数"
fi
# 检查并添加 WG_ALLOWED_IPS 参数
if ! grep -q 'WG_ALLOWED_IPS' ./.env; then
echo 'WG_ALLOWED_IPS="10.0.8.0/24"' >> ./.env
echo "已添加 WG_ALLOWED_IPS=10.0.8.0/24"
else
echo "WG_ALLOWED_IPS 参数已存在"
fi
# 检查并添加 WG_DEFAULT_ADDRESS 参数
if ! grep -q 'WG_DEFAULT_ADDRESS' ./.env; then
echo 'WG_DEFAULT_ADDRESS="10.8.0.x"' >> ./.env
echo "已添加 WG_DEFAULT_ADDRESS=10.8.0.x"
else
echo "WG_DEFAULT_ADDRESS 参数已存在"
fi
# 检查并添加 WG_DEFAULT_DNS 参数
if ! grep -q 'WG_DEFAULT_DNS' ./.env; then
echo 'WG_DEFAULT_DNS="119.29.29.29,1.1.1.1"' >> ./.env
echo "已添加 WG_DEFAULT_DNS=119.29.29.29,1.1.1.1"
else
echo "WG_DEFAULT_DNS 参数已存在"
fi
# 检查并添加 WG_MTU 参数
if ! grep -q 'WG_MTU' ./.env; then
echo 'WG_MTU=1420' >> ./.env
echo "已添加 WG_MTU=1420"
else
echo "WG_MTU 参数已存在"
fi
# 检查并添加 WG_PERSISTENT_KEEPALIVE 参数
if ! grep -q 'WG_PERSISTENT_KEEPALIVE' ./.env; then
echo 'WG_PERSISTENT_KEEPALIVE=25' >> ./.env
echo "已添加 WG_PERSISTENT_KEEPALIVE=25"
else
echo "WG_PERSISTENT_KEEPALIVE 参数已存在"
fi
# 检查并添加 WIREGUARD_PORT 参数
if ! grep -q 'WIREGUARD_PORT' ./.env; then
echo 'WIREGUARD_PORT=51820' >> ./.env
echo "已添加 WIREGUARD_PORT=51820"
else
echo "WIREGUARD_PORT 参数已存在"
fi
# 检查并添加 PASSWORD_HASH 参数
if ! grep -q 'PASSWORD_HASH' ./.env; then
echo 'PASSWORD_HASH="$$2a$$12$$0AL3hGeedv8fOfsNtfZY5OO3mMvBqlnZA8QmeBGfWPAQEoZ7LZ/7a"' >> ./.env
echo '已添加 PASSWORD_HASH="$$2a$$12$$0AL3hGeedv8fOfsNtfZY5OO3mMvBqlnZA8QmeBGfWPAQEoZ7LZ/7a"'
else
echo "PASSWORD_HASH 参数已存在"
fi
else
echo ".env 文件不存在"
fi