Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Commit a0c88a2

Browse files
author
yacht7
committed
Update Alpine to 3.11.6 and use dig for resolution instead of nslookup
1 parent fc57766 commit a0c88a2

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

Dockerfile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
FROM alpine:3.10
1+
FROM alpine:3.11.6
22

3-
LABEL maintainer="yacht7"
3+
LABEL maintainer="yacht7@protonmail.com"
44

55
ENV KILL_SWITCH=on
66

77
RUN \
88
echo '@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories && \
99
apk add --no-cache \
10+
bind-tools \
1011
openvpn \
1112
shadowsocks-libev@testing \
12-
tinyproxy && \
13+
tinyproxy
14+
15+
RUN \
1316
mkdir -p /data/vpn /var/log/openvpn && \
1417
addgroup -S shadowsocks && \
1518
adduser -S -G shadowsocks -g "shadowsocks user" -H -h /dev/null shadowsocks
16-
COPY data/ /data
17-
RUN chmod 500 /data/entry.sh
1819

19-
HEALTHCHECK CMD ping -qc 3 1.1.1.1
20+
COPY data/ /data
2021

21-
ENTRYPOINT ["/data/entry.sh"]
22+
ENTRYPOINT ["/data/entry.sh"]

data/entry.sh

100644100755
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ echo -e "\n---- OpenVPN Configuration ----"
4444

4545
# Create a new configuration file to modify so the original is left untouched.
4646
config_file_modified=${config_file_original}.modified
47-
cp $config_file_original $config_file_modified
4847

4948
# These configuration file changes are required by Alpine.
50-
echo "Making required changes to the configuration file."
49+
echo "Creating $config_file_modified and making required changes to that file."
50+
cp $config_file_original $config_file_modified
51+
5152
sed -i \
5253
-e '/up /c up \/etc\/openvpn\/up.sh' \
5354
-e '/down /c down \/etc\/openvpn\/down.sh' \
@@ -79,8 +80,7 @@ if [ $KILL_SWITCH = "on" ]; then
7980
echo "Creating VPN kill switch and local routes."
8081

8182
echo "Allowing established and related connections..."
82-
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
83-
iptables -A OUTPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
83+
iptables -A INPUT -m conntrack --ctstate ESTABLISHED -j ACCEPT
8484

8585
echo "Allowing loopback connections..."
8686
iptables -A INPUT -i lo -j ACCEPT
@@ -110,7 +110,7 @@ if [ $KILL_SWITCH = "on" ]; then
110110
domain=$(echo "$line" | cut -d " " -f 1)
111111
port=$(echo "$line" | cut -d " " -f 2)
112112
proto=$(echo "$line" | cut -d " " -f 3 | cut -c1-3)
113-
for ip in $(nslookup $domain localhost | tail -n +4 | grep -Eo '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}' | sort | uniq); do
113+
for ip in $(dig -4 +short $domain); do
114114
echo " $domain (IP:$ip PORT:$port)"
115115
iptables -A OUTPUT -o eth0 -d $ip -p ${proto:-$remote_proto} --dport ${port:-$remote_port} -j ACCEPT
116116
done
@@ -142,8 +142,10 @@ else
142142
fi
143143

144144
if [ "$SHADOWSOCKS" = "on" ]; then
145+
# https://www.gnu.org/software/bash/manual/html_node/Command-Grouping.html
145146
{
146147
echo "[INFO] Running Shadowsocks"
148+
# Wait for VPN connection to be established
147149
while ! ping -c 1 1.1.1.1 > /dev/null 2>&1; do
148150
sleep 1
149151
done
@@ -159,11 +161,9 @@ if [ "$SHADOWSOCKS" = "on" ]; then
159161
fi
160162

161163
if [ "$TINYPROXY" = "on" ]; then
162-
# start list of commands to run Tinyproxy
163164
# https://www.gnu.org/software/bash/manual/html_node/Command-Grouping.html
164165
{
165166
echo "[INFO] Running Tinyproxy"
166-
# Wait for VPN connection to be established
167167
while ! ping -c 1 1.1.1.1 > /dev/null 2>&1; do
168168
sleep 1
169169
done
@@ -184,7 +184,7 @@ if [ "$TINYPROXY" = "on" ]; then
184184
fi
185185

186186
sleep 1
187-
tinyproxy -c /data/tinyproxy.conf &
187+
tinyproxy -c /data/tinyproxy.conf
188188
} &
189189
fi
190190

@@ -193,4 +193,4 @@ echo "[INFO] Running OpenVPN"
193193
openvpn --verb $vpn_log_level --auth-nocache --cd /data/vpn --config $config_file_modified &
194194

195195
openvpn_child=$!
196-
wait $openvpn_child
196+
wait $openvpn_child

0 commit comments

Comments
 (0)