diff options
-rw-r--r-- | src/anytun.cpp | 26 | ||||
-rw-r--r-- | src/anytun.vcproj | 291 | ||||
-rw-r--r-- | src/posix/signalHandler.hpp | 6 | ||||
-rw-r--r-- | src/signalController.cpp | 9 | ||||
-rw-r--r-- | src/signalController.h | 15 | ||||
-rw-r--r-- | src/win32/signalHandler.hpp | 6 | ||||
-rw-r--r-- | src/win32/signalServiceHandler.hpp | 19 | ||||
-rw-r--r-- | src/win32/winService.cpp | 4 | ||||
-rw-r--r-- | src/win32/winService.h | 2 |
9 files changed, 185 insertions, 193 deletions
diff --git a/src/anytun.cpp b/src/anytun.cpp index ddec0c0..a693e34 100644 --- a/src/anytun.cpp +++ b/src/anytun.cpp @@ -51,13 +51,13 @@ #include "keyDerivationFactory.h" #include "signalController.h" #ifndef _MSC_VER -#include "daemonService.h" +# include "daemonService.h" #else -#ifdef WIN_SERVICE -#include "win32/winService.h" -#else -#include "nullDaemon.h" -#endif +# ifdef WIN_SERVICE +# include "win32/winService.h" +# else +# include "nullDaemon.h" +# endif #endif #include "packetSource.h" #include "tunDevice.h" @@ -69,7 +69,6 @@ #include "networkAddress.h" #endif - #ifndef ANYTUN_NOSYNC #include "syncQueue.h" #include "syncCommand.h" @@ -358,14 +357,13 @@ int main(int argc, char* argv[]) } } -int real_main(int argc, char* argv[], WinService* service) +int real_main(int argc, char* argv[], WinService& service) { bool daemonized=true; #else int main(int argc, char* argv[]) { - DaemonService daemon; - DaemonService* service = &daemon; + DaemonService service; bool daemonized=false; #endif try @@ -390,9 +388,9 @@ int main(int argc, char* argv[]) gOpt.parse_post(); // print warnings // daemonizing has to done before any thread gets started - service->initPrivs(gOpt.getUsername(), gOpt.getGroupname()); + service.initPrivs(gOpt.getUsername(), gOpt.getGroupname()); if(gOpt.getDaemonize()) { - service->daemonize(); + service.daemonize(); daemonized = true; } @@ -410,13 +408,13 @@ int main(int argc, char* argv[]) if(gOpt.getChrootDir() != "") { try { - service->chroot(gOpt.getChrootDir()); + service.chroot(gOpt.getChrootDir()); } catch(const std::runtime_error& e) { cLog.msg(Log::PRIO_WARNING) << "ignoring chroot error: " << e.what(); } } - service->dropPrivs(); + service.dropPrivs(); // this has to be called before the first thread is started gSignalController.init(service); diff --git a/src/anytun.vcproj b/src/anytun.vcproj index 721daee..37ca622 100644 --- a/src/anytun.vcproj +++ b/src/anytun.vcproj @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
@@ -6,7 +6,6 @@ ProjectGUID="{12460D00-D78A-4C68-BDE2-9E3B2F9CD0F3}"
RootNamespace="anytun"
Keyword="Win32Proj"
- AssemblyReferenceSearchPaths=""..\..\..\..\Program Files\boost\boost_1_35_0""
TargetFrameworkVersion="196613"
>
<Platforms>
@@ -44,9 +43,8 @@ />
<Tool
Name="VCCLCompilerTool"
- AdditionalOptions="/I "C:\Program Files\boost\boost_1_35_0\""
Optimization="0"
- PreprocessorDefinitions="LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;USE_SSL_CRYPTO;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK"
+ PreprocessorDefinitions="_WIN32_WINNT=0x0501;LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;USE_SSL_CRYPTO;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@@ -97,14 +95,14 @@ />
</Configuration>
<Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release"
+ Name="Debug|x64"
+ OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
>
<Tool
Name="VCPreBuildEventTool"
- CommandLine="win32/make_version_h.bat"
+ CommandLine="win32/make_version_h.bat"
/>
<Tool
Name="VCCustomBuildTool"
@@ -117,15 +115,19 @@ />
<Tool
Name="VCMIDLTool"
+ TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
- PreprocessorDefinitions="LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;USE_SSL_CRYPTO;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
+ Optimization="0"
+ PreprocessorDefinitions="_WIN32_WINNT=0x0501;LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;USE_SSL_CRYPTO;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
- Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
+ ForcedIncludeFiles=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -138,14 +140,13 @@ />
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="libeay32MD.lib"
+ AdditionalDependencies="libeay32MDd.lib"
LinkIncremental="2"
AdditionalLibraryDirectories=""
+ IgnoreAllDefaultLibraries="false"
GenerateDebugInformation="true"
SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
+ TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
@@ -170,14 +171,14 @@ />
</Configuration>
<Configuration
- Name="Service Debug|Win32"
- OutputDirectory="$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
ConfigurationType="1"
>
<Tool
Name="VCPreBuildEventTool"
- CommandLine="win32/make_version_h.bat"
+ CommandLine="win32/make_version_h.bat"
/>
<Tool
Name="VCCustomBuildTool"
@@ -193,17 +194,12 @@ />
<Tool
Name="VCCLCompilerTool"
- AdditionalOptions="/I "C:\Program Files\boost\boost_1_35_0\""
- Optimization="0"
- PreprocessorDefinitions="LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN_SERVICE;USE_SSL_CRYPTO;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
+ PreprocessorDefinitions="_WIN32_WINNT=0x0501;LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;USE_SSL_CRYPTO;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK"
+ RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
- DebugInformationFormat="4"
- ForcedIncludeFiles=""
+ DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -216,13 +212,13 @@ />
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="libeay32MDd.lib"
- OutputFile="$(OutDir)\$(ProjectName)svc.exe"
+ AdditionalDependencies="libeay32MD.lib"
LinkIncremental="2"
AdditionalLibraryDirectories=""
- IgnoreAllDefaultLibraries="false"
GenerateDebugInformation="true"
SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
@@ -248,9 +244,9 @@ />
</Configuration>
<Configuration
- Name="Service Release|Win32"
- OutputDirectory="$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
+ Name="Release|x64"
+ OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
>
<Tool
@@ -268,10 +264,11 @@ />
<Tool
Name="VCMIDLTool"
+ TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
- PreprocessorDefinitions="LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN_SERVICE;USE_SSL_CRYPTO;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK"
+ PreprocessorDefinitions="_WIN32_WINNT=0x0501;LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;USE_SSL_CRYPTO;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
@@ -290,14 +287,13 @@ <Tool
Name="VCLinkerTool"
AdditionalDependencies="libeay32MD.lib"
- OutputFile="$(OutDir)\$(ProjectName)svc.exe"
LinkIncremental="2"
AdditionalLibraryDirectories=""
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
- TargetMachine="1"
+ TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
@@ -322,7 +318,7 @@ />
</Configuration>
<Configuration
- Name="Debug with gcrypt|Win32"
+ Name="Service Debug|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
@@ -345,14 +341,14 @@ />
<Tool
Name="VCCLCompilerTool"
- AdditionalOptions="/I "C:\Program Files\boost\boost_1_35_0\""
Optimization="0"
- PreprocessorDefinitions="LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK;ssize_t=long"
+ PreprocessorDefinitions="_WIN32_WINNT=0x0501;LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN_SERVICE;USE_SSL_CRYPTO;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
ForcedIncludeFiles=""
/>
@@ -367,7 +363,8 @@ />
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="libgcrypt.lib libgpg-error.lib"
+ AdditionalDependencies="libeay32MDd.lib"
+ OutputFile="$(OutDir)\$(ProjectName)svc.exe"
LinkIncremental="2"
AdditionalLibraryDirectories=""
IgnoreAllDefaultLibraries="false"
@@ -398,9 +395,9 @@ />
</Configuration>
<Configuration
- Name="Release with gcrypt|Win32"
- OutputDirectory="$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
+ Name="Service Debug|x64"
+ OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
>
<Tool
@@ -418,15 +415,20 @@ />
<Tool
Name="VCMIDLTool"
+ TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
- PreprocessorDefinitions="LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK;ssize_t=long"
- RuntimeLibrary="2"
+ Optimization="0"
+ PreprocessorDefinitions="_WIN32_WINNT=0x0501;LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN_SERVICE;USE_SSL_CRYPTO;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
+ ForcedIncludeFiles=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -439,14 +441,14 @@ />
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="libgcrypt.lib libgpg-error.lib"
+ AdditionalDependencies="libeay32MDd.lib"
+ OutputFile="$(OutDir)\$(ProjectName)svc.exe"
LinkIncremental="2"
AdditionalLibraryDirectories=""
+ IgnoreAllDefaultLibraries="false"
GenerateDebugInformation="true"
SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
+ TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
@@ -471,7 +473,7 @@ />
</Configuration>
<Configuration
- Name="Service Debug with gcrypt|Win32"
+ Name="Service Release|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
@@ -494,17 +496,12 @@ />
<Tool
Name="VCCLCompilerTool"
- AdditionalOptions="/I "C:\Program Files\boost\boost_1_35_0\""
- Optimization="0"
- PreprocessorDefinitions="LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN_SERVICE;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK;ssize_t=long"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
+ PreprocessorDefinitions="_WIN32_WINNT=0x0501;LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN_SERVICE;USE_SSL_CRYPTO;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK"
+ RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
- DebugInformationFormat="4"
- ForcedIncludeFiles=""
+ DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -517,13 +514,14 @@ />
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="libgcrypt.lib libgpg-error.lib"
+ AdditionalDependencies="libeay32MD.lib"
OutputFile="$(OutDir)\$(ProjectName)svc.exe"
LinkIncremental="2"
AdditionalLibraryDirectories=""
- IgnoreAllDefaultLibraries="false"
GenerateDebugInformation="true"
SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
@@ -549,9 +547,9 @@ />
</Configuration>
<Configuration
- Name="Service Release with gcrypt|Win32"
- OutputDirectory="$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
+ Name="Service Release|x64"
+ OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
>
<Tool
@@ -569,10 +567,11 @@ />
<Tool
Name="VCMIDLTool"
+ TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
- PreprocessorDefinitions="LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN_SERVICE;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK;ssize_t=long"
+ PreprocessorDefinitions="_WIN32_WINNT=0x0501;LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN_SERVICE;USE_SSL_CRYPTO;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
@@ -590,7 +589,7 @@ />
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="libgcrypt.lib libgpg-error.lib"
+ AdditionalDependencies="libeay32MD.lib"
OutputFile="$(OutDir)\$(ProjectName)svc.exe"
LinkIncremental="2"
AdditionalLibraryDirectories=""
@@ -598,7 +597,7 @@ SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
- TargetMachine="1"
+ TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
@@ -623,9 +622,9 @@ />
</Configuration>
<Configuration
- Name="Debug|x64"
- OutputDirectory="$(PlatformName)\$(ConfigurationName)"
- IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ Name="Debug with gcrypt|Win32"
+ OutputDirectory="$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
>
<Tool
@@ -643,19 +642,17 @@ />
<Tool
Name="VCMIDLTool"
- TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalOptions="/I "C:\Program Files\boost\boost_1_35_0\""
Optimization="0"
- PreprocessorDefinitions="LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;USE_SSL_CRYPTO;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK"
+ PreprocessorDefinitions="_WIN32_WINNT=0x0501;LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK;ssize_t=long"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
- DebugInformationFormat="3"
+ DebugInformationFormat="4"
ForcedIncludeFiles=""
/>
<Tool
@@ -669,13 +666,13 @@ />
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="libeay32MDd.lib"
+ AdditionalDependencies="libgcrypt.lib libgpg-error.lib"
LinkIncremental="2"
AdditionalLibraryDirectories=""
IgnoreAllDefaultLibraries="false"
GenerateDebugInformation="true"
SubSystem="1"
- TargetMachine="17"
+ TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
@@ -700,7 +697,7 @@ />
</Configuration>
<Configuration
- Name="Release|x64"
+ Name="Debug with gcrypt|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
@@ -724,12 +721,15 @@ />
<Tool
Name="VCCLCompilerTool"
- PreprocessorDefinitions="LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;USE_SSL_CRYPTO;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
+ Optimization="0"
+ PreprocessorDefinitions="_WIN32_WINNT=0x0501;LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK;ssize_t=long"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
- Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
+ ForcedIncludeFiles=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -742,13 +742,12 @@ />
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="libeay32MD.lib"
+ AdditionalDependencies="libgcrypt.lib libgpg-error.lib"
LinkIncremental="2"
AdditionalLibraryDirectories=""
+ IgnoreAllDefaultLibraries="false"
GenerateDebugInformation="true"
SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
TargetMachine="17"
/>
<Tool
@@ -774,9 +773,9 @@ />
</Configuration>
<Configuration
- Name="Service Debug|x64"
- OutputDirectory="$(PlatformName)\$(ConfigurationName)"
- IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ Name="Release with gcrypt|Win32"
+ OutputDirectory="$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
>
<Tool
@@ -794,21 +793,15 @@ />
<Tool
Name="VCMIDLTool"
- TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalOptions="/I "C:\Program Files\boost\boost_1_35_0\""
- Optimization="0"
- PreprocessorDefinitions="LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN_SERVICE;USE_SSL_CRYPTO;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
+ PreprocessorDefinitions="_WIN32_WINNT=0x0501;LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK;ssize_t=long"
+ RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
- ForcedIncludeFiles=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -821,14 +814,14 @@ />
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="libeay32MDd.lib"
- OutputFile="$(OutDir)\$(ProjectName)svc.exe"
+ AdditionalDependencies="libgcrypt.lib libgpg-error.lib"
LinkIncremental="2"
AdditionalLibraryDirectories=""
- IgnoreAllDefaultLibraries="false"
GenerateDebugInformation="true"
SubSystem="1"
- TargetMachine="17"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
@@ -853,7 +846,7 @@ />
</Configuration>
<Configuration
- Name="Service Release|x64"
+ Name="Release with gcrypt|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
@@ -877,7 +870,7 @@ />
<Tool
Name="VCCLCompilerTool"
- PreprocessorDefinitions="LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN_SERVICE;USE_SSL_CRYPTO;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK"
+ PreprocessorDefinitions="_WIN32_WINNT=0x0501;LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK;ssize_t=long"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
@@ -895,8 +888,7 @@ />
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="libeay32MD.lib"
- OutputFile="$(OutDir)\$(ProjectName)svc.exe"
+ AdditionalDependencies="libgcrypt.lib libgpg-error.lib"
LinkIncremental="2"
AdditionalLibraryDirectories=""
GenerateDebugInformation="true"
@@ -928,9 +920,9 @@ />
</Configuration>
<Configuration
- Name="Debug with gcrypt|x64"
- OutputDirectory="$(PlatformName)\$(ConfigurationName)"
- IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ Name="Service Debug with gcrypt|Win32"
+ OutputDirectory="$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
>
<Tool
@@ -948,19 +940,18 @@ />
<Tool
Name="VCMIDLTool"
- TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalOptions="/I "C:\Program Files\boost\boost_1_35_0\""
Optimization="0"
- PreprocessorDefinitions="LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK;ssize_t=long"
+ PreprocessorDefinitions="_WIN32_WINNT=0x0501;LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN_SERVICE;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK;ssize_t=long"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
- DebugInformationFormat="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
ForcedIncludeFiles=""
/>
<Tool
@@ -975,12 +966,13 @@ <Tool
Name="VCLinkerTool"
AdditionalDependencies="libgcrypt.lib libgpg-error.lib"
+ OutputFile="$(OutDir)\$(ProjectName)svc.exe"
LinkIncremental="2"
AdditionalLibraryDirectories=""
IgnoreAllDefaultLibraries="false"
GenerateDebugInformation="true"
SubSystem="1"
- TargetMachine="17"
+ TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
@@ -1005,7 +997,7 @@ />
</Configuration>
<Configuration
- Name="Release with gcrypt|x64"
+ Name="Service Debug with gcrypt|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
@@ -1029,12 +1021,16 @@ />
<Tool
Name="VCCLCompilerTool"
- PreprocessorDefinitions="LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK;ssize_t=long"
- RuntimeLibrary="2"
+ Optimization="0"
+ PreprocessorDefinitions="_WIN32_WINNT=0x0501;LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN_SERVICE;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK;ssize_t=long"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
+ ForcedIncludeFiles=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -1048,12 +1044,12 @@ <Tool
Name="VCLinkerTool"
AdditionalDependencies="libgcrypt.lib libgpg-error.lib"
+ OutputFile="$(OutDir)\$(ProjectName)svc.exe"
LinkIncremental="2"
AdditionalLibraryDirectories=""
+ IgnoreAllDefaultLibraries="false"
GenerateDebugInformation="true"
SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
TargetMachine="17"
/>
<Tool
@@ -1079,9 +1075,9 @@ />
</Configuration>
<Configuration
- Name="Service Debug with gcrypt|x64"
- OutputDirectory="$(PlatformName)\$(ConfigurationName)"
- IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ Name="Service Release with gcrypt|Win32"
+ OutputDirectory="$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
>
<Tool
@@ -1099,21 +1095,15 @@ />
<Tool
Name="VCMIDLTool"
- TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalOptions="/I "C:\Program Files\boost\boost_1_35_0\""
- Optimization="0"
- PreprocessorDefinitions="LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN_SERVICE;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK;ssize_t=long"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
+ PreprocessorDefinitions="_WIN32_WINNT=0x0501;LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN_SERVICE;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK;ssize_t=long"
+ RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
- ForcedIncludeFiles=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -1130,10 +1120,11 @@ OutputFile="$(OutDir)\$(ProjectName)svc.exe"
LinkIncremental="2"
AdditionalLibraryDirectories=""
- IgnoreAllDefaultLibraries="false"
GenerateDebugInformation="true"
SubSystem="1"
- TargetMachine="17"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
@@ -1182,7 +1173,7 @@ />
<Tool
Name="VCCLCompilerTool"
- PreprocessorDefinitions="LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN_SERVICE;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK;ssize_t=long"
+ PreprocessorDefinitions="_WIN32_WINNT=0x0501;LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN_SERVICE;WIN32_LEAN_AND_MEAN;NOMINMAX;BOOST_ALL_DYN_LINK;ssize_t=long"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
@@ -1318,6 +1309,10 @@ >
</File>
<File
+ RelativePath=".\nullDaemon.h"
+ >
+ </File>
+ <File
RelativePath=".\options.h"
>
</File>
@@ -1402,6 +1397,10 @@ >
</File>
<File
+ RelativePath=".\sysExec.h"
+ >
+ </File>
+ <File
RelativePath=".\threadUtils.hpp"
>
</File>
@@ -1490,6 +1489,10 @@ >
</File>
<File
+ RelativePath=".\nullDaemon.cpp"
+ >
+ </File>
+ <File
RelativePath=".\options.cpp"
>
<FileConfiguration
@@ -1501,7 +1504,7 @@ />
</FileConfiguration>
<FileConfiguration
- Name="Release|Win32"
+ Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
@@ -1509,7 +1512,7 @@ />
</FileConfiguration>
<FileConfiguration
- Name="Service Debug|Win32"
+ Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
@@ -1517,7 +1520,7 @@ />
</FileConfiguration>
<FileConfiguration
- Name="Service Release|Win32"
+ Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
@@ -1525,7 +1528,7 @@ />
</FileConfiguration>
<FileConfiguration
- Name="Debug with gcrypt|Win32"
+ Name="Service Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
@@ -1533,7 +1536,7 @@ />
</FileConfiguration>
<FileConfiguration
- Name="Release with gcrypt|Win32"
+ Name="Service Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
@@ -1541,7 +1544,7 @@ />
</FileConfiguration>
<FileConfiguration
- Name="Service Debug with gcrypt|Win32"
+ Name="Service Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
@@ -1549,7 +1552,7 @@ />
</FileConfiguration>
<FileConfiguration
- Name="Service Release with gcrypt|Win32"
+ Name="Service Release|x64"
>
<Tool
Name="VCCLCompilerTool"
@@ -1557,7 +1560,7 @@ />
</FileConfiguration>
<FileConfiguration
- Name="Debug|x64"
+ Name="Debug with gcrypt|Win32"
>
<Tool
Name="VCCLCompilerTool"
@@ -1565,7 +1568,7 @@ />
</FileConfiguration>
<FileConfiguration
- Name="Release|x64"
+ Name="Debug with gcrypt|x64"
>
<Tool
Name="VCCLCompilerTool"
@@ -1573,7 +1576,7 @@ />
</FileConfiguration>
<FileConfiguration
- Name="Service Debug|x64"
+ Name="Release with gcrypt|Win32"
>
<Tool
Name="VCCLCompilerTool"
@@ -1581,7 +1584,7 @@ />
</FileConfiguration>
<FileConfiguration
- Name="Service Release|x64"
+ Name="Release with gcrypt|x64"
>
<Tool
Name="VCCLCompilerTool"
@@ -1589,7 +1592,7 @@ />
</FileConfiguration>
<FileConfiguration
- Name="Debug with gcrypt|x64"
+ Name="Service Debug with gcrypt|Win32"
>
<Tool
Name="VCCLCompilerTool"
@@ -1597,7 +1600,7 @@ />
</FileConfiguration>
<FileConfiguration
- Name="Release with gcrypt|x64"
+ Name="Service Debug with gcrypt|x64"
>
<Tool
Name="VCCLCompilerTool"
@@ -1605,7 +1608,7 @@ />
</FileConfiguration>
<FileConfiguration
- Name="Service Debug with gcrypt|x64"
+ Name="Service Release with gcrypt|Win32"
>
<Tool
Name="VCCLCompilerTool"
@@ -1686,6 +1689,10 @@ >
</File>
<File
+ RelativePath=".\sysExec.cpp"
+ >
+ </File>
+ <File
RelativePath=".\win32\tunDevice.cpp"
>
</File>
diff --git a/src/posix/signalHandler.hpp b/src/posix/signalHandler.hpp index 35075b9..a5668b4 100644 --- a/src/posix/signalHandler.hpp +++ b/src/posix/signalHandler.hpp @@ -30,8 +30,8 @@ * along with anytun. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef ANYTUN_signalHandler_h_INCLUDED -#define ANYTUN_signalHandler_h_INCLUDED +#ifndef ANYTUN_signalHandler_hpp_INCLUDED +#define ANYTUN_signalHandler_hpp_INCLUDED #include <csignal> #include <boost/thread.hpp> @@ -100,7 +100,7 @@ void handleSignal() } } -void registerSignalHandler(SignalController& ctrl, DaemonService* /*service*/) +void registerSignalHandler(SignalController& ctrl, DaemonService& /*service*/) { sigset_t signal_set; diff --git a/src/signalController.cpp b/src/signalController.cpp index f20b695..6a20588 100644 --- a/src/signalController.cpp +++ b/src/signalController.cpp @@ -71,14 +71,7 @@ int SigErrorHandler(int /*sig*/, const std::string& msg) #endif #endif -void SignalController::init() -{ - DaemonService* service = NULL; - registerSignalHandler(*this, service); - handler[SIGERROR] = boost::bind(SigErrorHandler, _1, _2); -} - -void SignalController::init(DaemonService* service) +void SignalController::init(DaemonService& service) { registerSignalHandler(*this, service); handler[SIGERROR] = boost::bind(SigErrorHandler, _1, _2); diff --git a/src/signalController.h b/src/signalController.h index 8a82c9e..fa5f0fb 100644 --- a/src/signalController.h +++ b/src/signalController.h @@ -39,14 +39,12 @@ #include "threadUtils.hpp" -#ifndef _MSC_VER -#include "daemonService.h" -#else #ifdef WIN_SERVICE -#include "win32/winService.h" +//#include "win32/winService.h" +class WinService; +typedef WinService DaemonService; #else -#include "nullDaemon.h" -#endif +class DaemonService; #endif #define SIGERROR -1 @@ -61,8 +59,7 @@ class SignalController public: static SignalController& instance(); - void init(); - void init(DaemonService* service); + void init(DaemonService& service); int run(); void inject(int sig, const std::string& msg = ""); @@ -92,7 +89,7 @@ private: typedef std::map<CallbackType, ServiceCallback> CallbackMap; CallbackMap callbacks; - friend void registerSignalHandler(SignalController& ctrl, DaemonService* service); + friend void registerSignalHandler(SignalController& ctrl, DaemonService& service); }; extern SignalController& gSignalController; diff --git a/src/win32/signalHandler.hpp b/src/win32/signalHandler.hpp index fb0c7e6..23872a6 100644 --- a/src/win32/signalHandler.hpp +++ b/src/win32/signalHandler.hpp @@ -30,8 +30,8 @@ * along with anytun. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef ANYTUN_signalHandler_h_INCLUDED -#define ANYTUN_signalHandler_h_INCLUDED +#ifndef ANYTUN_signalHandler_hpp_INCLUDED +#define ANYTUN_signalHandler_hpp_INCLUDED #include <windows.h> @@ -71,7 +71,7 @@ bool handleSignal(DWORD ctrlType) return true; } -void registerSignalHandler(SignalController& ctrl, DaemonService* /*service*/) +void registerSignalHandler(SignalController& ctrl, DaemonService& /*service*/) { if(!SetConsoleCtrlHandler((PHANDLER_ROUTINE)handleSignal, true)) AnytunError::throwErr() << "Error on SetConsoleCtrlhandler: " << AnytunErrno(GetLastError()); diff --git a/src/win32/signalServiceHandler.hpp b/src/win32/signalServiceHandler.hpp index 28121f4..da16de5 100644 --- a/src/win32/signalServiceHandler.hpp +++ b/src/win32/signalServiceHandler.hpp @@ -30,22 +30,19 @@ * along with anytun. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef ANYTUN_signalServiceHandler_h_INCLUDED -#define ANYTUN_signalServiceHandler_h_INCLUDED +#ifndef ANYTUN_signalServiceHandler_hpp_INCLUDED +#define ANYTUN_signalServiceHandler_hpp_INCLUDED #include "winService.h" -void registerSignalHandler(SignalController& ctrl, WinService* service) +void registerSignalHandler(SignalController& ctrl, WinService& service) { - if(!service) - return; + ctrl.handler[SERVICE_CONTROL_STOP] = boost::bind(&WinService::handleCtrlSignal, &service, _1, _2); + ctrl.handler[SERVICE_CONTROL_INTERROGATE] = boost::bind(&WinService::handleCtrlSignal, &service, _1, _2); + ctrl.handler[SIGUNKNOWN] = boost::bind(&WinService::handleCtrlSignal, &service, _1, _2); - ctrl.handler[SERVICE_CONTROL_STOP] = boost::bind(&WinService::handleCtrlSignal, service, _1, _2); - ctrl.handler[SERVICE_CONTROL_INTERROGATE] = boost::bind(&WinService::handleCtrlSignal, service, _1, _2); - ctrl.handler[SIGUNKNOWN] = boost::bind(&WinService::handleCtrlSignal, service, _1, _2); - - ctrl.callbacks.insert(SignalController::CallbackMap::value_type(CALLB_RUNNING, boost::bind(&WinService::reportStatus, service, SERVICE_RUNNING, NO_ERROR))); - ctrl.callbacks.insert(SignalController::CallbackMap::value_type(CALLB_STOPPING, boost::bind(&WinService::reportStatus, service, SERVICE_STOP_PENDING, NO_ERROR))); + ctrl.callbacks.insert(SignalController::CallbackMap::value_type(CALLB_RUNNING, boost::bind(&WinService::reportStatus, &service, SERVICE_RUNNING, NO_ERROR))); + ctrl.callbacks.insert(SignalController::CallbackMap::value_type(CALLB_STOPPING, boost::bind(&WinService::reportStatus, &service, SERVICE_STOP_PENDING, NO_ERROR))); } #endif diff --git a/src/win32/winService.cpp b/src/win32/winService.cpp index e39fe56..8c17420 100644 --- a/src/win32/winService.cpp +++ b/src/win32/winService.cpp @@ -105,7 +105,7 @@ void WinService::start() AnytunError::throwErr() << "Error on StartServiceCtrlDispatcher: " << AnytunErrno(GetLastError());
}
-int real_main(int argc, char* argv[], WinService* service);
+int real_main(int argc, char* argv[], WinService& service);
VOID WINAPI WinService::main(DWORD dwArgc, LPTSTR *lpszArgv)
{
@@ -120,7 +120,7 @@ VOID WINAPI WinService::main(DWORD dwArgc, LPTSTR *lpszArgv) service.status_.dwServiceSpecificExitCode = 0;
service.reportStatus(SERVICE_START_PENDING, NO_ERROR);
- real_main(dwArgc, lpszArgv, &service);
+ real_main(dwArgc, lpszArgv, service);
service.reportStatus(SERVICE_STOPPED, NO_ERROR);
}
diff --git a/src/win32/winService.h b/src/win32/winService.h index ecba55d..9c95400 100644 --- a/src/win32/winService.h +++ b/src/win32/winService.h @@ -68,7 +68,7 @@ private: SERVICE_STATUS_HANDLE status_handle_; }; -typedef class WinService DaemonService; +typedef WinService DaemonService; #endif |