-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwg-split
More file actions
executable file
·45 lines (34 loc) · 824 Bytes
/
wg-split
File metadata and controls
executable file
·45 lines (34 loc) · 824 Bytes
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
#!/usr/bin/env bash
#
# Creates a split tunnel for packets destined to Mullvad's SOCKS5 proxy.
# Useful for tunneling the traffic of specific applications.
die() {
echo "[-] Error: $1" >&2
exit 1
}
info() {
echo "[+] $1"
}
validate_config() {
[ -f "$1" ] || die "The config file $1 does not exist"
}
split_config() {
INPUT_FILE="$1"
CODE="$(basename ""${INPUT_FILE%.conf}"")"
DNS="$(grep DNS ""$INPUT_FILE"" | cut -c 7-)"
OUTPUT_FILE="split-$CODE.conf"
info "Creating split tunnel for $CODE at $OUTPUT_FILE"
cat "$INPUT_FILE" \
| sed -E "s#AllowedIPs.*#AllowedIPs = 10.0.0.0/8, $DNS/32#" \
> "$OUTPUT_FILE"
}
### Main ###
umask 077
if [ $# -eq 0 ]; then
info "Usage: wg-split <Tunnel config> [Tunnel config]..."
exit
fi
for config in $@; do
validate_config "$config"
split_config "$config"
done