genconfig: Add client-to-client support

This commit is contained in:
Kyle Manna 2014-07-09 08:17:19 -07:00
parent d5979915cf
commit f263eb9a61

View File

@ -39,6 +39,7 @@ usage() {
echo
echo "optional arguments:"
echo " -d Disable NAT routing and default route"
echo " -c Enable client-to-client option"
}
set -ex
@ -54,7 +55,7 @@ ORIG_OVPN_ROUTES=$OVPN_ROUTES
OVPN_ROUTES=""
# Parse arguments
while getopts ":r:s:du:" opt; do
while getopts ":r:s:du:c" opt; do
case $opt in
r)
if [ -n "$OVPN_ROUTES" ]; then
@ -72,6 +73,9 @@ while getopts ":r:s:du:" opt; do
u)
OVPN_SERVER_URL=$OPTARG
;;
c)
OVPN_CLIENT_TO_CLIENT=1
;;
\?)
set +x
echo "Invalid option: -$OPTARG" >&2
@ -114,6 +118,7 @@ fi
export OVPN_SERVER OVPN_ROUTES OVPN_DEFROUTE
export OVPN_SERVER_URL OVPN_ENV OVPN_PROTO OVPN_CN OVPN_PORT
export OVPN_CLIENT_TO_CLIENT
# Preserve config
if [ -f "$OVPN_ENV" ]; then
@ -155,6 +160,8 @@ status /tmp/openvpn-status.log
client-config-dir $OPENVPN/ccd
EOF
[ -n "$OVPN_CLIENT_TO_CLIENT" ] && echo "client-to-client" >> "$conf"
# Append Routes
for i in ${OVPN_ROUTES[@]}; do
# If user passed "0" skip this, assume no extra routes