-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdanted_config.sh
More file actions
60 lines (48 loc) · 1.33 KB
/
Copy pathdanted_config.sh
File metadata and controls
60 lines (48 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
set -e
# Use INSTALL_DIR from environment, error if not set
if [ -z "$INSTALL_DIR" ]; then
echo "[ERROR] INSTALL_DIR is not set. Please run this script via install_warp_manager.sh."
exit 1
fi
# Source config from INSTALL_DIR
CONFIG_FILE="$INSTALL_DIR/warp_manager.conf"
if [ -f "$CONFIG_FILE" ]; then
source "$CONFIG_FILE"
fi
# Number of WARP namespaces/proxies
COUNT=$(find "$INSTALL_DIR/warp-profiles" -mindepth 1 -maxdepth 1 -type d | wc -l)
# Config directory
CONFIG_DIR="/etc/danted-warp"
# Ensure config directory exists
if [ ! -d "$CONFIG_DIR" ]; then
echo "Creating config directory: $CONFIG_DIR"
sudo mkdir -p "$CONFIG_DIR"
sudo chmod 755 "$CONFIG_DIR"
fi
# Use BASE_PORT from config if set, otherwise prompt
if [ -z "$BASE_PORT" ]; then
read -p "Enter starting port for SOCKS proxies [default: 1080]: " BASE_PORT
BASE_PORT=${BASE_PORT:-1080}
fi
for i in $(seq 1 "$COUNT"); do
NS="warpns$i"
WG="wgcf-profile"
PORT=$((BASE_PORT + i - 1))
CONF="$CONFIG_DIR/$NS.conf"
LOG="stderr"
sudo tee "$CONF" > /dev/null <<EOF
logoutput: $LOG
internal: 10.10.$i.2 port = $PORT
external: $WG
socksmethod: none
client pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
}
socks pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
protocol: tcp udp
}
EOF
echo "Generated: $CONF (listening on port $PORT, namespace $NS)"
done