diff options
-rwxr-xr-x | etc/init.d/anytun | 19 | ||||
-rw-r--r-- | src/anytun-controld.cpp | 28 |
2 files changed, 25 insertions, 22 deletions
diff --git a/etc/init.d/anytun b/etc/init.d/anytun index 752eb8d..9fc4d4a 100755 --- a/etc/init.d/anytun +++ b/etc/init.d/anytun @@ -55,12 +55,13 @@ start_configd () { test -d $VARCONFIG_DIR || mkdir -p $VARCONFIG_DIR chmod 700 $VARCONFIG_DIR rm -f $VARCONFIG_DIR/$NAME 2>/dev/null + KDPRF=`sed 's/#.*//' < $CONFIG_DIR/$NAME/config | grep -e 'kd-prf' | sed 's/^/ --/' | xargs echo` for CLIENTNAME in `ls $CONFIG_DIR/$NAME/conf.d`; do echo -n " ($CLIENTNAME)" DAEMONARG=`sed 's/#.*//' < $CONFIG_DIR/$NAME/conf.d/$CLIENTNAME | grep -e '\w' | sed 's/^/ --/' | xargs echo` - $ANYTUNCONFIG $DAEMONARG >> $VARCONFIG_DIR/$NAME + $ANYTUNCONFIG $DAEMONARG $CIPHER $AUTHALGO $KDPRF >> $VARCONFIG_DIR/$NAME done - CONTROLHOST=`sed 's/#.*//' < $CONFIG_DIR/$NAME/config | grep -e 'control-host' | sed 's/^/ --/'` + CONTROLHOST=`sed 's/#.*//' < $CONFIG_DIR/$NAME/config | grep -e 'control-host' | sed 's/^/ --/' | xargs echo` $CONTROLDAEMON -f $VARCONFIG_DIR/$NAME $DAEMONOPTS $CONTROLHOST \ --write-pid $VARCONFIG_DIR/$NAME.pid # rm -f $VARCONFIG_DIR/$NAME @@ -68,7 +69,7 @@ start_configd () { } stop_configd () { if [ -d $CONFIG_DIR/$NAME/conf.d ] ; then - echo -n " ($NAME)" + echo -n " ($NAME-controlld)" kill `cat $VARCONFIG_DIR/$NAME.pid` || true rm $VARCONFIG_DIR/$NAME.pid fi @@ -102,7 +103,7 @@ case "$1" in echo -n "Stoping $DESC:" if test -z "$2" ; then for PIDFILE in `ls $VARRUN_DIR/*.pid 2> /dev/null`; do - NAME=`echo $PIDFILE | cut -c17-` + NAME=`basename $PIDFILE` NAME=${NAME%%.pid} echo -n " $NAME" stop_vpn @@ -112,7 +113,7 @@ case "$1" in [ -z "$1" ] && break if test -e $VARRUN_DIR/$1.pid ; then PIDFILE=`ls $VARRUN_DIR/$1.pid 2> /dev/null` - NAME=`echo $PIDFILE | cut -c17-` + NAME=`basename $PIDFILE` NAME=${NAME%%.pid} echo -n " $NAME" stop_vpn @@ -127,7 +128,7 @@ case "$1" in echo -n "Reloading $DESC:" if test -z "$2" ; then for PIDFILE in `ls $VARRUN_DIR/*.pid 2> /dev/null`; do - NAME=`echo $PIDFILE | cut -c17-` + NAME=`basename $PIDFILE` NAME=${NAME%%.pid} echo -n " $NAME" if [ -d $CONFIG_DIR/$NAME/conf.d ] ; then @@ -143,7 +144,7 @@ case "$1" in [ -z "$1" ] && break if test -e $VARRUN_DIR/$1.pid ; then PIDFILE=`ls $VARRUN_DIR/$1.pid 2> /dev/null` - NAME=`echo $PIDFILE | cut -c17-` + NAME=`basename $PIDFILE` NAME=${NAME%%.pid} echo -n " $NAME" if [ -d $CONFIG_DIR/$NAME/conf.d ] ; then @@ -164,7 +165,7 @@ case "$1" in echo -n "Restarting $DESC:" if test -z "$2" ; then for PIDFILE in `ls $VARRUN_DIR/*.pid 2> /dev/null`; do - NAME=`echo $PIDFILE | cut -c17-` + NAME=`basename $PIDFILE` NAME=${NAME%%.pid} echo -n " $NAME" stop_vpn @@ -176,7 +177,7 @@ case "$1" in [ -z "$1" ] && break if test -e $VARRUN_DIR/$1.pid ; then PIDFILE=`ls $VARRUN_DIR/$1.pid 2> /dev/null` - NAME=`echo $PIDFILE | cut -c17-` + NAME=`basename $PIDFILE` NAME=${NAME%%.pid} echo -n " $NAME" stop_vpn diff --git a/src/anytun-controld.cpp b/src/anytun-controld.cpp index c70f770..dd9be12 100644 --- a/src/anytun-controld.cpp +++ b/src/anytun-controld.cpp @@ -47,17 +47,15 @@ #include "syncServer.h" #include "daemon.hpp" +#include <vector> + +std::list<std::string> config_; void syncOnConnect(SyncTcpConnection * connptr) { - std::ifstream file(gOpt.getFileName().c_str()); - if(file.is_open()) { - std::string line; - while (!file.eof()) { - getline (file,line); - connptr->Send(line); - } - file.close(); + for(std::list<std::string>::const_iterator it=config_.begin(); it!=config_.end();++it) + { + connptr->Send(*it); } } @@ -106,8 +104,14 @@ int main(int argc, char* argv[]) std::ifstream file( gOpt.getFileName().c_str() ); if( file.is_open() ) + { + std::string line; + while (!file.eof()) { + getline (file,line); + config_.push_back(line); + } file.close(); - else { + } else { std::cout << "ERROR: unable to open file!" << std::endl; exit(-1); } @@ -118,13 +122,11 @@ int main(int argc, char* argv[]) daemonized = true; } - gSignalController.init(); - gResolver.init(); - if(gOpt.getChrootDir() != "") do_chroot(gOpt.getChrootDir()); - privs.drop(); + gSignalController.init(); + gResolver.init(); boost::thread * syncListenerThread; syncListenerThread = new boost::thread(boost::bind(syncListener)); |