Skip to content

Commit ad6fefc

Browse files
authored
Merge pull request #7 from SloCompTech/develop
Improved IPv6 support & finalized client mode support
2 parents 00e1d13 + 229d223 commit ad6fefc

File tree

13 files changed

+70
-20
lines changed

13 files changed

+70
-20
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
### 2.0.3 - Improved IPv6 support & finalized client mode support
4+
5+
- Added some IPv6 settings to examples
6+
- Sleep interval on crash
7+
- Outsourced server specific config to `system-server.conf`
8+
- Added parameter `MODE` so you can choose **client** mode instead of server (to not include server specific options)
9+
310
### 2.0.2 - Added multi-instance support
411

512
- Added `TUNNEL_INTERFACE` to set interface name (in case of multiple containers)

CONTRIBUTING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ Sections:
4242
up # After interface is up
4343
tls-verify # Check certificate
4444
system.conf # System OpenVPN config file (do not edit, unless instructed)
45-
include-conf.conf # File that includes all configuration files (automatically generated)
45+
system-server.conf # System OpenCPN server specific file (do not edit, unless instructed)
46+
system-client.conf # System OpenCPN client specific file (do not edit, unless instructed)
47+
dynamic.conf # File that links all config files together (automatically generated)
4648
pki
4749
ca.crt # CA certificate
4850
certs by serial # Certs by Serial ID

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ services:
6767
|**Parameter**|**Function**|
6868
|:-----------:|:----------:|
6969
|`-e FAIL_MODE=hard`|Restart whole container on error|
70+
|`-e MODE=client`|Set docker mode (valid values: *empty*,server,client; default: server), set to client in case you use container as client|
7071
|`-e PUID=1000`|for UserID - see below for explanation|
7172
|`-e PGID=1000`|for GroupID - see below for explanation|
7273
|`-e PERSISTENT_INTERFACE=true`|Enable persistent TUN interface|
@@ -147,7 +148,14 @@ For more infromation see:
147148

148149
### Client mode
149150

150-
Just put *.ovpn* file in `/config/openvpn/config` and restart container.
151+
1. Run container to get config structure `docker run -it --rm -v PATH:/config slocomptech/openvpn`.
152+
2. Make sure you **don't** have following options specified in your *.ovpn* file
153+
- dev
154+
- user
155+
- group
156+
- anything that is already specified in *system.conf*
157+
3. Put *.ovpn* file in `config/openvpn/config` in your volume.
158+
4. Start conatiner with `-e MODE=client`.
151159

152160
## Troubleshooting
153161

root/defaults/example/config/basic_nat_ipv6/client/client.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
client
1010
dev tun0
1111
proto $PROTO
12+
#proto udp6 # Uncomment this to use IPv6 to connect to server
1213
nobind
1314

1415
# Remote info

root/defaults/example/config/basic_nat_ipv6/config/server.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
# Basic info
99
proto $PROTO
10+
#proto udp6 # Uncomment this so server is accessible over IPv6
1011
port $PORT
1112

1213
# Network info (local VPN network)

root/defaults/example/config/basic_nat_wlp_ipv6/client/client.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
client
1010
dev tun0
1111
proto $PROTO
12+
#proto udp6 # Uncomment this to use IPv6 to connect to server
1213
nobind
1314

1415
# Remote info

root/defaults/example/config/basic_nat_wlp_ipv6/config/server.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
# Basic info
99
proto $PROTO
10+
#proto udp6 # Uncomment this so server is accessible over IPv6
1011
port $PORT
1112

1213
# Network info (local VPN network)

root/defaults/example/config/basic_routed_ipv6/client/client.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
client
1010
dev tun0
1111
proto $PROTO
12+
#proto udp6 # Uncomment this to use IPv6 to connect to server
1213
nobind
1314

1415
# Remote info

root/defaults/example/config/basic_routed_ipv6/config/server.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
# Basic info
99
proto $PROTO
10+
#proto udp6 # Uncomment this so server is accessible over IPv6
1011
port $PORT
1112

