Changed a lot

This commit is contained in:
BlubbFish 2015-03-04 22:21:34 +00:00
parent cd21034b41
commit 8264cbfa7b
54 changed files with 2014 additions and 529 deletions

View File

@ -12,12 +12,12 @@ namespace NetMonitorClient
{ {
public partial class Netzmonitor : Form public partial class Netzmonitor : Form
{ {
private ServiceControl sc; private NetMonitorUtils.NetworkSetter sc;
public Netzmonitor() public Netzmonitor()
{ {
InitializeComponent(); InitializeComponent();
InitNetworks(); InitNetworks();
this.sc = new ServiceControl("NetMonitorServer"); this.sc = new NetMonitorUtils.NetworkSetter("network.ini","config.ini");
} }
private void Netzmonitor_Resize(object sender, System.EventArgs e) private void Netzmonitor_Resize(object sender, System.EventArgs e)

View File

@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NetMonitorClient</RootNamespace> <RootNamespace>NetMonitorClient</RootNamespace>
<AssemblyName>NetMonitorClient</AssemblyName> <AssemblyName>NetMonitorClient</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<FileUpgradeFlags> <FileUpgradeFlags>
</FileUpgradeFlags> </FileUpgradeFlags>
@ -31,16 +31,18 @@
<IsWebBootstrapper>false</IsWebBootstrapper> <IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>E:\Programme\NetMonitor\</OutputPath> <OutputPath>..\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@ -50,6 +52,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
@ -105,6 +108,7 @@
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
</Compile> </Compile>
<None Include="app.config" />
<None Include="network.ini" /> <None Include="network.ini" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
@ -139,6 +143,16 @@
<ItemGroup> <ItemGroup>
<None Include="Properties\icon_ok.ico" /> <None Include="Properties\icon_ok.ico" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Utils\Utils\Utils.csproj">
<Project>{fac8ce64-bf13-4ece-8097-aeb5dd060098}</Project>
<Name>Utils</Name>
</ProjectReference>
<ProjectReference Include="..\NetMonitorUtils\NetMonitorUtils.csproj">
<Project>{45ee003d-5572-48fe-b90e-6bfe18d9eec8}</Project>
<Name>NetMonitorUtils</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- 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. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -7,7 +7,7 @@ namespace NetMonitorClient
{ {
public class Networksetter public class Networksetter
{ {
private ServiceControl sc; private NetMonitorUtils.NetworkSetter sc;
private InIReader networkini; private InIReader networkini;
private string net_name; private string net_name;
private List<string> loglist; private List<string> loglist;
@ -25,7 +25,7 @@ namespace NetMonitorClient
WinsAuto, WinsAuto,
Wins Wins
} }
public Networksetter(string name, InIReader ini, ServiceControl serv) public Networksetter(string name, InIReader ini, NetMonitorUtils.NetworkSetter serv)
{ {
this.net_name = name; this.net_name = name;
this.networkini = ini; this.networkini = ini;
@ -99,48 +99,48 @@ namespace NetMonitorClient
text.Add("Ip: " + ip + ";Subnet: " + subnet + ";Gateway: " + gateway); text.Add("Ip: " + ip + ";Subnet: " + subnet + ";Gateway: " + gateway);
loglist.Add("Gesendet: " + text); loglist.Add("Gesendet: " + text);
System.Windows.Forms.Application.DoEvents(); System.Windows.Forms.Application.DoEvents();
status = this.sc.setNetworkIp(ip, subnet, gateway, adapter); status = this.sc.setNetworkIp(ip, subnet, gateway, adapter,"");
} }
if (option == netsetter.Auto) if (option == netsetter.Auto)
{ {
text.Add("Netzwerk auf Auto"); text.Add("Netzwerk auf Auto");
loglist.Add("Gesendet: " + text); loglist.Add("Gesendet: " + text);
System.Windows.Forms.Application.DoEvents(); System.Windows.Forms.Application.DoEvents();
status = this.sc.setNetworkAuto(adapter); status = this.sc.setNetworkAuto(adapter,"");
} }
if (option == netsetter.IpAuto) if (option == netsetter.IpAuto)
{ {
text.Add("Ip auf Auto"); text.Add("Ip auf Auto");
loglist.Add("Gesendet: " + text); loglist.Add("Gesendet: " + text);
System.Windows.Forms.Application.DoEvents(); System.Windows.Forms.Application.DoEvents();
status = this.sc.setNetworkIpAuto(adapter); status = this.sc.setNetworkIpAuto(adapter,"");
} }
if (option == netsetter.DnsAuto) if (option == netsetter.DnsAuto)
{ {
text.Add("Dns auf Auto"); text.Add("Dns auf Auto");
loglist.Add("Gesendet: " + text); loglist.Add("Gesendet: " + text);
System.Windows.Forms.Application.DoEvents(); System.Windows.Forms.Application.DoEvents();
status = this.sc.setNetworkDnsAuto(adapter); status = this.sc.setNetworkDnsAuto(adapter,"");
} }
if (option == netsetter.WinsAuto) if (option == netsetter.WinsAuto)
{ {
text.Add("Wins auf Auto"); text.Add("Wins auf Auto");
loglist.Add("Gesendet: " + text); loglist.Add("Gesendet: " + text);
System.Windows.Forms.Application.DoEvents(); System.Windows.Forms.Application.DoEvents();
status = this.sc.setNetworkWinsAuto(adapter); status = this.sc.setNetworkWinsAuto(adapter,"");
} }
if (option == netsetter.Dns) if (option == netsetter.Dns)
{ {
text.Add("Dns: " + dns); text.Add("Dns: " + dns);
loglist.Add("Gesendet: " + text); loglist.Add("Gesendet: " + text);
status = this.sc.setNetworkDNS(dns, adapter); status = this.sc.setNetworkDns(dns, adapter,"");
} }
if (option == netsetter.Wins) if (option == netsetter.Wins)
{ {
text.Add("Wins: " + wins); text.Add("Wins: " + wins);
loglist.Add("Gesendet: " + text); loglist.Add("Gesendet: " + text);
System.Windows.Forms.Application.DoEvents(); System.Windows.Forms.Application.DoEvents();
status = this.sc.setNetworkWINS(wins, adapter); status = this.sc.setNetworkWins(wins, adapter,"");
} }
loglist.Add("Antwort: " + ((status) ? "Ok" : "Fehler")); loglist.Add("Antwort: " + ((status) ? "Ok" : "Fehler"));
System.Windows.Forms.Application.DoEvents(); System.Windows.Forms.Application.DoEvents();

View File

@ -1,10 +1,10 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // Dieser Code wurde von einem Tool generiert.
// Runtime Version:4.0.30319.1 // Laufzeitversion:4.0.30319.34209
// //
// Changes to this file may cause incorrect behavior and will be lost if // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// the code is regenerated. // der Code erneut generiert wird.
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -13,12 +13,12 @@ namespace NetMonitorClient.Properties {
/// <summary> /// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc. /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
/// </summary> /// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
// class via a tool like ResGen or Visual Studio. // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
// To add or remove a member, edit your .ResX file then rerun ResGen // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
// with the /str option, or rebuild your VS project. // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
@ -33,7 +33,7 @@ namespace NetMonitorClient.Properties {
} }
/// <summary> /// <summary>
/// Returns the cached ResourceManager instance used by this class. /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager { internal static global::System.Resources.ResourceManager ResourceManager {
@ -47,8 +47,8 @@ namespace NetMonitorClient.Properties {
} }
/// <summary> /// <summary>
/// Overrides the current thread's CurrentUICulture property for all /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
/// resource lookups using this strongly typed resource class. /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture { internal static global::System.Globalization.CultureInfo Culture {
@ -60,6 +60,9 @@ namespace NetMonitorClient.Properties {
} }
} }
/// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol).
/// </summary>
internal static System.Drawing.Icon icon_no { internal static System.Drawing.Icon icon_no {
get { get {
object obj = ResourceManager.GetObject("icon_no", resourceCulture); object obj = ResourceManager.GetObject("icon_no", resourceCulture);
@ -67,6 +70,9 @@ namespace NetMonitorClient.Properties {
} }
} }
/// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol).
/// </summary>
internal static System.Drawing.Icon icon_ok { internal static System.Drawing.Icon icon_ok {
get { get {
object obj = ResourceManager.GetObject("icon_ok", resourceCulture); object obj = ResourceManager.GetObject("icon_ok", resourceCulture);

View File

@ -1,10 +1,10 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // Dieser Code wurde von einem Tool generiert.
// Runtime Version:4.0.30319.1 // Laufzeitversion:4.0.30319.34209
// //
// Changes to this file may cause incorrect behavior and will be lost if // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// the code is regenerated. // der Code erneut generiert wird.
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -12,7 +12,7 @@ namespace NetMonitorClient.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));

View File

@ -0,0 +1,3 @@
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>

View File

@ -5,27 +5,21 @@ using System.Text;
using BlubbFish.Utils; using BlubbFish.Utils;
using NetMonitorUtils; using NetMonitorUtils;
namespace NetMonitorConsole namespace NetMonitorConsole {
{ class Factory {
class Factory
{
private static CmdArgs instanceArguments; private static CmdArgs instanceArguments;
private static FileLogger instanceLogger; private static FileLogger instanceLogger;
public static CmdArgs getArguments(string[] args) public static CmdArgs getArguments(string[] args) {
{ if(instanceArguments == null) {
if (instanceArguments == null) instanceArguments = CmdArgs.getInstance();
{ Dictionary<string, CmdArgs.VaildArguments> argp = new Dictionary<string, CmdArgs.VaildArguments>();
instanceArguments = CmdArgs.getInstance(String.Join(" ", args, 0, args.Length)); argp.Add("-n", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Touple, true));
Dictionary<string, CmdArgs.ArgLength> argp = new Dictionary<string, CmdArgs.ArgLength>(); instanceArguments.setArguments(argp, args);
argp.Add("-n", CmdArgs.ArgLength.Touple);
instanceArguments.setArguments(argp);
} }
return instanceArguments; return instanceArguments;
} }
public static FileLogger getLogger() public static FileLogger getLogger() {
{ if(instanceLogger == null) {
if (instanceLogger == null)
{
instanceLogger = FileLogger.getInstance("logs/console.log", true); instanceLogger = FileLogger.getInstance("logs/console.log", true);
} }
return instanceLogger; return instanceLogger;

View File

@ -74,11 +74,6 @@
<Name>NetMonitorUtils</Name> <Name>NetMonitorUtils</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="network.ini">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="icon.ico" /> <Content Include="icon.ico" />
</ItemGroup> </ItemGroup>

View File

@ -1,6 +0,0 @@
[network1]
Name=Home
Ip=auto
Dns=auto
Wins=auto
Adapter=LAN-Verbindung

View File

@ -5,25 +5,23 @@ using System.Text;
using System.Net.Sockets; using System.Net.Sockets;
using System.Net; using System.Net;
namespace NetMonitorServer namespace NetMonitorServer {
{ abstract class ActionClass {
abstract class ActionClass
{
protected UdpClient outputNetworkStream; protected UdpClient outputNetworkStream;
protected IPEndPoint outputNetworkPort; protected IPEndPoint outputNetworkPort;
internal void SetAnswerStream(UdpClient udpClient, IPEndPoint iPEndPoint) internal void SetAnswerStream(UdpClient udpClient, IPEndPoint iPEndPoint) {
{
this.outputNetworkStream = udpClient; this.outputNetworkStream = udpClient;
this.outputNetworkPort = iPEndPoint; this.outputNetworkPort = iPEndPoint;
} }
abstract internal bool Run(Queue<string> arguments); abstract internal bool Run(Queue<string> arguments);
protected void sendMessage(string message) protected void sendMessage(string message) {
{
Console.WriteLine(message); Console.WriteLine(message);
byte[] answ = Encoding.UTF8.GetBytes(message); byte[] answ = Encoding.UTF8.GetBytes(message);
outputNetworkStream.Send(answ, answ.Length, outputNetworkPort); outputNetworkStream.Send(answ, answ.Length, outputNetworkPort);
} }
protected ServerModel Model = ServerModel.Instance;
} }
} }

View File

@ -5,11 +5,13 @@ using System.Text;
using System.Diagnostics; using System.Diagnostics;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using System.Text.RegularExpressions;
namespace NetMonitorServer namespace NetMonitorServer
{ {
class SetNetworks : ActionClass class SetNetworks : ActionClass
{ {
private string netsh_output = "";
private bool setNetworkWins(Queue<string> data) private bool setNetworkWins(Queue<string> data)
{ {
if (data.Count != 2) if (data.Count != 2)
@ -42,7 +44,7 @@ namespace NetMonitorServer
} }
string ip = data.Dequeue(); string ip = data.Dequeue();
string name = data.Dequeue(); string name = data.Dequeue();
string netsh = "interface ipv4 set dnsservers name=\"" + name + (ip == "auto" ? "\" source=dhcp" : "\" static " + ip + "primary"); string netsh = "interface ipv4 set dnsservers name=\"" + name + (ip == "auto" ? "\" source=dhcp" : "\" static " + ip + " primary");
try try
{ {
this.runProgramNetsh(netsh); this.runProgramNetsh(netsh);
@ -94,7 +96,7 @@ namespace NetMonitorServer
{ {
if (data.Count != 1) if (data.Count != 1)
{ {
this.sendMessage("To less arguments for SetNetworks.setNetworkDns class"); this.sendMessage("To less arguments for SetNetworks.setNetworkAuto class");
return false; return false;
} }
string name = data.Dequeue(); string name = data.Dequeue();
@ -113,8 +115,155 @@ namespace NetMonitorServer
return true; return true;
} }
private bool getNetwork(Queue<string> arguments)
{
if(arguments.Count != 1) {
this.sendMessage("To less arguments for SetNetworks.getNetwork class");
return false;
}
string adapter = arguments.Dequeue();
string ip = "";
string subnet = "";
string gateway = "";
string dns = "";
string wins = "";
try
{
this.runProgramNetsh("interface ipv4 show interfaces");
string[] text = this.netsh_output.Trim().Split('\n');
foreach (string line in text)
{
string l = line.Trim();
if (l == "")
{
continue;
}
if (Regex.IsMatch(l, "disconnected[ ]+"+adapter+"$", RegexOptions.IgnoreCase))
{
this.sendMessage("disconnected");
return true;
}
}
this.runProgramNetsh("interface ipv4 show addresses");
text = this.netsh_output.Trim().Split('\n');
bool match = false;
foreach (string line in text)
{
string l = line.Trim();
if (l == "")
{
continue;
}
if (Regex.IsMatch(l, "^Konfiguration der Schnittstelle", RegexOptions.IgnoreCase))
{
match = false;
}
if (Regex.IsMatch(l, "^[a-z0-9 ]+\""+adapter+"\"", RegexOptions.IgnoreCase))
{
match = true;
}
if (match)
{
if (Regex.IsMatch(l, "DHCP aktiviert:\\s+Ja", RegexOptions.IgnoreCase))
{
ip = "auto";
break;
}
if (Regex.IsMatch(l, "IP-Adresse:\\s+[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+", RegexOptions.IgnoreCase))
{
ip = Regex.Match(l, "[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+").ToString();
}
if (Regex.IsMatch(l, "Subnetzpräfix:\\s+[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\/[0-9]+ \\(Maske [0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\)", RegexOptions.IgnoreCase))
{
subnet = Regex.Match(l, "\\(Maske ([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+)\\)").Groups[1].ToString();
}
if (Regex.IsMatch(l, "Standardgateway:\\s+[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+", RegexOptions.IgnoreCase))
{
gateway = Regex.Match(l, "[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+").ToString();
}
}
}
this.runProgramNetsh("interface ipv4 show dnsservers");
text = this.netsh_output.Trim().Split('\n');
match = false;
foreach (string line in text)
{
string l = line.Trim();
if (l == "")
{
continue;
}
if (Regex.IsMatch(l, "^Konfiguration der Schnittstelle", RegexOptions.IgnoreCase))
{
match = false;
}
if (Regex.IsMatch(l, "^[a-z0-9 ]+\"" + adapter + "\"", RegexOptions.IgnoreCase))
{
match = true;
}
if (match)
{
if (Regex.IsMatch(l, "Über DHCP konfigurierte DNS-Server:\\s+", RegexOptions.IgnoreCase))
{
dns = "auto";
}
if (Regex.IsMatch(l, "Statisch konfigurierte DNS-Server:\\s+[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+", RegexOptions.IgnoreCase))
{
dns = Regex.Match(l, "[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+").ToString();
}
}
}
this.runProgramNetsh("interface ipv4 show winsservers");
text = this.netsh_output.Trim().Split('\n');
match = false;
foreach (string line in text)
{
string l = line.Trim();
if (l == "")
{
continue;
}
if (Regex.IsMatch(l, "^Konfiguration der Schnittstelle", RegexOptions.IgnoreCase))
{
match = false;
}
if (Regex.IsMatch(l, "^[a-z0-9 ]+\"" + adapter + "\"", RegexOptions.IgnoreCase))
{
match = true;
}
if (match)
{
if (Regex.IsMatch(l, "Über DHCP konfigurierte WINS-Server:\\s+", RegexOptions.IgnoreCase))
{
wins = "auto";
}
if (Regex.IsMatch(l, "Statisch konfigurierte WINS-Server:\\s+[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+", RegexOptions.IgnoreCase))
{
wins = Regex.Match(l, "[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+").ToString();
}
}
}
}
catch (Exception e)
{
this.sendMessage(e.Message);
return false;
}
if (ip == "")
{
this.sendMessage("unknown");
return false;
}
this.sendMessage("[" + ip + "|" + subnet + "|" + gateway + "|" + dns + "|" + wins + "]");
return true;
}
private bool runProgramNetsh(string args) private bool runProgramNetsh(string args)
{ {
//Console.WriteLine("netsh args: "+args);
Process p = new Process(); Process p = new Process();
p.StartInfo.Arguments = args; p.StartInfo.Arguments = args;
p.StartInfo.FileName = "netsh"; p.StartInfo.FileName = "netsh";
@ -122,14 +271,14 @@ namespace NetMonitorServer
p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false; p.StartInfo.UseShellExecute = false;
p.Start(); p.Start();
string output = p.StandardOutput.ReadToEnd(); this.netsh_output = p.StandardOutput.ReadToEnd();
p.WaitForExit(); p.WaitForExit();
Console.WriteLine(output.Trim()); //Console.WriteLine(this.netsh_output.Trim());
if (p.ExitCode == 0) if (p.ExitCode == 0)
{ {
return true; return true;
} }
throw new Exception(output.Trim()); throw new Exception(this.netsh_output.Trim());
} }
internal override bool Run(Queue<string> arguments) internal override bool Run(Queue<string> arguments)
{ {
@ -144,8 +293,11 @@ namespace NetMonitorServer
case "ip": return this.setNetworkIp(arguments); case "ip": return this.setNetworkIp(arguments);
case "dns": return this.setNetworkDns(arguments); case "dns": return this.setNetworkDns(arguments);
case "wins": return this.setNetworkWins(arguments); case "wins": return this.setNetworkWins(arguments);
case "network": return this.getNetwork(arguments);
default: this.sendMessage("Wrong arguments for service on SetNetwork class"); return false; default: this.sendMessage("Wrong arguments for service on SetNetwork class"); return false;
} }
} }
} }
} }

View File

@ -2,14 +2,110 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Diagnostics;
using BlubbFish.Utils;
using NetMonitorServer.Controller;
namespace NetMonitorServer namespace NetMonitorServer {
{ class SetOpenVPNService : ActionClass {
class SetOpenVPNService : ActionClass
{ internal override bool Run(Queue<string> arguments) {
internal override bool Run(Queue<string> arguments) if(arguments.Count < 2) {
{ this.sendMessage("To less arguments for SetOpenVpnService class");
throw new NotImplementedException(); return false;
}
switch(arguments.Dequeue().ToLower()) {
case "status":
return this.getVpn(arguments);
case"start":
return this.getVpnStart(arguments);
case"stop":
return this.getVpnStop(arguments);
default:
this.sendMessage("Wrong arguments for service on SetOpenVpnService class");
return false;
}
}
private bool getVpnStop(Queue<string> arguments) {
string config = arguments.Dequeue();
if(Model.openvpnInstances.Keys.Contains(config)) { //schon in der Liste
OpenVpnController o = Model.openvpnInstances[config];
if(o.HasExited) { //läuft nicht! Fehler!
this.sendMessage("Fehler! Openvpn schon beendet! " + config + " Config");
return false;
}
o.Kill();
} else { //Noch nicht in der liste
this.sendMessage("Fehler! Openvpn noch nie gestartet! " + config + " Config");
return false;
}
this.sendMessage("true");
return false;
}
private bool getVpnStart(Queue<string> arguments) {
string config = arguments.Dequeue();
if(Model.openvpnInstances.Keys.Contains(config)) { //schon in der Liste
OpenVpnController o = Model.openvpnInstances[config];
if(!o.HasExited) { //läuft noch! Fehler!
this.sendMessage("Fehler! Openvpn Läuft noch! " + config + " Config");
return false;
}
try {
o.Start();
} catch(Exception e) {
this.sendMessage("Fehler beim Starten von OpenVPN: " + e.Message);
return false;
}
this.sendMessage("true");
return true;
} else { //Noch nicht in der liste
string ovpn = InIReader.getInstance("config.ini").getValue("program", "openvpn");
ovpn = (ovpn.EndsWith("\\")) ? ovpn : ovpn + "\\";
try {
OpenVpnController o = new OpenVpnController(ovpn, config);
Model.openvpnInstances.Add(config, o);
o.Start();
} catch(Exception e) {
this.sendMessage("Fehler beim Starten von OpenVPN: " + e.Message);
return false;
}
this.sendMessage("true");
return true;
}
}
private bool getVpn(Queue<string> arguments) {
if(arguments.Count != 1) {
this.sendMessage("To less arguments for SetOpenVpnService.getVpn class");
return false;
}
string config = arguments.Dequeue();
string run = "";
try {
if(Model.openvpnInstances.Keys.Contains(config)) {
OpenVpnController o = Model.openvpnInstances[config];
if(o.HasExited) {
run = "disconnected";
} else if(o.Conntected) {
run = "connected|" + o.Ip + "|" + o.Dhcp + "|" + o.DhcpLease + "|" + o.IpDate + "|" + o.SuccessDate;
} else {
run = "conntecting";
}
}
} catch(Exception e) {
this.sendMessage(e.Message);
return false;
}
if(run == "") {
this.sendMessage("unknown");
return false;
}
this.sendMessage("[" + run + "]");
return true;
} }
} }
} }

View File

@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.IO;
namespace NetMonitorServer.Controller {
class OpenVpnController {
private Process proc;
public bool HasExited { get; private set; }
public bool Conntected { get; private set; }
public string Error { get; private set; }
public string Ip { get; private set; }
public string Dhcp { get; private set; }
public string DhcpLease { get; private set; }
public string IpDate { get; private set; }
public string SuccessDate { get; private set; }
public OpenVpnController(string path, string config) {
// TODO: Complete member initialization
this.proc = new Process();
this.proc.StartInfo.Arguments = "--config " + config;
this.proc.StartInfo.FileName = path + "bin\\openvpn.exe";
this.proc.StartInfo.WorkingDirectory = path + "config";
this.HasExited = true;
this.Conntected = false;
this.Error = "";
}
private void VpnOutputHandler(object sendingProcess, DataReceivedEventArgs outLine) {
if(!String.IsNullOrEmpty(outLine.Data)) {
string pattern = "^(.*?) N.*?IP/netmask of ([0-9\\./]*).*?DHCP-serv: ([0-9\\.]*).*?lease-time: ([0-9]*)";
Match match = Regex.Match(outLine.Data, pattern);
if(match.Success) {
this.IpDate = match.Groups[1].Value;
this.Ip = match.Groups[2].Value;
this.Dhcp = match.Groups[3].Value;
this.DhcpLease = match.Groups[4].Value;
}
pattern = "^(.*?) Initialization Sequence Completed";
match = Regex.Match(outLine.Data, pattern);
if(match.Success) {
this.SuccessDate = match.Groups[1].Value;
this.Conntected = true;
}
//Console.WriteLine("L: |" + outLine.Data + "|");
}
}
private void VpnErrorHandler(object sendingProcess, DataReceivedEventArgs outLine) {
this.Error += outLine.Data;
}
internal bool Start() {
if(!this.HasExited) {
return false;
}
this.HasExited = false;
this.Conntected = false;
this.Error = "";
this.proc.StartInfo.UseShellExecute = false;
this.proc.StartInfo.RedirectStandardOutput = true;
this.proc.StartInfo.RedirectStandardError = true;
this.proc.StartInfo.RedirectStandardInput = true;
this.proc.OutputDataReceived += new DataReceivedEventHandler(VpnOutputHandler);
this.proc.ErrorDataReceived += new DataReceivedEventHandler(VpnErrorHandler);
this.proc.Start();
this.proc.BeginOutputReadLine();
this.proc.BeginErrorReadLine();
return true;
}
internal bool Kill() {
this.proc.CancelErrorRead();
this.proc.CancelOutputRead();
this.proc.Kill();
this.proc.WaitForExit();
this.HasExited = true;
this.Conntected = false;
return true;
}
}
}

View File

@ -4,17 +4,14 @@ using System.Linq;
using System.Text; using System.Text;
using BlubbFish.Utils; using BlubbFish.Utils;
namespace NetMonitorServer namespace NetMonitorServer {
{ class Factory {
class Factory internal static ActionClass getAction(string className) {
{ if(className.ToLower() == "net")
internal static ActionClass getAction(string className)
{
if (className.Substring(0, 3).ToLower() == "net")
return new SetNetworks(); return new SetNetworks();
if (className.Substring(0, 7).ToLower() == "service") if(className.ToLower() == "service")
return new SetService(); return new SetService();
if (className.Substring(0, 7).ToLower() == "openvpn") if(className.ToLower() == "openvpn")
return new SetOpenVPNService(); return new SetOpenVPNService();
return null; return null;
} }

View File

@ -14,6 +14,21 @@
<TargetFrameworkProfile> <TargetFrameworkProfile>
</TargetFrameworkProfile> </TargetFrameworkProfile>
<FileAlignment>512</FileAlignment> <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>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -43,6 +58,9 @@
<PropertyGroup> <PropertyGroup>
<StartupObject /> <StartupObject />
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration.Install" /> <Reference Include="System.Configuration.Install" />
@ -57,6 +75,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="ActionClass.cs" /> <Compile Include="ActionClass.cs" />
<Compile Include="Controller\OpenVpnController.cs" />
<Compile Include="Factory.cs" /> <Compile Include="Factory.cs" />
<Compile Include="Actions\SetOpenVPNService.cs" /> <Compile Include="Actions\SetOpenVPNService.cs" />
<Compile Include="Actions\SetService.cs" /> <Compile Include="Actions\SetService.cs" />
@ -71,19 +90,13 @@
</Compile> </Compile>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Actions\SetNetworks.cs" /> <Compile Include="Actions\SetNetworks.cs" />
<Compile Include="ServerModel.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="MainService.resx"> <EmbeddedResource Include="MainService.resx">
<DependentUpon>MainService.cs</DependentUpon> <DependentUpon>MainService.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="ClassDiagram1.cd" />
<None Include="config.ini">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="icon.ico" /> <Content Include="icon.ico" />
</ItemGroup> </ItemGroup>
@ -93,6 +106,28 @@
<Name>Utils</Name> <Name>Utils</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </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" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- 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. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -2,8 +2,20 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<StartArguments>-r</StartArguments> <StartArguments>-r</StartArguments>
<StartAction>Program</StartAction>
<StartProgram>D:\Visual Studio 2012\Projects\netmonitor\bin\Debug\NetMonitorServer.exe</StartProgram>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<StartArguments>-r</StartArguments> <StartArguments>-r</StartArguments>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<PublishUrlHistory>veröffentlichen\</PublishUrlHistory>
<InstallUrlHistory />
<SupportUrlHistory />
<UpdateUrlHistory />
<BootstrapperUrlHistory />
<ErrorReportUrlHistory />
<FallbackCulture>de-DE</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
</Project> </Project>

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
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>();
}
/// <summary>
/// Openvpn Instanzen Dictionary
/// </summary>
public Dictionary<string, OpenVpnController> openvpnInstances;
}
}

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!-- <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/> -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC-Manifestoptionen
Wenn Sie die Zugangsebene für das Windows-Benutzerkonto ändern möchten, ersetzen Sie den
requestedExecutionLevel-Knoten durch eines der folgenden Elemente.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Durch Angeben des requestedExecutionLevel-Knotens wird die Datei- und Registrierungsvirtualisierung deaktiviert.
Wenn Sie Datei- und Registrierungsvirtualisierung für Abwärts-
kompatibilität verwenden möchten, löschen Sie den requestedExecutionLevel-Knoten.
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<!-- <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application> -->
<!-- Eine Liste aller Windows-Versionen, mit denen die Anwendung kompatibel ist.
Windows wählt automatisch die am stärksten kompatible Umgebung aus.-->
<!-- Wenn die Anwendung mit Windows Vista kompatibel ist, heben Sie die Auskommentierung des folgenden supportedOS-Knotens auf-->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"></supportedOS>-->
<!-- Wenn die Anwendung mit Windows 7 kompatibel ist, heben Sie die Kommentierung des folgenden supportedOS-Knotens auf.-->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>-->
<!-- Wenn die Anwendung mit Windows 8 kompatibel ist, heben Sie die Auskommentierung des folgenden supportedOS-Knotens auf-->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></supportedOS>-->
<!-- </application>
</compatibility> -->
<!-- Designs für allgemeine Windows-Steuerelemente und -Dialogfelder (Windows XP und höher) aktivieren -->
<!-- <dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>-->
</asmv1:assembly>

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="NetMonitorTray.Controller.Tray">
<Position X="7.75" Y="1" Width="1.5" />
<TypeIdentifier>
<HashCode>ACAAAAAAIAAAAAAIAgEAAAAAAAAAAAIIBEAAAAAAAAI=</HashCode>
<FileName>Controller\ControllerTray.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="NetMonitorTray.Controller.Window" Collapsed="true">
<Position X="0.5" Y="2.5" Width="1.5" />
<TypeIdentifier>
<HashCode>gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIIAAAAAAAAAAg=</HashCode>
<FileName>Controller\ControllerWindow.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="NetMonitorTray.Models.Tray">
<Position X="9.25" Y="1" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAgAAwAAAAABAAAAQAAAIAAAAAIAAEAAg=</HashCode>
<FileName>Models\ModelTray.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="NetMonitorTray.Models.Window" Collapsed="true">
<Position X="2.25" Y="2.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAIAAAAAAAAAAAAAAIAAAAAAAAAAAIgAAQAAAAAACA=</HashCode>
<FileName>Models\ModelWindow.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="NetMonitorTray.Program" Collapsed="true">
<Position X="0.5" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAA=</HashCode>
<FileName>Program.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="NetMonitorTray.Properties.Resources" Collapsed="true">
<Position X="2.25" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>SAACCAAAAAACAAAAEAgBEAAAAQAAAAAAAAAAAAAAAIA=</HashCode>
</TypeIdentifier>
</Class>
<Class Name="NetMonitorTray.View.Tray">
<Position X="6.25" Y="1" Width="1.5" />
<TypeIdentifier>
<HashCode>AAhAQIAAACAAAAAAEAAMAAAEAACAAAIAAAgAAAAEAAQ=</HashCode>
<FileName>Views\ViewTray.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="NetMonitorTray.View.Window" Collapsed="true">
<Position X="4" Y="2.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AQAAAAAAACAAAAAAAAAAAAAAAAAAAAIAAAgAAAAEAAA=</HashCode>
<FileName>Views\ViewWindow.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="NetMonitorTray.View.ViewWindowForm" Collapsed="true">
<Position X="4" Y="1.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAEAAAAACCAAABAAAACAEAECAwAAAAACACAAIIAIBAE=</HashCode>
<FileName>Views\ViewWindowForm.cs</FileName>
</TypeIdentifier>
</Class>
<Font Name="Segoe UI" Size="9" />
</ClassDiagram>

View File

@ -0,0 +1,140 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using NetMonitorUtils;
using BlubbFish.Utils;
namespace NetMonitorTray.Controller {
public class Tray : OwnController {
private static View.Tray tray;
private static OpenVpnSetter vpn;
private static NetworkSetter network;
private static Controller.Window window;
/// <summary>
/// Tray Controller
/// </summary>
public Tray() {
vpn = new OpenVpnSetter("vpn.ini", "config.ini");
network = new NetworkSetter("network.ini", "config.ini");
}
/// <summary>
/// Init!
/// </summary>
override protected void init() {
tray = new View.Tray();
window = new Controller.Window();
tray.setWorkingIcon();
try {
tray.Model.connectedStatus = false;
List<string> vpns = tray.Model.getVpnList();
tray.Model.VpnSelected = vpn.getStatus(vpns);
List<string> adapter = tray.Model.getAdapterList();
tray.Model.NetworkSelected = network.getNetwork(adapter);
} catch(Exception e) {
tray.showError(e.Message);
tray.Model.connectedStatus = false;
}
}
/// <summary>
/// User klickt auf den Eintrag Beenden
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
internal static void Click_Quit(object sender, EventArgs e) {
tray.Dispose();
//Application.ExitThread();
Application.Exit();
}
/// <summary>
/// User klick auf einen Eintrag Service Starten/Stoppen
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
internal static void Click_Vpn(object sender, EventArgs e) {
tray.setWorkingIcon();
string[] conf = ((ToolStripMenuItem)sender).Name.Split('|');
switch(tray.Model.VpnSelected[conf[1]]) {
case "disconnected":
case "unknown":
try {
vpn.setStart(conf[1]);
for(int i = 0; i < 10; i++) {
string status = vpn.getStatus(conf[1]);
if(status.StartsWith("[connected|")) {
tray.Model.VpnSelected[conf[1]] = "connected";
status = status.Substring(0, status.Length - 1).Substring(1);
string[] ip = status.Split('|');
tray.setVpn(true, "Verbunden am: " + ip[5] + "\nmit IP: " + ip[1] + "\nConfig: " + conf[1]);
break;
}
System.Threading.Thread.Sleep(3000);
}
} catch(Exception ex) {
tray.Model.connectedStatus = false;
tray.showError("Fehler beim starten von Openvpn mit " + conf[1] + ": " + ex.Message);
}
break;
case "connected":
try {
vpn.setStop(conf[1]);
for(int i = 0; i < 10; i++) {
string status = vpn.getStatus(conf[1]);
if(status == "[disconnected]") {
tray.Model.VpnSelected[conf[1]] = "disconnected";
tray.setVpn(false, "Config: " + conf[1]);
break;
}
System.Threading.Thread.Sleep(1000);
}
} catch(Exception ex) {
tray.Model.connectedStatus = false;
tray.showError("Fehler beim beenden von Openvpn mit " + conf + ": " + ex.Message);
}
break;
}
}
/// <summary>
/// User klickt Doppelt auf das TrayIcon
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
internal static void Click_Tray(object sender, EventArgs e) {
Click_Open(sender, e);
}
/// <summary>
/// User klickt auf den Tray-Ballon
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
internal static void Click_Ballon(object sender, EventArgs e) {
throw new NotImplementedException();
}
/// <summary>
/// User klickt auf einen Eintrag Netzwerk
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
internal static void Click_Network(object sender, EventArgs e) {
tray.setWorkingIcon();
try {
network.setNetwork(((ToolStripMenuItem)sender).Name);
string n = ((ToolStripMenuItem)sender).Name;
tray.Model.NetworkSelected[n.Split('|')[0]] = n.Split('|')[1];
} catch(Exception ex) {
tray.showError("Fehler beim setzen des Netzwerks: " + ex.Message);
}
}
/// <summary>
/// User klickt auf den Eintrag Öffnen
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
internal static void Click_Open(object sender, EventArgs e) {
window.execute();
}
}
}

View File

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using NetMonitorUtils;
using BlubbFish.Utils;
namespace NetMonitorTray.Controller
{
public class Window : OwnController
{
private static View.Window window;
/// <summary>
/// Tray Controller
/// </summary>
public Window()
{
}
override protected void init()
{
window = new View.Window();
}
public static void FormClosed(object sender, FormClosedEventArgs e)
{
window.Dispose();
}
internal static void NetworkSelected(object sender, EventArgs e)
{
MessageBox.Show("Angeklickt!");
}
}
}

View File

@ -1,84 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace NetMonitorTray.Controller
{
public class Tray
{
private static View.Tray tray;
public Tray()
{
tray = new View.Tray();
}
public void view()
{
Application.Run();
}
/// <summary>
/// User klickt auf den Eintrag Beenden
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
internal static void Click_Quit(object sender, EventArgs e)
{
tray.Dispose();
Application.ExitThread();
}
/// <summary>
/// User klick auf einen Eintrag Service Starten/Stoppen
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
internal static void Click_Service(object sender, EventArgs e)
{
throw new NotImplementedException();
//tray.showError("Fehler beim Starten/Stoppen von Service!");
/*switch (((ToolStripMenuItem)sender).Name)
{
case "StartService": tray.setService(true); break;
case "StopService": tray.setService(false); break;
}*/
}
/// <summary>
/// User klickt Doppelt auf das TrayIcon
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
internal static void Click_Tray(object sender, EventArgs e)
{
//Doppelklick auf das Trayicon
throw new NotImplementedException();
}
/// <summary>
/// User klickt auf den Tray-Ballon
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
internal static void Click_Ballon(object sender, EventArgs e)
{
throw new NotImplementedException();
}
/// <summary>
/// User klickt auf einen Eintrag Netzwerk
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
internal static void Click_Network(object sender, EventArgs e)
{
throw new NotImplementedException();
}
/// <summary>
/// User klickt auf den Eintrag Öffnen
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
internal static void Click_Open(object sender, EventArgs e)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,104 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using NetMonitorTray.Properties;
using BlubbFish.Utils;
namespace NetMonitorTray.Models {
public class Tray : OwnModel<Tray> {
private InIReader networks;
private InIReader vpns;
private Tray() {
this.init();
}
override protected void init() {
this.networks = InIReader.getInstance("network.ini");
this.vpns = InIReader.getInstance("vpn.ini");
}
internal Dictionary<string, Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>>> getMenuNetwork() {
Dictionary<string, Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>>> ret = new Dictionary<string, Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>>>();
List<String> l = this.networks.getSections();
foreach(String name in l) {
String adapter = this.networks.getValue(name, "Adapter");
if(ret.Keys.Contains(adapter)) {
ret[adapter].Add(adapter + "|" + name, new Tuple<string, System.Drawing.Bitmap, bool, bool>("Netzwerk " + this.networks.getValue(name, "Name"), Properties.Resources.MenuImagesNetwork, true, (this.NetworkSelected.Keys.Contains(adapter) && this.NetworkSelected[adapter] == name)));
} else {
Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>> tmp = new Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>>();
tmp.Add(adapter + "|" + name, new Tuple<string, System.Drawing.Bitmap, bool, bool>("Netzwerk " + this.networks.getValue(name, "Name"), Properties.Resources.MenuImagesNetwork, true, (this.NetworkSelected.Keys.Contains(adapter) && this.NetworkSelected[adapter] == name)));
ret.Add(adapter, tmp);
}
}
return ret;
}
internal Dictionary<string, Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>>> getMenuVpn() {
Dictionary<string, Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>>> ret = new Dictionary<string, Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>>>();
List<String> l = this.vpns.getSections();
Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>> tmp = new Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>>();
foreach(String vpn in l) {
String name = this.vpns.getValue(vpn, "Name");
String conf = this.vpns.getValue(vpn, "Config");
tmp.Add(vpn + "|" + conf, new Tuple<string, System.Drawing.Bitmap, bool, bool>("VPN " + name, Properties.Resources.MenuImagesOpenvpn, true, (this.VpnSelected.Keys.Contains(conf) && this.VpnSelected[conf] == "connected")));
}
ret.Add("OpenVpn", tmp);
return ret;
}
private bool connectedStatusValue = false;
internal bool connectedStatus {
get { return connectedStatusValue; }
set { connectedStatusValue = value; this.update(); }
}
private Dictionary<String, String> VpnSelectedValue = new Dictionary<string, string>();
/// <summary>
/// Item1 = configfile
/// Item2 = status ("unknown";"connected";"disconnected")
/// </summary>
internal Dictionary<String, String> VpnSelected {
get { return VpnSelectedValue; }
set { VpnSelectedValue = value; this.update(); }
}
private Dictionary<String, String> networkSelectedValue = new Dictionary<string, string>();
/// <summary>
/// Item1 = adapter
/// Item2 = network
/// </summary>
public Dictionary<String, String> NetworkSelected {
get { return networkSelectedValue; }
set { networkSelectedValue = value; this.update(); }
}
internal List<string> getAdapterList() {
List<String> ret = new List<string>();
List<String> l = this.networks.getSections();
foreach(String name in l) {
String adapter = this.networks.getValue(name, "Adapter");
if(!ret.Contains(adapter)) {
ret.Add(adapter);
}
}
return ret;
}
internal List<string> getVpnList() {
List<String> ret = new List<string>();
List<String> l = this.vpns.getSections();
foreach(String name in l) {
String adapter = this.vpns.getValue(name, "Config");
if(!ret.Contains(adapter)) {
ret.Add(adapter);
}
}
return ret;
}
}
}

View File

@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using NetMonitorTray.Properties;
using BlubbFish.Utils;
namespace NetMonitorTray.Models
{
public class Window : OwnModel<Window>
{
private InIReader networkfile;
private Window()
{
this.init();
}
override protected void init()
{
this.networkfile = InIReader.getInstance("network.ini");
}
/// <summary>
/// Listet alle Netzwerke auf
/// </summary>
public List<string> Networks
{
get { return this.networkfile.getSections(); }
}
public string getNetworkProperty(string network, string property)
{
return this.networkfile.getValue(network, property);
}
/// <summary>
/// Fügt ein neues Netzwerk hinzu
/// </summary>
/// <param name="name">Netzwerkid</param>
/// <returns>true if added, false if error</returns>
public bool addNetwork(string name)
{
if (this.networkfile.addSection(name))
{
this.update();
return true;
}
return false;
}
/// <summary>
/// Löscht ein Netzwerk
/// </summary>
/// <param name="name">Netzwerkid</param>
/// <returns>true if deleted, false if error</returns>
public bool removeNetwork(string name)
{
if (this.networkfile.removeSection(name))
{
this.update();
return true;
}
return false;
}
}
}

View File

@ -1,49 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using NetMonitorTray.Properties;
using BlubbFish.Utils;
namespace NetMonitorTray.Model
{
public class Tray : OwnModel<Tray>
{
private bool serviceRun;
private Tray()
{
this.init();
}
private void init()
{
this.serviceRun = false;
}
internal Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>> getMenuNetwork()
{
Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>> ret = new Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>>();
ret.Add("network1", new Tuple<string, System.Drawing.Bitmap, bool, bool>("Netzwerk Home", null, true, false));
ret.Add("network2", new Tuple<string, System.Drawing.Bitmap, bool, bool>("Netzwerk Arbeit", null, true, false));
ret.Add("network3", new Tuple<string, System.Drawing.Bitmap, bool, bool>("Netzwerk Test", null, true, false));
return ret;
}
internal Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>> getMenuOpenVpnService()
{
Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>> ret = new Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>>();
ret.Add("StartService", new Tuple<string, System.Drawing.Bitmap, bool, bool>("Service Starten", Properties.Resources.MenuImagesServerConnect, !this.serviceRun, !this.serviceRun));
ret.Add("StopService", new Tuple<string, System.Drawing.Bitmap, bool, bool>("Service Stoppen", Properties.Resources.MenuImagesServerDisconnect, this.serviceRun, this.serviceRun));
return ret;
}
public void setService(bool run)
{
this.serviceRun = run;
this.update();
}
}
}

View File

@ -5,7 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{0B85C838-3295-4FDA-9B07-4F5B3681BE2F}</ProjectGuid> <ProjectGuid>{0B85C838-3295-4FDA-9B07-4F5B3681BE2F}</ProjectGuid>
<OutputType>Exe</OutputType> <OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NetMonitorTray</RootNamespace> <RootNamespace>NetMonitorTray</RootNamespace>
<AssemblyName>NetMonitorTray</AssemblyName> <AssemblyName>NetMonitorTray</AssemblyName>
@ -52,8 +52,10 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Controller\Tray.cs" /> <Compile Include="Controller\ControllerTray.cs" />
<Compile Include="Models\Tray.cs" /> <Compile Include="Controller\ControllerWindow.cs" />
<Compile Include="Models\ModelWindow.cs" />
<Compile Include="Models\ModelTray.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs"> <Compile Include="Properties\Resources.Designer.cs">
@ -61,13 +63,22 @@
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\Tray.cs" /> <Compile Include="Views\ViewWindowForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Views\ViewWindowForm.Designer.cs">
<DependentUpon>ViewWindowForm.cs</DependentUpon>
</Compile>
<Compile Include="Views\ViewWindow.cs" />
<Compile Include="Views\ViewTray.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="icon.ico" /> <Content Include="icon.ico" />
<Content Include="Resources\Icons\door_open.png" /> <Content Include="Resources\Icons\door_open.png" />
<Content Include="Resources\Icons\server_connect.png" /> <Content Include="Resources\Icons\server_connect.png" />
<Content Include="Resources\Icons\server_delete.png" /> <Content Include="Resources\Icons\server_delete.png" />
<Content Include="Resources\Icons\server_link.png" />
<None Include="Resources\Icons\world_link.png" />
<Content Include="Resources\working.ico" /> <Content Include="Resources\working.ico" />
<Content Include="Resources\nothing.ico" /> <Content Include="Resources\nothing.ico" />
<Content Include="Resources\connected.ico" /> <Content Include="Resources\connected.ico" />
@ -77,14 +88,23 @@
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Views\ViewWindowForm.resx">
<DependentUpon>ViewWindowForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\Utils\Utils\Utils.csproj"> <ProjectReference Include="..\..\Utils\Utils\Utils.csproj">
<Project>{fac8ce64-bf13-4ece-8097-aeb5dd060098}</Project> <Project>{fac8ce64-bf13-4ece-8097-aeb5dd060098}</Project>
<Name>Utils</Name> <Name>Utils</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\NetMonitorUtils\NetMonitorUtils.csproj">
<Project>{45ee003d-5572-48fe-b90e-6bfe18d9eec8}</Project>
<Name>NetMonitorUtils</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="ClassDiagram1.cd" />
</ItemGroup> </ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- 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. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms;
namespace NetMonitorTray namespace NetMonitorTray
@ -12,7 +13,8 @@ namespace NetMonitorTray
static void Main(string[] args) static void Main(string[] args)
{ {
Controller.Tray t = new Controller.Tray(); Controller.Tray t = new Controller.Tray();
t.view(); t.execute();
Application.Run();
} }
} }
} }

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// Dieser Code wurde von einem Tool generiert. // Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.18444 // Laufzeitversion:4.0.30319.34209
// //
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird. // der Code erneut generiert wird.
@ -90,6 +90,26 @@ namespace NetMonitorTray.Properties {
} }
} }
/// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap MenuImagesNetwork {
get {
object obj = ResourceManager.GetObject("MenuImagesNetwork", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap MenuImagesOpenvpn {
get {
object obj = ResourceManager.GetObject("MenuImagesOpenvpn", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary> /// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
/// </summary> /// </summary>

View File

@ -127,6 +127,12 @@
<data name="IconWorking" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="IconWorking" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\working.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\working.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="MenuImagesNetwork" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Icons\server_link.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="MenuImagesOpenvpn" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\icons\world_link.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="MenuImagesQuit" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="MenuImagesQuit" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Icons\door_open.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\Icons\door_open.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>

Binary file not shown.

After

Width:  |  Height:  |  Size: 706 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 957 B

View File

@ -13,27 +13,31 @@ namespace NetMonitorTray.View
public class Tray : OwnView public class Tray : OwnView
{ {
private NotifyIcon trayi; private NotifyIcon trayi;
private Dictionary<string, Tuple<string, Bitmap, bool, bool>> menuOpenVpnService; private Dictionary<string, Dictionary<string, Tuple<string, Bitmap, bool, bool>>> menuVpn;
private Dictionary<string, Tuple<string, Bitmap, bool, bool>> menuNetwork; private Dictionary<string, Dictionary<string, Tuple<string, Bitmap, bool, bool>>> menuNetwork;
private Icon[] iconlist = { new Icon(Resources.IconNothing, 40, 40), new Icon(Resources.IconWorking, 40, 40), new Icon(Resources.IconConnected, 40, 40) };
public Tray() public Tray()
{ {
this.initIcon(); this.init();
Model.Tray.Instance.setObserver(this); this.Model = Models.Tray.Instance;
this.Model.setObserver(this);
} }
public override void update() public override void update()
{ {
this.menuOpenVpnService = Model.Tray.Instance.getMenuOpenVpnService(); this.menuVpn = this.Model.getMenuVpn();
this.menuNetwork = Model.Tray.Instance.getMenuNetwork(); this.menuNetwork = this.Model.getMenuNetwork();
this.trayi.ContextMenuStrip = this.genMenu(); this.trayi.ContextMenuStrip = this.genMenu();
this.trayi.Icon = (this.Model.connectedStatus ? this.iconlist[2] : this.iconlist[0]);
} }
private void initIcon() override protected void init()
{ {
this.trayi = new NotifyIcon(); this.trayi = new NotifyIcon();
this.trayi.Visible = true; this.trayi.Visible = true;
this.trayi.Icon = new Icon(Resources.IconNothing, 40, 40); this.trayi.Icon = this.iconlist[0];
this.trayi.Text = "NetMonitorTray"; this.trayi.Text = "NetMonitorTray";
this.trayi.DoubleClick += Controller.Tray.Click_Tray; this.trayi.DoubleClick += Controller.Tray.Click_Tray;
this.trayi.BalloonTipClicked += Controller.Tray.Click_Ballon; this.trayi.BalloonTipClicked += Controller.Tray.Click_Ballon;
@ -48,10 +52,15 @@ namespace NetMonitorTray.View
m1.Name = "Open"; m1.Name = "Open";
menu.Items.Add(m1); menu.Items.Add(m1);
menu.Items.Add(new ToolStripSeparator()); menu.Items.Add(new ToolStripSeparator());
menu.Items.AddRange(this.genMenuIt(this.menuNetwork, Controller.Tray.Click_Network)); foreach (String adapter in this.menuNetwork.Keys)
{
menu.Items.AddRange(this.genMenuIt(this.menuNetwork[adapter], Controller.Tray.Click_Network));
menu.Items.Add(new ToolStripSeparator()); menu.Items.Add(new ToolStripSeparator());
menu.Items.AddRange(this.genMenuIt(this.menuOpenVpnService, Controller.Tray.Click_Service)); }
foreach(String adapter in this.menuVpn.Keys) {
menu.Items.AddRange(this.genMenuIt(this.menuVpn[adapter], Controller.Tray.Click_Vpn));
menu.Items.Add(new ToolStripSeparator()); menu.Items.Add(new ToolStripSeparator());
}
ToolStripMenuItem m2 = new ToolStripMenuItem("Beenden"); ToolStripMenuItem m2 = new ToolStripMenuItem("Beenden");
m2.Image = Resources.MenuImagesQuit; m2.Image = Resources.MenuImagesQuit;
m2.Click += Controller.Tray.Click_Quit; m2.Click += Controller.Tray.Click_Quit;
@ -90,21 +99,28 @@ namespace NetMonitorTray.View
this.trayi.ShowBalloonTip(100); this.trayi.ShowBalloonTip(100);
} }
internal void Dispose() override public void Dispose()
{ {
this.trayi.Visible = false; this.trayi.Visible = false;
Application.ExitThread(); Application.ExitThread();
} }
internal void setService(bool run) internal void setVpn(bool run, string ip)
{ {
this.showBallonTooltip((run ? "Service erfolgreich gestartet." : "Service erfolgreich beendet"), ToolTipIcon.Info); this.showBallonTooltip((run ? "OpenVpn erfolgreich gestartet.\n"+ip : "OpenVpn erfolgreich beendet\n"+ip), ToolTipIcon.Info);
Model.Tray.Instance.setService(run); this.Model.connectedStatus = run;
} }
internal void showError(string text) internal void showError(string text)
{ {
this.showBallonTooltip(text, ToolTipIcon.Error); this.showBallonTooltip(text, ToolTipIcon.Error);
} }
public Models.Tray Model { get; private set; }
internal void setWorkingIcon()
{
this.trayi.Icon = this.iconlist[1];
}
} }
} }

View File

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing;
using NetMonitorTray.Properties;
using BlubbFish.Utils;
namespace NetMonitorTray.View
{
public class Window : OwnView
{
private ViewWindowForm form;
public Window()
{
this.form = new ViewWindowForm();
this.init();
this.Model.setObserver(this);
}
public override void update()
{
this.form.UpdateForm();
}
protected override void init()
{
this.Model = Models.Window.Instance;
this.form.SetModel(this.Model);
this.form.Show();
}
public override void Dispose()
{
this.form.BeginInvoke((Action)(() =>
{
this.form.Dispose();
}));
}
public Models.Window Model { get; private set; }
}
}

View File

@ -0,0 +1,209 @@
namespace NetMonitorTray.View
{
partial class ViewWindowForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.networks = new System.Windows.Forms.TabPage();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.listView1 = new System.Windows.Forms.ListView();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.buttonNetworkAdd = new System.Windows.Forms.Button();
this.openvpn = new System.Windows.Forms.TabPage();
this.global = new System.Windows.Forms.TabPage();
this.label1 = new System.Windows.Forms.Label();
this.logBox = new System.Windows.Forms.TextBox();
this.tabControl1.SuspendLayout();
this.networks.SuspendLayout();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// statusStrip1
//
this.statusStrip1.Location = new System.Drawing.Point(0, 336);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(780, 22);
this.statusStrip1.SizingGrip = false;
this.statusStrip1.TabIndex = 0;
this.statusStrip1.Text = "statusStrip1";
//
// tabControl1
//
this.tabControl1.Controls.Add(this.networks);
this.tabControl1.Controls.Add(this.openvpn);
this.tabControl1.Controls.Add(this.global);
this.tabControl1.Location = new System.Drawing.Point(12, 12);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(591, 321);
this.tabControl1.TabIndex = 1;
//
// networks
//
this.networks.Controls.Add(this.groupBox2);
this.networks.Controls.Add(this.groupBox1);
this.networks.Location = new System.Drawing.Point(4, 22);
this.networks.Name = "networks";
this.networks.Padding = new System.Windows.Forms.Padding(3);
this.networks.Size = new System.Drawing.Size(583, 295);
this.networks.TabIndex = 0;
this.networks.Text = "Netzwerke";
this.networks.UseVisualStyleBackColor = true;
//
// groupBox2
//
this.groupBox2.Location = new System.Drawing.Point(189, 6);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(388, 283);
this.groupBox2.TabIndex = 3;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "groupBox2";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.listView1);
this.groupBox1.Controls.Add(this.buttonNetworkAdd);
this.groupBox1.Location = new System.Drawing.Point(6, 6);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(177, 283);
this.groupBox1.TabIndex = 2;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "groupBox1";
//
// listView1
//
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2});
this.listView1.FullRowSelect = true;
this.listView1.GridLines = true;
this.listView1.HideSelection = false;
this.listView1.Location = new System.Drawing.Point(7, 19);
this.listView1.MultiSelect = false;
this.listView1.Name = "listView1";
this.listView1.ShowGroups = false;
this.listView1.Size = new System.Drawing.Size(164, 226);
this.listView1.TabIndex = 2;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "ID";
//
// columnHeader2
//
this.columnHeader2.Text = "Label";
this.columnHeader2.Width = 100;
//
// buttonNetworkAdd
//
this.buttonNetworkAdd.Location = new System.Drawing.Point(7, 251);
this.buttonNetworkAdd.Name = "buttonNetworkAdd";
this.buttonNetworkAdd.Size = new System.Drawing.Size(164, 23);
this.buttonNetworkAdd.TabIndex = 1;
this.buttonNetworkAdd.Text = "Netzwerk Hinzufügen";
this.buttonNetworkAdd.UseVisualStyleBackColor = true;
//
// openvpn
//
this.openvpn.Location = new System.Drawing.Point(4, 22);
this.openvpn.Name = "openvpn";
this.openvpn.Padding = new System.Windows.Forms.Padding(3);
this.openvpn.Size = new System.Drawing.Size(583, 295);
this.openvpn.TabIndex = 1;
this.openvpn.Text = "OpenVPN";
this.openvpn.UseVisualStyleBackColor = true;
//
// global
//
this.global.Location = new System.Drawing.Point(4, 22);
this.global.Name = "global";
this.global.Size = new System.Drawing.Size(583, 295);
this.global.TabIndex = 2;
this.global.Text = "Einstellungen";
this.global.UseVisualStyleBackColor = true;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(609, 12);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(35, 13);
this.label1.TabIndex = 2;
this.label1.Text = "label1";
//
// logBox
//
this.logBox.Location = new System.Drawing.Point(609, 34);
this.logBox.Multiline = true;
this.logBox.Name = "logBox";
this.logBox.Size = new System.Drawing.Size(163, 295);
this.logBox.TabIndex = 3;
//
// ViewWindowForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(780, 358);
this.Controls.Add(this.logBox);
this.Controls.Add(this.label1);
this.Controls.Add(this.tabControl1);
this.Controls.Add(this.statusStrip1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "ViewWindowForm";
this.Text = "NetMonitorTray";
this.tabControl1.ResumeLayout(false);
this.networks.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage networks;
private System.Windows.Forms.TabPage openvpn;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox logBox;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button buttonNetworkAdd;
private System.Windows.Forms.TabPage global;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
}
}

View File

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace NetMonitorTray.View
{
public partial class ViewWindowForm : Form
{
private Models.Window model;
public ViewWindowForm()
{
InitializeComponent();
this.FormClosed += Controller.Window.FormClosed;
listView1.ItemActivate += Controller.Window.NetworkSelected;
}
public void UpdateForm()
{
this.BeginInvoke((Action)(() =>
{
this.logBox.Text = "Loaded";
List<string> networks = this.model.Networks;
foreach(string network in networks) {
ListViewItem item = new ListViewItem();
item.Text = network;
item.SubItems.Add(this.model.getNetworkProperty(network, "Name"));
listView1.Items.Add(item);
}
}));
}
public void SetModel(Models.Window window)
{
this.model = window;
}
}
}

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -46,6 +46,7 @@
<Compile Include="NetworkSetter.cs" /> <Compile Include="NetworkSetter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ServiceControl.cs" /> <Compile Include="ServiceControl.cs" />
<Compile Include="OpenVpnSetter.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\Utils\Utils\Utils.csproj"> <ProjectReference Include="..\..\Utils\Utils\Utils.csproj">
@ -53,6 +54,17 @@
<Name>Utils</Name> <Name>Utils</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="config.ini">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="network.ini">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="vpn.ini">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- 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. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -29,8 +29,8 @@ namespace NetMonitorUtils
} }
public bool setNetwork(string networkName) public bool setNetwork(string networkName)
{ {
this.addLog("setNetwork", "Setze Netzwerkeinstellungen: " + networkName, LogLevel.Info); this.addLog("NetworkSetter.setNetwork", "Setze Netzwerkeinstellungen: " + networkName, LogLevel.Info);
this.addLog("setNetwork", "networkName: " + networkName + ";", LogLevel.Debug); this.addLog("NetworkSetter.setNetwork", "networkName: " + networkName + ";", LogLevel.Debug);
String name = networkini.getValue(networkName, "Name"); String name = networkini.getValue(networkName, "Name");
String ip = networkini.getValue(networkName, "Ip"); String ip = networkini.getValue(networkName, "Ip");
String subnet = networkini.getValue(networkName, "Subnet"); String subnet = networkini.getValue(networkName, "Subnet");
@ -38,100 +38,100 @@ namespace NetMonitorUtils
String dns = networkini.getValue(networkName, "Dns"); String dns = networkini.getValue(networkName, "Dns");
String wins = networkini.getValue(networkName, "Wins"); String wins = networkini.getValue(networkName, "Wins");
String adapter = networkini.getValue(networkName, "Adapter"); String adapter = networkini.getValue(networkName, "Adapter");
this.addLog("setNetwork", "name: " + name, LogLevel.Debug); this.addLog("NetworkSetter.setNetwork", "name: " + name, LogLevel.Debug);
this.addLog("setNetwork", "ip: " + ip, LogLevel.Debug); this.addLog("NetworkSetter.setNetwork", "ip: " + ip, LogLevel.Debug);
this.addLog("setNetwork", "subnet: " + subnet, LogLevel.Debug); this.addLog("NetworkSetter.setNetwork", "subnet: " + subnet, LogLevel.Debug);
this.addLog("setNetwork", "gateway: " + gateway, LogLevel.Debug); this.addLog("NetworkSetter.setNetwork", "gateway: " + gateway, LogLevel.Debug);
this.addLog("setNetwork", "dns: " + dns, LogLevel.Debug); this.addLog("NetworkSetter.setNetwork", "dns: " + dns, LogLevel.Debug);
this.addLog("setNetwork", "wins: " + wins, LogLevel.Debug); this.addLog("NetworkSetter.setNetwork", "wins: " + wins, LogLevel.Debug);
this.addLog("setNetwork", "adapter: " + adapter, LogLevel.Debug); this.addLog("NetworkSetter.setNetwork", "adapter: " + adapter, LogLevel.Debug);
bool ret = false; bool ret = false;
if (ip.ToLower() == "auto" && dns.ToLower() == "auto" && wins.ToLower() == "auto") if (ip.ToLower() == "auto" && dns.ToLower() == "auto" && wins.ToLower() == "auto")
{ {
ret = setNetworkAuto(adapter, name); ret = setNetworkAuto(adapter, name);
this.addLog("setNetwork.setNetworkAuto", "return " + ret, LogLevel.Debug); this.addLog("NetworkSetter.setNetwork.setNetworkAuto", "return " + ret, LogLevel.Debug);
} }
else else
{ {
if (ip.ToLower() == "auto") if (ip.ToLower() == "auto")
{ {
ret = setNetworkIpAuto(adapter, name); ret = setNetworkIpAuto(adapter, name);
this.addLog("setNetwork.setNetworkIpAuto", "return " + ret, LogLevel.Debug); this.addLog("NetworkSetter.setNetwork.setNetworkIpAuto", "return " + ret, LogLevel.Debug);
} }
else else
{ {
ret = setNetworkIp(ip, subnet, gateway, adapter, name); ret = setNetworkIp(ip, subnet, gateway, adapter, name);
this.addLog("setNetwork.setNetworkIp", "return " + ret, LogLevel.Debug); this.addLog("NetworkSetter.setNetwork.setNetworkIp", "return " + ret, LogLevel.Debug);
} }
if (dns.ToLower() == "auto") if (dns.ToLower() == "auto")
{ {
ret = setNetworkDnsAuto(adapter, name); ret = setNetworkDnsAuto(adapter, name);
this.addLog("setNetwork.setNetworkDnsAuto", "return " + ret, LogLevel.Debug); this.addLog("NetworkSetter.setNetwork.setNetworkDnsAuto", "return " + ret, LogLevel.Debug);
} }
else else
{ {
ret = setNetworkDns(dns, adapter, name); ret = setNetworkDns(dns, adapter, name);
this.addLog("setNetwork.setNetworkDns", "return " + ret, LogLevel.Debug); this.addLog("NetworkSetter.setNetwork.setNetworkDns", "return " + ret, LogLevel.Debug);
} }
if (wins.ToLower() == "auto") if (wins.ToLower() == "auto")
{ {
ret = setNetworkWinsAuto(adapter, name); ret = setNetworkWinsAuto(adapter, name);
this.addLog("setNetwork.setNetworkWinsAuto", "return " + ret, LogLevel.Debug); this.addLog("NetworkSetter.setNetwork.setNetworkWinsAuto", "return " + ret, LogLevel.Debug);
} }
else else
{ {
ret = setNetworkWins(wins, adapter, name); ret = setNetworkWins(wins, adapter, name);
this.addLog("setNetwork.setNetworkWins", "return " + ret, LogLevel.Debug); this.addLog("NetworkSetter.setNetwork.setNetworkWins", "return " + ret, LogLevel.Debug);
} }
} }
this.addLog("setNetwork", "return " + ret, LogLevel.Debug); this.addLog("NetworkSetter.setNetwork", "return " + ret, LogLevel.Debug);
return ret; return ret;
} }
public bool setNetworkAuto(string adapter, string name) public bool setNetworkAuto(string adapter, string name)
{ {
this.addLog("setNetworkAuto", "Setze Netzwerkeinstellungen von " + adapter + " auf Automatisch", LogLevel.Info); this.addLog("NetworkSetter.setNetworkAuto", "Setze Netzwerkeinstellungen von " + adapter + " auf Automatisch", LogLevel.Info);
this.addLog("setNetworkAuto", "datapter: " + adapter + "; name: " + name + ";", LogLevel.Debug); this.addLog("NetworkSetter.setNetworkAuto", "datapter: " + adapter + "; name: " + name + ";", LogLevel.Debug);
return setNetwork(netsetterType.Auto, null, null, null, adapter, name, null, null); return setNetwork(netsetterType.Auto, null, null, null, adapter, name, null, null);
} }
public bool setNetworkIpAuto(string adapter, string name) public bool setNetworkIpAuto(string adapter, string name)
{ {
this.addLog("setNetworkIpAuto", "Setze Netzwerkeinstellungen von " + adapter + " auf IP Automatisch", LogLevel.Info); this.addLog("NetworkSetter.setNetworkIpAuto", "Setze Netzwerkeinstellungen von " + adapter + " auf IP Automatisch", LogLevel.Info);
this.addLog("setNetworkIpAuto", "adapter: " + adapter + "; name: " + name + ";", LogLevel.Debug); this.addLog("NetworkSetter.setNetworkIpAuto", "adapter: " + adapter + "; name: " + name + ";", LogLevel.Debug);
return setNetwork(netsetterType.IpAuto, null, null, null, adapter, name, null, null); return setNetwork(netsetterType.IpAuto, null, null, null, adapter, name, null, null);
} }
public bool setNetworkIp(string ip, string subnet, string gateway, string adapter, string name) public bool setNetworkIp(string ip, string subnet, string gateway, string adapter, string name)
{ {
this.addLog("setNetworkIp", "Setze Netzwerkeinstellungen von " + adapter + " auf IP " + ip + "/" + subnet + " GW " + gateway, LogLevel.Info); this.addLog("NetworkSetter.setNetworkIp", "Setze Netzwerkeinstellungen von " + adapter + " auf IP " + ip + "/" + subnet + " GW " + gateway, LogLevel.Info);
this.addLog("setNetworkIp", "ip: " + ip + "; subnet: " + subnet + "; gateway: " + gateway + "; adapter: " + adapter + "; name: " + name + ";", LogLevel.Debug); this.addLog("NetworkSetter.setNetworkIp", "ip: " + ip + "; subnet: " + subnet + "; gateway: " + gateway + "; adapter: " + adapter + "; name: " + name + ";", LogLevel.Debug);
return setNetwork(netsetterType.Ip, ip, subnet, gateway, adapter, name, null, null); return setNetwork(netsetterType.Ip, ip, subnet, gateway, adapter, name, null, null);
} }
public bool setNetworkDnsAuto(string adapter, string name) public bool setNetworkDnsAuto(string adapter, string name)
{ {
this.addLog("setNetworkDnsAuto", "Setze Netzwerkeinstellungen von " + adapter + " auf Dns Automatisch", LogLevel.Info); this.addLog("NetworkSetter.setNetworkDnsAuto", "Setze Netzwerkeinstellungen von " + adapter + " auf Dns Automatisch", LogLevel.Info);
this.addLog("setNetworkDnsAuto", "adapter: " + adapter + "; name: " + name + ";", LogLevel.Debug); this.addLog("NetworkSetter.setNetworkDnsAuto", "adapter: " + adapter + "; name: " + name + ";", LogLevel.Debug);
return setNetwork(netsetterType.DnsAuto, null, null, null, adapter, name, null, null); return setNetwork(netsetterType.DnsAuto, null, null, null, adapter, name, null, null);
} }
public bool setNetworkDns(string dns, string adapter, string name) public bool setNetworkDns(string dns, string adapter, string name)
{ {
this.addLog("setNetworkDns", "Setze Netzwerkeinstellungen von " + adapter + " auf Dns " + dns, LogLevel.Info); this.addLog("NetworkSetter.setNetworkDns", "Setze Netzwerkeinstellungen von " + adapter + " auf Dns " + dns, LogLevel.Info);
this.addLog("setNetworkDns", "dns: " + dns + "; adapter: " + adapter + "; name: " + name + ";", LogLevel.Debug); this.addLog("NetworkSetter.setNetworkDns", "dns: " + dns + "; adapter: " + adapter + "; name: " + name + ";", LogLevel.Debug);
return setNetwork(netsetterType.Dns, null, null, null, adapter, name, dns, null); return setNetwork(netsetterType.Dns, null, null, null, adapter, name, dns, null);
} }
public bool setNetworkWinsAuto(string adapter, string name) public bool setNetworkWinsAuto(string adapter, string name)
{ {
this.addLog("setNetworkWinsAuto", "Setze Netzwerkeinstellungen von " + adapter + " auf Wins Automatisch", LogLevel.Info); this.addLog("NetworkSetter.setNetworkWinsAuto", "Setze Netzwerkeinstellungen von " + adapter + " auf Wins Automatisch", LogLevel.Info);
this.addLog("setNetworkWinsAuto", "adapter: " + adapter + "; name: " + name + ";", LogLevel.Debug); this.addLog("NetworkSetter.setNetworkWinsAuto", "adapter: " + adapter + "; name: " + name + ";", LogLevel.Debug);
return setNetwork(netsetterType.WinsAuto, null, null, null, adapter, name, null, null); return setNetwork(netsetterType.WinsAuto, null, null, null, adapter, name, null, null);
} }
public bool setNetworkWins(string wins, string adapter, string name) public bool setNetworkWins(string wins, string adapter, string name)
{ {
this.addLog("setNetworkWins", "Setze Netzwerkeinstellungen von " + adapter + " auf Wins " + wins, LogLevel.Info); this.addLog("NetworkSetter.setNetworkWins", "Setze Netzwerkeinstellungen von " + adapter + " auf Wins " + wins, LogLevel.Info);
this.addLog("setNetworkWins", "wins: " + wins + "; adapter: " + adapter + "; name: " + name + ";", LogLevel.Debug); this.addLog("NetworkSetter.setNetworkWins", "wins: " + wins + "; adapter: " + adapter + "; name: " + name + ";", LogLevel.Debug);
return setNetwork(netsetterType.Wins, null, null, null, adapter, name, null, wins); return setNetwork(netsetterType.Wins, null, null, null, adapter, name, null, wins);
} }
private bool setNetwork(netsetterType option, string ip, string subnet, string gateway, string adapter, string name, string dns, string wins) private bool setNetwork(netsetterType option, string ip, string subnet, string gateway, string adapter, string name, string dns, string wins)
{ {
this.addLog("setNetwork", "option: " + option + "; ip: " + ip + "; subnet: " + subnet + "; gateway: " + gateway + "; adapter: " + adapter + "; name: " + name + "; dns: " + dns + "; wins: " + wins + ";", LogLevel.Debug); this.addLog("NetworkSetter.setNetwork", "option: " + option + "; ip: " + ip + "; subnet: " + subnet + "; gateway: " + gateway + "; adapter: " + adapter + "; name: " + name + "; dns: " + dns + "; wins: " + wins + ";", LogLevel.Debug);
bool status = false; bool status = false;
try try
{ {
@ -173,10 +173,80 @@ namespace NetMonitorUtils
} }
catch (Exception e) catch (Exception e)
{ {
this.addLog("setNetwork", "Fehler beim Ausführen des Befehls: " + e.Message, LogLevel.Error); this.addLog("NetworkSetter.setNetwork", "Fehler beim Ausführen des Befehls: " + e.Message, LogLevel.Error);
throw e; throw e;
} }
return status; return status;
} }
public Dictionary<String, String> getNetwork(List<string> adapters)
{
this.addLog("NetworkSetter.getNetwork", "Hole Netzwerkeinstellungen für alle Adapter", LogLevel.Info);
this.addLog("NetworkSetter.getNetwork", "adapter: "+adapters+";", LogLevel.Debug);
Dictionary<String, String> ret = new Dictionary<String, String>();
foreach (string adapter in adapters)
{
String data = this.serviceController.NetworkGetName(adapter);
if (data == "unknown")
{
ret.Add(adapter, "unknown");
}
else if (data == "disconnected")
{
ret.Add(adapter, "disconnected");
}
else
{
string[] values = data.Substring(0, data.Length - 1).Substring(1).Split('|');
List<string> networks = this.networkini.getSections();
string selected_network = "";
foreach (string network in networks)
{
if (networkini.getValue(network, "Ip") == values[0])
{
selected_network = network;
}
if (networkini.getValue(network, "Subnet") == values[1] || (values[1] == "" && networkini.getValue(network, "Subnet") == null))
{
if (selected_network != network)
{
selected_network = "";
}
}
if (networkini.getValue(network, "Gateway") == values[2] || (values[2] == "" && networkini.getValue(network, "Gateway") == null))
{
if (selected_network != network)
{
selected_network = "";
}
}
if (networkini.getValue(network, "Dns") == values[3])
{
if (selected_network != network)
{
selected_network = "";
}
}
if (networkini.getValue(network, "Wins") == values[4])
{
if (selected_network != network)
{
selected_network = "";
}
}
}
if (selected_network == "")
{
ret.Add(adapter, "unknown");
}
else
{
ret.Add(adapter, selected_network);
}
}
}
return ret;
}
} }
} }

