Skip to content

Commit dbdb9fd

Browse files
committed
Bash wizards, removed compression
1 parent e627dce commit dbdb9fd

File tree

25 files changed

+414
-724
lines changed

25 files changed

+414
-724
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
- Rewritten helper scripts
77
- Reorganized examples
88
- Added Site-to-site example
9+
- Removed `compression` from examples
10+
- Switched to bash wizards
911

1012
### 2.0.6 - Fixed bugs, added additonal parameters
1113

root/usr/local/share/docker-openvpn/examples/basic/config/openvpn/openvpn-template.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ persist-tun
2323
cipher AES-256-GCM
2424

2525
# Additional settings
26-
compress lzo
2726
verb 3
2827

2928
# Permissions

root/usr/local/share/docker-openvpn/examples/basic/config/openvpn/openvpn.conf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,5 @@ verify-client-cert require
4444

4545
# Additional settings
4646
client-to-client
47-
keepalive 10 120
48-
compress lzo
47+
keepalive 15 120
4948
explicit-exit-notify 1
Lines changed: 44 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,47 @@
1-
#!/usr/local/bin/python
2-
3-
#
4-
# Config wizard for basic_nat example
5-
# @author Martin Dagarin
6-
# @version 1
7-
# @since 19/03/2019
1+
#!/usr/bin/with-contenv bash
82
#
9-
10-
# Defaults:
11-
# Protocol: udp
12-
# Network: 10.0.0.0
13-
# Port: 1194
14-
# DNS: 8.8.8.8, 8.8.4.4
3+
# Config wizard for basic example
4+
# @author Martin Dagarin
5+
# @version 2
6+
# @since 22/03/2020
157
#
168

17-
import sys, os
18-
19-
# Import libraries included in this docker
20-
sys.path.insert(0, '/app')
21-
import libovpn
22-
23-
# Check if temporary path was passed to this script
24-
if len(sys.argv) < 2:
25-
print("Temporary path was not passed to wizard")
26-
sys.exit(1)
27-
TEMP_PATH = sys.argv[1]
28-
if not os.path.isdir(TEMP_PATH):
29-
print("Specified directory does not exist")
30-
sys.exit(2)
31-
32-
# Select protocol
33-
protocol = input("Protocol udp, tcp, udp6, tcp6 [udp]:")
34-
AVAILABLE_PROTOCOLS = ["udp", "tcp", "udp6", "tcp6"]
35-
if len(protocol) != 0 and protocol not in AVAILABLE_PROTOCOLS:
36-
print("Invalid protocol")
37-
sys.exit(3)
38-
if len(protocol) == 0:
39-
protocol = "udp"
40-
41-
# Select network
42-
network = input("VPN network [10.0.0.0]:")
43-
if len(network) == 0:
44-
network = "10.0.0.0"
45-
46-
# Select port
47-
port = input("Port [1194]:")
48-
if len(port) == 0:
49-
port="1194"
50-
51-
# Select Public IP or domain
52-
public = input("Public IP or domain of server:")
53-
if len(public) == 0:
54-
print("Invalid Public IP")
55-
sys.exit(4)
56-
57-
# DNS servers
58-
dns1 = input("DNS1 [8.8.8.8]:")
59-
if len(dns1) == 0:
60-
dns1 = "8.8.8.8"
61-
dns2 = input("DNS2 [8.8.4.4]:")
62-
if len(dns2) == 0:
63-
dns2 = "8.8.4.4"
64-
65-
66-
# Write to server config
67-
vars = [
68-
("$PROTO", protocol),
69-
("$PORT", port),
70-
("$NETWORK_ADDRESS", network),
71-
("$SERVER_IP", public),
72-
("$DNS1", dns1),
73-
("$DNS2", dns2)
74-
]
75-
76-
# Process config files
77-
confs = [
78-
"/config/openvpn/openvpn.conf",
79-
"/config/openvpn/openvpn-template.conf"
80-
]
81-
for config_file in confs:
82-
libovpn.conf_envsubst(TEMP_PATH + config_file, vars)
9+
if [ -z "$1" ]; then
10+
echo 'Directory path missing'
11+
exit 1
12+
fi
13+
14+
read -p 'Protocol udp, tcp, udp6, tcp6 [udp]: ' protocol
15+
protocol=${protocol:=udp}
16+
17+
read -p 'Port [1194]: ' port
18+
port=${port:=1194}
19+
20+
read -p 'Public IP: ' public_ip
21+
if [ -z "$public_ip" ]; then echo 'Invalid IP'; exit 2; fi
22+
23+
read -p 'VPN network [10.8.0.0]: ' network
24+
network=${network:='10.8.0.0'}
25+
26+
read -p 'DNS1 [1.1.1.1]: ' dns1
27+
dns1=${dns1:='1.1.1.1'}
28+
29+
read -p 'DNS2 [8.8.8.8]: ' dns2
30+
dns2=${dns2:='8.8.8.8'}
31+
32+
confs=(
33+
"$1/config/openvpn/openvpn.conf"
34+
"$1/config/openvpn/openvpn-template.conf"
35+
)
36+
37+
for file in "${confs[@]}"
38+
do
39+
mv $file $file.old
40+
PROTO="$protocol" \
41+
PORT="$port" \
42+
SERVER_IP="$public_ip" \
43+
NETWORK_ADDRESS="$network" \
44+
DNS1="$dns1" \
45+
DNS2="$dns2" \
46+
envsubst < $file.old > $file
47+
done

