From 8a496e779bbe15d77ef3ef3a56c01f854597f596 Mon Sep 17 00:00:00 2001 From: BlubbFish Date: Tue, 4 Aug 2026 14:54:51 +0200 Subject: [PATCH] stuff --- NetMonitorServer/MainService.cs | 10 +- NetMonitorServer/NetMonitorServer.csproj | 143 ++---------------- NetMonitorServer/NetMonitorServer.csproj.user | 29 ++-- NetMonitorServer/Program.cs | 66 ++++---- NetMonitorServer/ServerModel.cs | 29 +--- 5 files changed, 63 insertions(+), 214 deletions(-) diff --git a/NetMonitorServer/MainService.cs b/NetMonitorServer/MainService.cs index d3595b1..ea9d773 100644 --- a/NetMonitorServer/MainService.cs +++ b/NetMonitorServer/MainService.cs @@ -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 + "\\"; diff --git a/NetMonitorServer/NetMonitorServer.csproj b/NetMonitorServer/NetMonitorServer.csproj index d3962e5..13cf42c 100644 --- a/NetMonitorServer/NetMonitorServer.csproj +++ b/NetMonitorServer/NetMonitorServer.csproj @@ -1,139 +1,18 @@ - - + + - Debug - x86 - 8.0.30703 - 2.0 - {7813196F-D729-44A2-81C7-82BB83E207F5} Exe - Properties - NetMonitorServer - NetMonitorServer - v4.5 - - - 512 - veröffentlichen\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - - - AnyCPU - true - full - false - ..\bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - AnyCPU - none - true - ..\bin\Release\ - - - prompt - 4 - false - - - icon.ico - - - - - - app.manifest + netcoreapp3.1 + NetmonitorServer + - - - - - - - - - - + + + - - - - - - - Component - - - MainService.cs - - - Component - - - - + - - - MainService.cs - - - - - - - - {fac8ce64-bf13-4ece-8097-aeb5dd060098} - Utils - - - - - Designer - - - - - False - Microsoft .NET Framework 4.5 %28x86 and x64%29 - true - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - false - - - - - \ No newline at end of file + + diff --git a/NetMonitorServer/NetMonitorServer.csproj.user b/NetMonitorServer/NetMonitorServer.csproj.user index 90dda4c..798f654 100644 --- a/NetMonitorServer/NetMonitorServer.csproj.user +++ b/NetMonitorServer/NetMonitorServer.csproj.user @@ -1,21 +1,12 @@  - - - -r - Program - D:\Visual Studio 2012\Projects\netmonitor\bin\Debug\NetMonitorServer.exe - - - -r - - - veröffentlichen\ - - - - - - de-DE - false - + + + + + Component + + + Component + + \ No newline at end of file diff --git a/NetMonitorServer/Program.cs b/NetMonitorServer/Program.cs index d09880f..30fe52e 100644 --- a/NetMonitorServer/Program.cs +++ b/NetMonitorServer/Program.cs @@ -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 { - /// - /// The main entry point for the application. - /// - 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 { + { "-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); } } } diff --git a/NetMonitorServer/ServerModel.cs b/NetMonitorServer/ServerModel.cs index 6c03d6d..ea210a0 100644 --- a/NetMonitorServer/ServerModel.cs +++ b/NetMonitorServer/ServerModel.cs @@ -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(); - } + class ServerModel : OwnSingeton { /// /// Openvpn Instanzen Dictionary /// - public Dictionary openvpnInstances; + public Dictionary openvpnInstances; + + private ServerModel() => this.openvpnInstances = new Dictionary(); + } }