View File

@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BlubbFish.Utils;
namespace NetMonitorUtils {
public class OpenVpnSetter : OwnObject {
private ServiceControl serviceController;
private InIReader vpnini;
public OpenVpnSetter(string vpnfile, string configfile) {
this.addLog("NetworkSetter", "vpnfile: " + vpnfile + "; configfile: " + configfile + ";", LogLevel.Debug);
this.vpnini = InIReader.getInstance(vpnfile);
this.serviceController = ServiceControl.getInstance(configfile);
}
public bool setStart(string name) {
this.addLog("ServiceSetter.setStart", "", LogLevel.Debug);
this.addLog("ServiceSetter.setStart", "Starte Service", LogLevel.Info);
return this.serviceController.VpnSetStart(name);
}
public bool setStop(string name) {
this.addLog("ServiceSetter.setStop", "", LogLevel.Debug);
this.addLog("ServiceSetter.setStop", "Stoppe Service", LogLevel.Info);
return this.serviceController.VpnSetStop(name);
}
/// <summary>
/// Returns a list ("unknown";"connected";"disconnected","name")
/// </summary>
/// <param name="names"></param>
/// <returns></returns>
public Dictionary<String, String> getStatus(List<string> vpns) {
this.addLog("ServiceSetter.setStatus", "", LogLevel.Debug);
this.addLog("ServiceSetter.setStatus", "Status von allen Services", LogLevel.Info);
Dictionary<String, String> ret = new Dictionary<String, String>();
foreach(string vpn in vpns) {
String data = this.serviceController.VpnGetStatus(vpn);
if(data == "unknown") {
ret.Add(vpn, "unknown");
} else if(data == "disconnected") {
ret.Add(vpn, "disconnected");
} else {
}
}
return ret;
}
/// <summary>
/// Return a Status of one VPN
/// </summary>
/// <param name="config">Configfile</param>
/// <returns>Statusustring</returns>
public string getStatus(string config) {
this.addLog("ServiceSetter.getStatus", "", LogLevel.Debug);
this.addLog("ServiceSetter.getStatus", "Status vom Service", LogLevel.Info);
return this.serviceController.VpnGetStatus(config);
}
}
}