root/usr/local/share/docker-openvpn/examples/basic_ipv6/config/openvpn/openvpn-template.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ persist-tun
2424
cipher AES-256-GCM
2525

2626
# Additional settings
27-
compress lzo
2827
verb 3
2928

3029
# Permissions

root/usr/local/share/docker-openvpn/examples/basic_ipv6/config/openvpn/openvpn.conf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,5 @@ verify-client-cert require
4747

4848
# Additional settings
4949
client-to-client
50-
keepalive 10 120
51-
compress lzo
50+
keepalive 15 120
5251
explicit-exit-notify 1
Lines changed: 48 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,51 @@
1-
#!/usr/local/bin/python
2-
3-
#
4-
# Config wizard for basic_nat example
5-
# @author Martin Dagarin
6-
# @version 1
7-
# @since 19/03/2019
1+
#!/usr/bin/with-contenv bash
82
#
9-
10-
# Defaults:
11-
# Protocol: udp
12-
# Network: 10.0.0.0
13-
# Port: 1194
14-
# DNS: 8.8.8.8, 2001:4860:4860::8888
3+
# Config wizard for basic_ipv6 example
4+
# @author Martin Dagarin
5+
# @version 2
6+
# @since 22/03/2020
157
#
168

17-
import sys, os
18-
19-
# Import libraries included in this docker
20-
sys.path.insert(0, '/app')
21-
import libovpn
22-
23-
# Check if temporary path was passed to this script
24-
if len(sys.argv) < 2:
25-
print("Temporary path was not passed to wizard")
26-
sys.exit(1)
27-
TEMP_PATH = sys.argv[1]
28-
if not os.path.isdir(TEMP_PATH):
29-
print("Specified directory does not exist")
30-
sys.exit(2)
31-
32-
# Select protocol
33-
protocol = input("Protocol udp, tcp, udp6, tcp6 [udp]:")
34-
AVAILABLE_PROTOCOLS = ["udp", "tcp", "udp6", "tcp6"]
35-
if len(protocol) != 0 and protocol not in AVAILABLE_PROTOCOLS:
36-
print("Invalid protocol")
37-
sys.exit(3)
38-
if len(protocol) == 0:
39-
protocol = "udp"
40-
41-
# Select network
42-
network = input("VPN network [10.0.0.0]:")
43-
if len(network) == 0:
44-
network = "10.0.0.0"
45-
networkv6 = input("VPN IPv6 network with CIDR [2001:db8::/32]:")
46-
if len(network) == 0:
47-
print("Invalid network")
48-
sys.exit(4)
49-
50-
# Select port
51-
port = input("Port [1194]:")
52-
if len(port) == 0:
53-
port="1194"
54-
55-
# Select Public IP or domain
56-
public = input("Public IP or domain of server:")
57-
if len(public) == 0:
58-
print("Invalid Public IP")
59-
sys.exit(5)
60-
61-
# DNS servers
62-
dns1 = input("DNS1 [8.8.8.8]:")
63-
if len(dns1) == 0:
64-
dns1 = "8.8.8.8"
65-
dns2 = input("DNS2 [2001:4860:4860::8888]:")
66-
if len(dns2) == 0:
67-
dns2 = "2001:4860:4860::8888"
68-
69-
70-
# Write to server config
71-
vars = [
72-
("$PROTO", protocol),
73-
("$PORT", port),
74-
("$NETWORK_ADDRESS", network),
75-
("$NETWORK_ADDRESS_IPV6", networkv6),
76-
("$SERVER_IP", public),
77-
("$DNS1", dns1),
78-
("$DNS2", dns2)
79-
]
80-
81-
# Process config files
82-
confs = [
83-
"/config/openvpn/openvpn.conf",
84-
"/config/openvpn/openvpn-template.conf"
85-
]
86-
for config_file in confs:
87-
libovpn.conf_envsubst(TEMP_PATH + config_file, vars)
9+
if [ -z "$1" ]; then
10+
echo 'Directory path missing'
11+
exit 1
12+
fi
13+
14+
read -p 'Protocol udp, tcp, udp6, tcp6 [udp]: ' protocol
15+
protocol=${protocol:=udp}
16+
17+
read -p 'Port [1194]: ' port
18+
port=${port:=1194}
19+
20+
read -p 'Public IP: ' public_ip
21+
if [ -z "$public_ip" ]; then echo 'Invalid IP'; exit 2; fi
22+
23+
read -p 'VPN network [10.8.0.0]: ' network
24+
network=${network:='10.8.0.0'}
25+
26+
read -p 'VPN IPv6 network with CIDR [2001:db8::/64]: ' network6
27+
network6=${network6:='2001:db8::/64'}
28+
29+
read -p 'DNS1 [1.1.1.1]: ' dns1
30+
dns1=${dns1:='1.1.1.1'}
31+
32+
read -p 'DNS2 [8.8.8.8]: ' dns2
33+
dns2=${dns2:='8.8.8.8'}
34+
35+
confs=(
36+
"$1/config/openvpn/openvpn.conf"
37+
"$1/config/openvpn/openvpn-template.conf"
38+
)
39+
40+
for file in "${confs[@]}"
41+
do
42+
mv $file $file.old
43+
PROTO="$protocol" \
44+
PORT="$port" \
45+
SERVER_IP="$public_ip" \
46+
NETWORK_ADDRESS="$network" \
47+
NETWORK_ADDRESS_IPV6="$network6" \
48+
DNS1="$dns1" \
49+
DNS2="$dns2" \
50+
envsubst < $file.old > $file
51+
done

root/usr/local/share/docker-openvpn/examples/basic_nat/config/openvpn/openvpn-template.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ persist-tun
2323
cipher AES-256-GCM
2424

2525
# Additional settings
26-
compress lzo
2726
verb 3
2827

2928
# Permissions

root/usr/local/share/docker-openvpn/examples/basic_nat/config/openvpn/openvpn.conf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,5 @@ verify-client-cert require
4444

4545
# Additional settings
4646
client-to-client
47-
keepalive 10 120
48-
compress lzo
47+
keepalive 15 120
4948
explicit-exit-notify 1

0 commit comments

Comments
 (0)