This commit is contained in:
BlubbFish 2026-08-04 14:54:51 +02:00
parent e1dde73f42
commit 8a496e779b
5 changed files with 63 additions and 214 deletions

View File

@ -1,14 +1,11 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.ServiceProcess;
using System.Text;
using System.Threading;
using BlubbFish.Utils;
namespace NetMonitorServer {
@ -17,6 +14,7 @@ namespace NetMonitorServer {
private static UdpClient receiveStream;
private static FileLogger log;
private static OwnObject.LogLevel loglevel;
public MainService() {
string folder = Factory.getSettings().getValue("program", "logfolder");
folder = folder.EndsWith("\\") ? folder : folder + "\\";

View File

@ -1,139 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{7813196F-D729-44A2-81C7-82BB83E207F5}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NetMonitorServer</RootNamespace>
<AssemblyName>NetMonitorServer</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<PublishUrl>veröffentlichen\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\Release\</OutputPath>
<DefineConstants>
</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>NetmonitorServer</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Xml" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0" />
<PackageReference Include="TopShelf.ServiceInstaller" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="ActionClass.cs" />
<Compile Include="Controller\OpenVpnController.cs" />
<Compile Include="Factory.cs" />
<Compile Include="Actions\SetOpenVPNService.cs" />
<Compile Include="Actions\SetService.cs" />
<Compile Include="MainService.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="MainService.Designer.cs">
<DependentUpon>MainService.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Actions\SetNetworks.cs" />
<Compile Include="ServerModel.cs" />
<ProjectReference Include="..\..\Utils\Utils\Utils\Utils.csproj" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="MainService.resx">
<DependentUpon>MainService.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Content Include="icon.ico" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Utils\Utils\Utils.csproj">
<Project>{fac8ce64-bf13-4ece-8097-aeb5dd060098}</Project>
<Name>Utils</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.manifest">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

View File

@ -1,21 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<StartArguments>-r</StartArguments>
<StartAction>Program</StartAction>
<StartProgram>D:\Visual Studio 2012\Projects\netmonitor\bin\Debug\NetMonitorServer.exe</StartProgram>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<StartArguments>-r</StartArguments>
</PropertyGroup>
<PropertyGroup>
<PublishUrlHistory>veröffentlichen\</PublishUrlHistory>
<InstallUrlHistory />
<SupportUrlHistory />
<UpdateUrlHistory />
<BootstrapperUrlHistory />
<ErrorReportUrlHistory />
<FallbackCulture>de-DE</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<ItemGroup>
<Compile Update="MainService.cs">
<SubType>Component</SubType>
</Compile>
<Compile Update="Program.cs">
<SubType>Component</SubType>
</Compile>
</ItemGroup>
</Project>

View File

@ -1,48 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Configuration.Install;
using System.ComponentModel;
using System.Configuration.Install;
using System.ServiceProcess;
using System.Threading;
using BlubbFish.Utils;
namespace NetMonitorServer {
[RunInstaller(true)]
public class TestWinInstaller : Installer {
private ServiceInstaller m_ThisService;
private ServiceProcessInstaller m_ThisServiceProcess;
public TestWinInstaller() {
m_ThisService = new ServiceInstaller();
m_ThisServiceProcess = new ServiceProcessInstaller();
m_ThisServiceProcess.Account = ServiceAccount.LocalSystem;
m_ThisService.ServiceName = "NetMonitorServer";
m_ThisService.StartType = ServiceStartMode.Automatic;
m_ThisService.Description = "Teil von NetMonitor der die Systemnahen Befele ausführt";
m_ThisService.DisplayName = "Netzwerk Settings Tool";
Installers.Add(m_ThisService);
Installers.Add(m_ThisServiceProcess);
public class InstallWindowsService : Installer {
public InstallWindowsService() {
this.Installers.Add(new ServiceInstaller {
ServiceName = "NetMonitorServer",
StartType = ServiceStartMode.Automatic,
Description = "Teil von NetMonitor der die Systemnahen Befele ausführt",
DisplayName = "Netmonitor Server"
});
this.Installers.Add(new ServiceProcessInstaller {
Account = ServiceAccount.LocalSystem
});
}
}
static class Program {
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main(string[] args) {
if(args.Length == 0) {
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new MainService()
};
ServiceBase.Run(ServicesToRun);
} else if(args.Length == 1 && args[0] == "-r") {
MainService s = new MainService();
s.StartServiceConsole(args);
class Program {
static void Main(String[] args) => new Program(args);
public Program(String[] args) {
CmdArgs.Instance.SetArguments(new Dictionary<String, CmdArgs.VaildArguments> {
{ "-r", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single, false) }
}, args);
if(CmdArgs.Instance.HasArgumentType("-r")) {
ServiceBase.Run(new ServiceBase[] { new MainService() });
} else {
new MainService().StartServiceConsole(args);
while(true) {
System.Threading.Thread.Sleep(100);
Thread.Sleep(100);
}
}
}

View File

@ -1,31 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using BlubbFish.Utils;
using NetMonitorServer.Controller;
namespace NetMonitorServer {
class ServerModel {
private static volatile ServerModel instance;
private static object syncRoot = new Object();
public static ServerModel Instance {
get {
if(instance == null) {
lock(syncRoot) {
if(instance == null)
instance = new ServerModel();
}
}
return instance;
}
}
private ServerModel() {
openvpnInstances = new Dictionary<string, OpenVpnController>();
}
class ServerModel : OwnSingeton<ServerModel> {
/// <summary>
/// Openvpn Instanzen Dictionary
/// </summary>
public Dictionary<string, OpenVpnController> openvpnInstances;
public Dictionary<String, OpenVpnController> openvpnInstances;
private ServerModel() => this.openvpnInstances = new Dictionary<String, OpenVpnController>();
}
}