View File

@ -8,92 +8,71 @@ using System.Net;
using BlubbFish.Utils; using BlubbFish.Utils;
using NetMonitorUtils.Execptions; using NetMonitorUtils.Execptions;
namespace NetMonitorUtils namespace NetMonitorUtils {
{ public class ServiceControl {
public class ServiceControl
{
private ServiceController sc = new ServiceController(); private ServiceController sc = new ServiceController();
private static ServiceControl instance; private static ServiceControl instance;
private InIReader config; private InIReader config;
private ServiceControl(string configfile) private ServiceControl(string configfile) {
{
this.sc.ServiceName = "NetMonitorServer"; this.sc.ServiceName = "NetMonitorServer";
this.config = InIReader.getInstance(configfile); this.config = InIReader.getInstance(configfile);
} }
public static ServiceControl getInstance(string configfile) public static ServiceControl getInstance(string configfile) {
{ if(instance == null) {
if (instance == null)
{
instance = new ServiceControl(configfile); instance = new ServiceControl(configfile);
} }
return instance; return instance;
} }
private bool ServiceSetStatus(ServiceControllerStatus status) private bool ServiceSetStatus(ServiceControllerStatus status) {
{ if(this.sc.Status == status) {
if (this.sc.Status == status)
{
return true; return true;
} }
this.sc.Start(); this.sc.Start();
try try {
{
this.sc.WaitForStatus(status, new TimeSpan(0, 0, 30)); this.sc.WaitForStatus(status, new TimeSpan(0, 0, 30));
} } catch(System.ServiceProcess.TimeoutException) {
catch (System.ServiceProcess.TimeoutException)
{
return false; return false;
} }
return true; return true;
} }
public bool ServiceStart() public bool ServiceStart() {
{
return this.ServiceSetStatus(ServiceControllerStatus.Running); return this.ServiceSetStatus(ServiceControllerStatus.Running);
} }
public bool ServicePause() public bool ServicePause() {
{
return this.ServiceSetStatus(ServiceControllerStatus.Paused); return this.ServiceSetStatus(ServiceControllerStatus.Paused);
} }
public bool ServiceStop() public bool ServiceStop() {
{
return this.ServiceSetStatus(ServiceControllerStatus.Stopped); return this.ServiceSetStatus(ServiceControllerStatus.Stopped);
} }
public bool NetworkSetAuto(string adapter) public bool NetworkSetAuto(string adapter) {
{ if(adapter == null) {
if (adapter == null)
{
throw new ServiceControlArgumentException("Adapter ist not Set!"); throw new ServiceControlArgumentException("Adapter ist not Set!");
} }
return this.sendMessage("NET","AUTO "+adapter); return this.sendMessage("NET", "AUTO " + adapter);
} }
private bool sendMessage(string method, string message) private bool sendMessage(string method, string message) {
{
IPEndPoint netRecieverPoint = new IPEndPoint(IPAddress.Loopback, 0); IPEndPoint netRecieverPoint = new IPEndPoint(IPAddress.Loopback, 0);
int startPort = Int32.Parse(this.config.getValue("ports", "client_from")); int startPort = Int32.Parse(this.config.getValue("ports", "client_from"));
int rangePort = Int32.Parse(this.config.getValue("ports", "client_to")); int rangePort = Int32.Parse(this.config.getValue("ports", "client_to"));
UdpClient netReciver = null; UdpClient netReciver = null;
int selectedPort = 0; int selectedPort = 0;
for (int i = startPort; i < rangePort; i++) for(int i = startPort; i < rangePort; i++) {
{ try {
try
{
netReciver = new UdpClient(i); netReciver = new UdpClient(i);
} } catch(System.Net.Sockets.SocketException) { }
catch (System.Net.Sockets.SocketException) { } if(netReciver != null) {
if (netReciver != null)
{
selectedPort = i; selectedPort = i;
break; break;
} }
} }
if (netReciver == null) if(netReciver == null) {
{
throw new ServiceControlException("No Free Port for Comunication"); throw new ServiceControlException("No Free Port for Comunication");
} }
byte[] data = Encoding.UTF8.GetBytes(method + " " + selectedPort + " " + message); byte[] data = Encoding.UTF8.GetBytes(method + " " + selectedPort + " " + message);
@ -103,125 +82,159 @@ namespace NetMonitorUtils
netSender.Send(data, data.Length, netSenderPoint); netSender.Send(data, data.Length, netSenderPoint);
netReciver.Client.ReceiveTimeout = 60000; netReciver.Client.ReceiveTimeout = 60000;
byte[] recivedData; byte[] recivedData;
try try {
{
recivedData = netReciver.Receive(ref netRecieverPoint); recivedData = netReciver.Receive(ref netRecieverPoint);
} } catch(Exception e) {
catch (Exception e)
{
throw new ServiceControlNetworkException(e.Message); throw new ServiceControlNetworkException(e.Message);
} }
string recieveText = Encoding.UTF8.GetString(recivedData); string recieveText = Encoding.UTF8.GetString(recivedData);
if (recieveText.ToLower() == "true") if(recieveText.ToLower() == "true") {
{
return true; return true;
} } else {
else
{
throw new ServiceControlException(recieveText); throw new ServiceControlException(recieveText);
} }
} }
public bool NetworkSetIp(string ip, string subnet, string gateway, string adapter) public bool NetworkSetIp(string ip, string subnet, string gateway, string adapter) {
{ if(ip == null) {
if (ip == null)
{
throw new ServiceControlArgumentException("IP address not Set!"); throw new ServiceControlArgumentException("IP address not Set!");
} }
if (subnet == null) if(subnet == null) {
{
throw new ServiceControlArgumentException("Subnet address not Set!"); throw new ServiceControlArgumentException("Subnet address not Set!");
} }
if (gateway == null) if(gateway == null) {
{
throw new ServiceControlArgumentException("Gateway address not Set!"); throw new ServiceControlArgumentException("Gateway address not Set!");
} }
if (adapter == null) if(adapter == null) {
{
throw new ServiceControlArgumentException("Adapter ist not Set!"); throw new ServiceControlArgumentException("Adapter ist not Set!");
} }
return this.sendMessage("NET", "IP " + ip + " " + subnet + " " + gateway + " " + adapter); return this.sendMessage("NET", "IP " + ip + " " + subnet + " " + gateway + " " + adapter);
} }
public bool NetworkSetDNS(string dns, string adapter) public bool NetworkSetDNS(string dns, string adapter) {
{ if(dns == null) {
if (dns == null)
{
throw new ServiceControlArgumentException("DNS address not Set!"); throw new ServiceControlArgumentException("DNS address not Set!");
} }
if (adapter == null) if(adapter == null) {
{
throw new ServiceControlArgumentException("Adapter ist not Set!"); throw new ServiceControlArgumentException("Adapter ist not Set!");
} }
return this.sendMessage("NET", "DNS " + dns + " " + adapter); return this.sendMessage("NET", "DNS " + dns + " " + adapter);
} }
public bool NetworkSetWINS(string wins, string adapter) public bool NetworkSetWINS(string wins, string adapter) {
{ if(wins == null) {
if (wins == null)
{
throw new ServiceControlArgumentException("WINS address not Set!"); throw new ServiceControlArgumentException("WINS address not Set!");
} }
if (adapter == null) if(adapter == null) {
{
throw new ServiceControlArgumentException("Adapter ist not Set!"); throw new ServiceControlArgumentException("Adapter ist not Set!");
} }
return this.sendMessage("NET", "WINS " + wins + " " + adapter); return this.sendMessage("NET", "WINS " + wins + " " + adapter);
} }
public bool NetworkSetIpAuto(string adapter) public bool NetworkSetIpAuto(string adapter) {
{ if(adapter == null) {
if (adapter == null)
{
throw new ServiceControlArgumentException("Adapter ist not Set!"); throw new ServiceControlArgumentException("Adapter ist not Set!");
} }
return this.sendMessage("NET", "IP AUTO "+adapter); return this.sendMessage("NET", "IP AUTO " + adapter);
} }
public bool NetworkSetDnsAuto(string adapter) public bool NetworkSetDnsAuto(string adapter) {
{ if(adapter == null) {
if (adapter == null)
{
throw new ServiceControlArgumentException("Adapter ist not Set!"); throw new ServiceControlArgumentException("Adapter ist not Set!");
} }
return this.sendMessage("NET", "DNS AUTO " + adapter); return this.sendMessage("NET", "DNS AUTO " + adapter);
} }
public bool NetworkSetWinsAuto(string adapter) public bool NetworkSetWinsAuto(string adapter) {
{ if(adapter == null) {
if (adapter == null)
{
throw new ServiceControlArgumentException("Adapter ist not Set!"); throw new ServiceControlArgumentException("Adapter ist not Set!");
} }
return this.sendMessage("NET", "WINS AUTO " + adapter); return this.sendMessage("NET", "WINS AUTO " + adapter);
} }
public bool ServiceStart(string name) public bool ServiceStart(string name) {
{ if(name == null) {
if (name == null)
{
throw new ServiceControlArgumentException("Service name ist not set!"); throw new ServiceControlArgumentException("Service name ist not set!");
} }
return this.sendMessage("SERVICE", "START " + name); return this.sendMessage("SERVICE", "START " + name);
} }
public bool ServiceStop(string name) public bool ServiceStop(string name) {
{ if(name == null) {
if (name == null)
{
throw new ServiceControlArgumentException("Service name ist not set!"); throw new ServiceControlArgumentException("Service name ist not set!");
} }
return this.sendMessage("SERVICE", "STOP " + name); return this.sendMessage("SERVICE", "STOP " + name);
} }
public bool ServiceStatus(string name) public bool ServiceStatus(string name) {
{ if(name == null) {
if (name == null)
{
throw new ServiceControlArgumentException("Service name ist not set!"); throw new ServiceControlArgumentException("Service name ist not set!");
} }
try {
return this.sendMessage("SERVICE", "STATUS " + name); return this.sendMessage("SERVICE", "STATUS " + name);
} catch(ServiceControlException e) {
if(e.Message.ToLower() == "stopped") {
return false;
}
if(e.Message.ToLower() == "running") {
return true;
}
throw e;
}
}
public string NetworkGetName(string adapter) {
if(adapter == null) {
throw new ServiceControlArgumentException("Adaptername not set!");
}
try {
return this.sendMessage("NET", "NETWORK " + adapter).ToString();
} catch(ServiceControlException e) {
if(e.Message.ToLower() == "unknown") {
return "unknown";
}
if(e.Message.ToLower() == "disconnected") {
return "disconnected";
}
if(e.Message.ToLower().Substring(0, 1) == "[") {
return e.Message;
}
throw e;
}
}
public string VpnGetStatus(string vpn) {
if(vpn == null) {
throw new ServiceControlArgumentException("Configname not set!");
}
try {
return this.sendMessage("OPENVPN", "STATUS " + vpn).ToString();
} catch(ServiceControlException e) {
if(e.Message.ToLower() == "unknown") {
return "unknown";
}
if(e.Message.ToLower() == "disconnected") {
return "disconnected";
}
if(e.Message.ToLower().Substring(0, 1) == "[") {
return e.Message;
}
throw e;
}
}
internal bool VpnSetStart(string name) {
if(name == null) {
throw new ServiceControlArgumentException("OpenVPN Config name ist not set!");
}
return this.sendMessage("OPENVPN", "START " + name);
}
internal bool VpnSetStop(string name) {
if(name == null) {
throw new ServiceControlArgumentException("OpenVPN Config name ist not set!");
}
return this.sendMessage("OPENVPN", "STOP " + name);
} }
} }
} }