1213
# Network info (local VPN network)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#
2+
# System OpenVPN config file - server specific
3+
#
4+
# @see https://community.openvpn.net/openvpn/wiki/Openvpn24ManPage
5+
#
6+
# DO NOT EDIT THIS FILE, if you are unsure what to do,
7+
# place your config file in openvpn directory
8+
#
9+
10+
# Server hooks
11+
client-connect "/usr/local/bin/run_hooks client-connect"
12+
client-disconnect "/usr/local/bin/run_hooks client-disconnect"
13+
learn-address "/usr/local/bin/run_hooks learn-address"
14+
tls-verify "/usr/local/bin/run_hooks tls-verify"
15+
16+
# Client config directory
17+
client-config-dir /config/openvpn/ccd
18+
19+
# Certificate revocation list
20+
crl-verify /config/pki/crl.pem
21+
22+
#
23+
# For username & password authentication uncomment bellow
24+
#
25+
#auth-user-pass-verify "/app/bin/run_hooks via-env"
26+
27+
# Username & password authentication optional
28+
#--auth-user-pass-optional

root/defaults/openvpn/system.conf

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,6 @@ route-pre-down "/usr/local/bin/run_hooks route-pre-down"
1919
up "/usr/local/bin/run_hooks up"
2020
down-pre
2121
down "/usr/local/bin/run_hooks down"
22-
client-connect "/usr/local/bin/run_hooks client-connect"
23-
client-disconnect "/usr/local/bin/run_hooks client-disconnect"
24-
learn-address "/usr/local/bin/run_hooks learn-address"
25-
tls-verify "/usr/local/bin/run_hooks tls-verify"
26-
27-
#
28-
# For username & password authentication uncomment bellow
29-
#
30-
#auth-user-pass-verify "/app/bin/run_hooks via-env"
31-
32-
# Username & password authentication optional
33-
#--auth-user-pass-optional
3422

3523
# Temporary dir
3624
tmp-dir /config/tmp
@@ -44,11 +32,5 @@ mute 100
4432
#status /log/status 30
4533
status-version 2
4634

47-
# Client config directory
48-
client-config-dir /config/openvpn/ccd
49-
50-
# Certificate revocation list
51-
crl-verify /config/pki/crl.pem
52-
5335
# Include configs
5436
config /config/openvpn/dynamic.conf

root/etc/cont-init.d/70-config.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
# Dynamic OpenVPN configs
55
#
66

7+
CLIENT_FILE=/config/openvpn/system-client.conf
78
DYNAMIC_FILE=/config/openvpn/dynamic.conf
9+
SERVER_FILE=/config/openvpn/system-server.conf
810

911
# Build link file
1012
echo "#" > $DYNAMIC_FILE
@@ -18,12 +20,25 @@ echo "# Interface" >> $DYNAMIC_FILE
1820
echo "dev $TUNNEL_INTERFACE" >> $DYNAMIC_FILE
1921
echo "" >> $DYNAMIC_FILE
2022

23+
# Include mode specific configuration
24+
if { [ -z "$MODE" ] || [ "$MODE" == "server" ]; } && [ -f "$SERVER_FILE" ]; then
25+
echo "# Server specific configuration" >> $DYNAMIC_FILE
26+
echo "config $SERVER_FILE" >> $DYNAMIC_FILE
27+
echo "" >> $DYNAMIC_FILE
28+
elif [ "$MODE" == "client" ] && [ -f "$CLIENT_FILE" ]; then
29+
echo "# Client specific configuration" >> $DYNAMIC_FILE
30+
echo "config $CLIENT_FILE" >> $DYNAMIC_FILE
31+
echo "" >> $DYNAMIC_FILE
32+
fi
33+
2134
# Include all configuration files
35+
echo "# Configuration files" >> $DYNAMIC_FILE
2236
for file in /config/openvpn/config/*
2337
do
2438
[ -e "$file" ] || continue
2539

2640
echo "config $file" >> $DYNAMIC_FILE
2741
done
42+
echo "" >> $DYNAMIC_FILE
2843

2944
chown $CONTAINER_USER:$CONTAINER_USER $DYNAMIC_FILE

root/etc/services.d/openvpn/finish

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@
66

77
if [ "$FAIL_MODE" == "hard" ]; then
88
exec s6-svscanctl -t /var/run/s6/services
9+
else
10+
sleep 5
911
fi

0 commit comments

Comments
 (0)