Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit 387962a

Browse files
author
Concision
committed
Migrated SOCKS server to Dante
Signed-off-by: Concision <contact@concision.me>
1 parent cb8185e commit 387962a

5 files changed

Lines changed: 79 additions & 46 deletions

File tree

.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
### Dockerignore whitelist
2+
# Ignore everything
3+
*
4+
# Whitelist
5+
!config
6+
!docker-entrypoint.sh
7+
!docker-healthcheck.sh

Dockerfile

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,31 @@
1+
### Sanitize Windows \r\n formatting for Unix scripts
2+
FROM alpine as sanitized
3+
4+
## Dependencies
5+
RUN apk --no-cache add dos2unix
6+
7+
## Scripts
8+
COPY docker-entrypoint.sh docker-healthcheck.sh /scripts/
9+
# sanitize scripts
10+
RUN dos2unix /scripts/*.sh && \
11+
chmod +x /scripts/*.sh
12+
13+
## Danted Configuration
14+
COPY config/danted.conf /etc/danted.conf
15+
# sanitize configuration
16+
RUN dos2unix /etc/danted.conf
17+
18+
119
### Image Configuration
2-
FROM ubuntu:latest
20+
FROM ubuntu
321

422
# expose SOCKS server port
523
EXPOSE 1080/tcp
624

7-
8-
### Linux Dependencies
9-
# install Windscribe and OpenSSH server
25+
## Linux Dependencies
26+
# install Windscribe and Dante server
1027
RUN \
11-
# obtain caches
28+
# update package listings
1229
apt-get update && \
1330
# install dependencies
1431
apt-get install -y \
@@ -20,40 +37,38 @@ RUN \
2037
apt-utils debconf-utils dialog \
2138
# required for Windscribe
2239
iptables \
23-
# sanitize Windows \r\n formatting
24-
dos2unix \
25-
# openssh to create a SOCKS server
26-
openssh-server \
2740
# IP healthcheck
2841
curl \
29-
&& \
42+
# danted proxy server
43+
dante-server && \
3044
# fix resolveconf dependency configuration (as per https://stackoverflow.com/a/51507868)
3145
echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections && \
3246
echo "resolvconf resolvconf/linkify-resolvconf boolean false" | debconf-set-selections && \
3347
# add Windscribe signing key
3448
apt-key adv --keyserver keyserver.ubuntu.com --recv-key FDC247B7 && \
3549
# add Windscribe repository
3650
echo 'deb https://repo.windscribe.com/ubuntu zesty main' | tee /etc/apt/sources.list.d/windscribe-repo.list && \
37-
# install Windscribe
51+
# update repository
3852
apt-get update && \
53+
# install Windscribe
3954
apt-get install -y windscribe-cli && \
40-
# clean cache
55+
# remove Windscribe repository key
56+
apt-key del FDC247B7 && \
57+
# cleanup apt-get lists
4158
apt-get clean && \
42-
rm -rf /var/lib/apt/lists/*
43-
44-
# disable SSH shell
45-
RUN chsh --shell /bin/false
46-
47-
48-
### Add Docker scripts
49-
# add entrypoint
50-
COPY docker-entrypoint.sh docker-healthcheck.sh /
51-
52-
# mark as executable
53-
RUN dos2unix /docker-*.sh && \
54-
chmod +x /docker-*.sh
59+
rm -rf /var/lib/apt/lists/* && \
60+
# clear logs
61+
rm -rf /var/logs/*
5562

56-
ENTRYPOINT ["/docker-entrypoint.sh"]
63+
## Add Docker scripts and configuration
64+
# add scripts
65+
COPY --from=sanitized /scripts /
66+
# add dante server configuration
67+
COPY --from=sanitized /etc/danted.conf /etc/danted.conf
5768

69+
## Configure Image
70+
# default command
71+
CMD ["/docker-entrypoint.sh"]
72+
# healthcheck
5873
HEALTHCHECK --interval=120s --timeout=30s --start-period=15s --retries=3 \
5974
CMD "/docker-healthcheck.sh"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@ To deploy it, the following command can be executed:
7070
```bash
7171
./deploy-container.sh
7272
```
73-
> Note: Running the container interactively may break Windscribe authentication
73+
> Note: Running the container interactively may break Windscribe authentication

config/danted.conf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# logging
2+
debug: 0
3+
logoutput: stderr
4+
5+
# networking interfaces
6+
internal: 0.0.0.0 port = 1080
7+
external: tun0
8+
9+
# users
10+
user.privileged: root
11+
user.unprivileged: nobody
12+
13+
socksmethod: username none
14+
clientmethod: none
15+
16+
17+
# routing
18+
19+
client pass {
20+
from: 0.0.0.0/0 to: 0.0.0.0/0
21+
log: connect disconnect error
22+
}
23+
24+
socks pass {
25+
from: 0.0.0.0/0 to: 0.0.0.0/0
26+
log: connect disconnect error
27+
}

docker-entrypoint.sh

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,14 @@ prefixWith() {
4040
*"${NL}"*) prefixWith "[WINDSCRIBE]" echo "Windscribe location cannot contain new lines; ensure that the environment variable \$WINDSCRIBE_LOCATION is set properly"
4141
exit 1;;
4242
esac
43+
4344
# iptable support checks
4445
iptables -vnL > /dev/null 2>&1 || {
4546
prefixWith "[IPTABLES]" echo "Ensure cap_add is set to NET_ADMIN"
4647
exit 1
4748
}
4849

4950

50-
### Create SSH identity and start OpenSSH server
51-
# manage SSH identity
52-
prefixWith "[SSH]" echo "Creating SSH key"
53-
# generate SSH key
54-
prefixWith "[SSH]" ssh-keygen -N "" -f "/root/.ssh/id_rsa" <<< y
55-
# allow self-connecting with SSH
56-
prefixWith "[SSH]" cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys
57-
# start SSH server
58-
prefixWith "[SSH]" echo "Starting OpenSSH server"
59-
prefixWith "[SSH]" service ssh start
60-
61-
6251
### Create TUN device for Windscribe
6352
# create TUN device
6453
prefixWith "[OPENVPN]" echo "Creating OpenVPN TUN device"
@@ -96,12 +85,7 @@ prefixWith() {
9685
prefixWith "[WINDSCRIBE]" windscribe firewall on
9786

9887

99-
### Binds SOCKS server using OpenSSH
100-
while true; do
101-
prefixWith "[SSH]" echo "Creating OpenSSH SOCKS server"
102-
prefixWith "[SSH]" ssh -4 -oStrictHostKeyChecking=accept-new -D 0.0.0.0:1080 -N root@127.0.0.1
103-
prefixWith "[SSH]" echo "SOCKS server died, restarting"
104-
sleep 1
105-
done
88+
### Binds SOCKS server using Dante
89+
prefixWith "[DANTE]" danted
10690

10791
} 2>&1 1>&3 3>&- | { while read -r line; do echo "$(date '+%Y-%m-%d %H:%M:%S') ERR $line"; done } } 3>&1 1>&2 | { while read -r line; do echo "$(date '+%Y-%m-%d %H:%M:%S') OUT $line"; done }

0 commit comments

Comments
 (0)