View File

@ -2,3 +2,6 @@
server=54323 server=54323
client_from=54330 client_from=54330
client_to=54340 client_to=54340
[program]
openvpn=C:\Program Files\OpenVPN

View File

@ -0,0 +1,40 @@
[network1]
Name=Home
Ip=auto
Dns=auto
Wins=auto
Adapter=LAN-Verbindung
[network2]
Name=FHG
Ip=129.26.164.188
Subnet=255.255.248.0
Gateway=129.26.160.1
Dns=129.26.165.177
Wins=129.26.165.167
Adapter=LAN-Verbindung
[network3]
Name=Test
Ip=10.15.20.25
Subnet=255.255.255.0
Gateway=0.0.0.0
Dns=none
Wins=none
Adapter=LAN-Verbindung
[network4]
Name=Wlan Home
Ip=10.15.20.106
Subnet=255.255.0.0
Gateway=10.15.20.200
Dns=10.15.20.243
Wins=10.15.20.243
Adapter=Drahtlosnetzwerkverbindung
[network5]
Name=Wlan Auto
Ip=auto
Dns=auto
Wins=auto
Adapter=Drahtlosnetzwerkverbindung

7
NetMonitorUtils/vpn.ini Normal file
View File

@ -0,0 +1,7 @@
[openvpn1]
Name=FH
Config=wlanfb02.ovpn
[openvpn2]
Name=Home
Config=home.ovpn_

