summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/anytun-config.cpp10
-rw-r--r--src/anytun-controld.cpp10
-rw-r--r--src/anytun.cpp28
-rw-r--r--src/cryptinit.hpp13
-rw-r--r--src/options.cpp17
5 files changed, 38 insertions, 40 deletions
diff --git a/src/anytun-config.cpp b/src/anytun-config.cpp
index f69e883..0e60710 100644
--- a/src/anytun-config.cpp
+++ b/src/anytun-config.cpp
@@ -110,14 +110,8 @@ int main(int argc, char* argv[])
exit(0);
}
StringList targets = gOpt.getLogTargets();
- if(targets.empty()) {
- cLog.addTarget("stderr:2");
- }
- else {
- StringList::const_iterator it;
- for(it = targets.begin();it != targets.end(); ++it)
- cLog.addTarget(*it);
- }
+ for(StringList::const_iterator it = targets.begin();it != targets.end(); ++it)
+ cLog.addTarget(*it);
}
catch(syntax_error& e)
{
diff --git a/src/anytun-controld.cpp b/src/anytun-controld.cpp
index 1dbc6f8..c70f770 100644
--- a/src/anytun-controld.cpp
+++ b/src/anytun-controld.cpp
@@ -90,14 +90,8 @@ int main(int argc, char* argv[])
exit(0);
}
StringList targets = gOpt.getLogTargets();
- if(targets.empty()) {
- cLog.addTarget("syslog:3,anytun-controld,daemon");
- }
- else {
- StringList::const_iterator it;
- for(it = targets.begin();it != targets.end(); ++it)
- cLog.addTarget(*it);
- }
+ for(StringList::const_iterator it = targets.begin();it != targets.end(); ++it)
+ cLog.addTarget(*it);
}
catch(syntax_error& e)
{
diff --git a/src/anytun.cpp b/src/anytun.cpp
index e7afbd5..6ae4217 100644
--- a/src/anytun.cpp
+++ b/src/anytun.cpp
@@ -380,22 +380,8 @@ int main(int argc, char* argv[])
exit(0);
}
StringList targets = gOpt.getLogTargets();
- if(targets.empty()) {
-#ifndef _MSC_VER
- cLog.addTarget("syslog:3,anytun,daemon");
-#else
- #ifdef WIN_SERVICE
- cLog.addTarget("eventlog:3,anytun");
- #else
- cLog.addTarget("stdout:3");
- #endif
-#endif
- }
- else {
- StringList::const_iterator it;
- for(it = targets.begin();it != targets.end(); ++it)
- cLog.addTarget(*it);
- }
+ for(StringList::const_iterator it = targets.begin();it != targets.end(); ++it)
+ cLog.addTarget(*it);
}
catch(syntax_error& e)
{
@@ -454,14 +440,8 @@ int main(int argc, char* argv[])
if (postup_script)
boost::thread(boost::bind(&SysExec::waitForScript,postup_script));
#endif
-#ifndef NO_CRYPT
-#ifndef USE_SSL_CRYPTO
-// this must be called before any other libgcrypt call
- if(!initLibGCrypt())
- return -1;
-#endif
-#endif
-
+ initCrypto();
+
PacketSource* src = new UDPPacketSource(gOpt.getLocalAddr(), gOpt.getLocalPort());
if(gOpt.getRemoteAddr() != "")
diff --git a/src/cryptinit.hpp b/src/cryptinit.hpp
index f165c65..f8ac938 100644
--- a/src/cryptinit.hpp
+++ b/src/cryptinit.hpp
@@ -104,4 +104,17 @@ bool initLibGCrypt()
#endif
#endif
+bool initCrypto()
+{
+#ifndef NO_CRYPT
+#ifndef USE_SSL_CRYPTO
+ return initLibGCrypt();
+#else
+ return true;
+#endif
+#else
+ return true;
+#endif
+}
+
#endif
diff --git a/src/options.cpp b/src/options.cpp
index 236acb1..6c3437e 100644
--- a/src/options.cpp
+++ b/src/options.cpp
@@ -470,6 +470,22 @@ bool Options::parse(int argc, char* argv[])
throw syntax_error("unknown role name: " + role, -1);
}
+ if(log_targets_.empty()) {
+#ifndef _MSC_VER
+ #if !defined(ANYCONF_OPTIONS)
+ log_targets_.push_back(std::string("syslog:3,").append(progname_).append(",daemon"));
+ #else
+ log_targets_.push_back("stderr:2");
+ #endif
+#else
+ #ifdef WIN_SERVICE
+ log_targets_.push_back("eventlog:3,".append(progname_));
+ #else
+ log_targets_.push_back("stdout:3");
+ #endif
+#endif
+ }
+
return true;
}
@@ -524,6 +540,7 @@ void Options::printUsage()
std::cout << " [-L|--log] <target>:<level>[,<param1>[,<param2>..]]" << std::endl;
std::cout << " add a log target, can be invoked several times" << std::endl;
+ std::cout << " i.e.: stdout:5" << std::endl;
#if defined(ANYCTR_OPTIONS)