This commit is contained in:
Shahrad Elahi 2023-09-27 05:30:23 +03:30
parent c69b0cb5b0
commit 4ff0187f97
6 changed files with 15 additions and 11 deletions

View File

@ -1,5 +1,5 @@
VirtualAddrNetwork 10.192.0.0/10
SOCKSPort 9055
ControlPort 9051
DNSPort 10.8.0.1:53530
TransPort 10.8.0.1:9040
DNSPort 53530
TransPort 9040

View File

@ -3,13 +3,13 @@ services:
wireadmin:
environment:
# ⚠️ Required:
# Change this to your host's public address
# Make sure change this to your host's public address
- WG_HOST=raspberrypi.local
image: shahradel/wireadmin
container_name: wireadmin
volumes:
- ~/.wg-data:/data
- redis-data:/data
ports:
- "51820:51820/udp"
- "3000:3000/tcp"
@ -21,3 +21,6 @@ services:
- net.ipv4.ip_forward=1
- net.ipv4.conf.all.src_valid_mark=1
volumes:
redis-data:
driver: local

View File

@ -1,4 +1,4 @@
#!/usr/bin/dumb-init /bin/sh
#!/usr/bin/dumb-init /bin/bash
set -e
# Note above that we run dumb-init as PID 1 in order to reap zombie processes
@ -24,6 +24,6 @@ screen -L -Logfile /var/vlogs/tor -dmS tor bash -c "tor"
screen -L -Logfile /var/vlogs/redis -dmS redis bash -c "redis-server --port 6479 --daemonize no --dir /data --appendonly yes"
# After 5 seconds, export the database to the WireGuard config file
screen -dm bash -c "sleep 5; curl -s -o /dev/null http://127.0.0.1:3000/api/wireguard/regen"
bash -c "sleep 5; curl -s -o /dev/null http://127.0.0.1:3000/api/wireguard/regen"&
exec "$@"

View File

@ -43,6 +43,7 @@ export async function getServerIP(): Promise<string> {
}
export async function getPeerConf(params: GenPeerConParams): Promise<string> {
const serverAddress = params.serverAddress || await getServerIP()
const lines = [
'# Autogenerated by WireGuard UI (WireAdmin)',
'[Interface]',
@ -55,7 +56,7 @@ export async function getPeerConf(params: GenPeerConParams): Promise<string> {
`${params.preSharedKey ? `PresharedKey = ${params.preSharedKey}` : 'OMIT'}`,
`AllowedIPs = 0.0.0.0/0, ::/0`,
`PersistentKeepalive = ${params.persistentKeepalive}`,
`Endpoint = ${params.serverAddress || process.env.NEXT_PUBLIC_WG_HOST}:${params.port}`,
`Endpoint = ${serverAddress}:${params.port}`,
]
return lines
.filter((l) => l !== 'OMIT')

View File

@ -479,9 +479,9 @@ async function makeWgIptables(s: WgServer): Promise<{ up: string, down: string }
const up = dynaJoin([
`iptables -A INPUT -m state --state ESTABLISHED -j ACCEPT`,
`iptables -A INPUT -i ${wgInet} -s ${source} -m state --state NEW -j ACCEPT`,
`iptables -t nat -A PREROUTING -i ${wgInet} -p udp -s ${source} --dport 53 -j DNAT --to-destination 10.8.0.1:53530`,
`iptables -t nat -A PREROUTING -i ${wgInet} -p tcp -s ${source} -j DNAT --to-destination 10.8.0.1:9040`,
`iptables -t nat -A PREROUTING -i ${wgInet} -p udp -s ${source} -j DNAT --to-destination 10.8.0.1:9040`,
`iptables -t nat -A PREROUTING -i ${wgInet} -p udp -s ${source} --dport 53 -j DNAT --to-destination 127.0.0.1:53530`,
`iptables -t nat -A PREROUTING -i ${wgInet} -p tcp -s ${source} -j DNAT --to-destination 127.0.0.1:9040`,
`iptables -t nat -A PREROUTING -i ${wgInet} -p udp -s ${source} -j DNAT --to-destination 127.0.0.1:9040`,
`iptables -t nat -A OUTPUT -o lo -j RETURN`,
`iptables -A OUTPUT -m conntrack --ctstate INVALID -j DROP`,
`iptables -A OUTPUT -m state --state INVALID -j DROP`,

View File

@ -10,7 +10,7 @@ const nextConfig = {
reactStrictMode: true,
transpilePackages: [],
env: publicENV({
NEXT_PUBLIC_WG_HOST: process.env.WG_HOST
NEXT_PUBLIC_WG_HOST: process.env?.WG_HOST
})
}