View File

@ -19,7 +19,7 @@
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>E:\Programme\NetMonitor\</OutputPath> <OutputPath>..\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bin/Debug/NetOpenVPNGUI.exe Normal file

Binary file not shown.

Binary file not shown.

View File

@ -2,3 +2,6 @@
server=54323 server=54323
client_from=54330 client_from=54330
client_to=54340 client_to=54340
[program]
openvpn=C:\Program Files\OpenVPN

View File

@ -4,3 +4,37 @@ Ip=auto
Dns=auto Dns=auto
Wins=auto Wins=auto
Adapter=LAN-Verbindung Adapter=LAN-Verbindung
[network2]
Name=FHG
Ip=129.26.164.188
Subnet=255.255.248.0
Gateway=129.26.160.1
Dns=129.26.165.177
Wins=129.26.165.167
Adapter=LAN-Verbindung
[network3]
Name=Test
Ip=10.15.20.25
Subnet=255.255.255.0
Gateway=0.0.0.0
Dns=none
Wins=none
Adapter=LAN-Verbindung
[network4]
Name=Wlan Home
Ip=10.15.20.106
Subnet=255.255.0.0
Gateway=10.15.20.200
Dns=10.15.20.243
Wins=10.15.20.243
Adapter=Drahtlosnetzwerkverbindung
[network5]
Name=Wlan Auto
Ip=auto
Dns=auto
Wins=auto
Adapter=Drahtlosnetzwerkverbindung

7
bin/Debug/vpn.ini Normal file
View File

@ -0,0 +1,7 @@
[openvpn1]
Name=FH
Config=wlanfb02.ovpn
[openvpn2]
Name=Home
Config=home.ovpn_