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