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 VirtualAddrNetwork 10.192.0.0/10
SOCKSPort 9055 SOCKSPort 9055
ControlPort 9051 ControlPort 9051
DNSPort 10.8.0.1:53530 DNSPort 53530
TransPort 10.8.0.1:9040 TransPort 9040

View File

@ -3,13 +3,13 @@ services:
wireadmin: wireadmin:
environment: environment:
# ⚠️ Required: # ⚠️ Required:
# Change this to your host's public address # Make sure change this to your host's public address
- WG_HOST=raspberrypi.local - WG_HOST=raspberrypi.local
image: shahradel/wireadmin image: shahradel/wireadmin
container_name: wireadmin container_name: wireadmin
volumes: volumes:
- ~/.wg-data:/data - redis-data:/data
ports: ports:
- "51820:51820/udp" - "51820:51820/udp"
- "3000:3000/tcp" - "3000:3000/tcp"
@ -21,3 +21,6 @@ services:
- net.ipv4.ip_forward=1 - net.ipv4.ip_forward=1
- net.ipv4.conf.all.src_valid_mark=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 set -e
# Note above that we run dumb-init as PID 1 in order to reap zombie processes # 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" 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 # 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 "$@" exec "$@"

View File

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

View File

@ -479,9 +479,9 @@ async function makeWgIptables(s: WgServer): Promise<{ up: string, down: string }
const up = dynaJoin([ const up = dynaJoin([
`iptables -A INPUT -m state --state ESTABLISHED -j ACCEPT`, `iptables -A INPUT -m state --state ESTABLISHED -j ACCEPT`,
`iptables -A INPUT -i ${wgInet} -s ${source} -m state --state NEW -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 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 10.8.0.1:9040`, `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 10.8.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 -t nat -A OUTPUT -o lo -j RETURN`,
`iptables -A OUTPUT -m conntrack --ctstate INVALID -j DROP`, `iptables -A OUTPUT -m conntrack --ctstate INVALID -j DROP`,
`iptables -A OUTPUT -m state --state INVALID -j DROP`, `iptables -A OUTPUT -m state --state INVALID -j DROP`,

View File

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