masscheckin ganz viel kram

This commit is contained in:
BlubbFish 2015-11-16 00:10:59 +00:00
parent 8264cbfa7b
commit dfc14d9c36
45 changed files with 1862 additions and 834 deletions

View File

@ -47,7 +47,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<OutputPath>..\bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>

View File

@ -4,9 +4,10 @@ using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;
using BlubbFish.Utils;
namespace NetMonitorServer {
abstract class ActionClass {
abstract class ActionClass : OwnObject {
protected UdpClient outputNetworkStream;
protected IPEndPoint outputNetworkPort;
internal void SetAnswerStream(UdpClient udpClient, IPEndPoint iPEndPoint) {
@ -17,7 +18,7 @@ namespace NetMonitorServer {
abstract internal bool Run(Queue<string> arguments);
protected void sendMessage(string message) {
Console.WriteLine(message);
this.addLog("ActionClass.sendMessage", "Nachricht geantwortet: "+message, LogLevel.Notice);
byte[] answ = Encoding.UTF8.GetBytes(message);
outputNetworkStream.Send(answ, answ.Length, outputNetworkPort);
}

View File

@ -7,297 +7,284 @@ using System.Net;
using System.Net.Sockets;
using System.Text.RegularExpressions;
namespace NetMonitorServer
{
class SetNetworks : ActionClass
{
private string netsh_output = "";
private bool setNetworkWins(Queue<string> data)
{
if (data.Count != 2)
{
this.sendMessage("To less arguments for SetNetworks.setNetworkWins class");
return false;
}
string ip = data.Dequeue();
string name = data.Dequeue();
string netsh = "interface ipv4 set winsservers name=\"" + name + (ip == "auto" ? "\" source=dhcp" : "\" static " + ip);
try
{
this.runProgramNetsh(netsh);
}
catch (Exception e)
{
this.sendMessage(e.Message);
return false;
}
this.sendMessage("true");
return true;
}
namespace NetMonitorServer {
class SetNetworks : ActionClass {
private string netsh_output = "";
private bool setNetworkDns(Queue<string> data)
{
if (data.Count != 2)
{
this.sendMessage("To less arguments for SetNetworks.setNetworkDns class");
return false;
}
string ip = data.Dequeue();
string name = data.Dequeue();
string netsh = "interface ipv4 set dnsservers name=\"" + name + (ip == "auto" ? "\" source=dhcp" : "\" static " + ip + " primary");
try
{
this.runProgramNetsh(netsh);
}
catch (Exception e)
{
this.sendMessage(e.Message);
return false;
}
this.sendMessage("true");
return true;
}
private bool setNetworkIp(Queue<string> data)
{
if (data.Count != 2 && data.Count != 4)
{
this.sendMessage("To less arguments for SetNetworks.setNetworkIp class");
return false;
}
string ip = data.Dequeue();
string netsh = "";
if (ip == "auto")
{
string name = data.Dequeue();
netsh = "interface ipv4 set address name=\"" + name + "\" source=dhcp";
}
else
{
string subnet = data.Dequeue();
string gw = data.Dequeue();
string name = data.Dequeue();
netsh = "interface ipv4 set address \"" + name + "\" static " + ip + " " + subnet + " " + gw;
}
try
{
this.runProgramNetsh(netsh);
}
catch (Exception e)
{
this.sendMessage(e.Message);
return false;
}
this.sendMessage("true");
return true;
}
private bool setNetworkAuto(Queue<string> data)
{
if (data.Count != 1)
{
this.sendMessage("To less arguments for SetNetworks.setNetworkAuto class");
return false;
}
string name = data.Dequeue();
try
{
this.runProgramNetsh("interface ipv4 set address name=\"" + name + "\" source=dhcp");
this.runProgramNetsh("interface ipv4 set dnsservers name=\"" + name + "\" source=dhcp");
this.runProgramNetsh("interface ipv4 set winsservers name=\"" + name + "\" source=dhcp");
}
catch (Exception e)
{
this.sendMessage(e.Message);
return false;
}
this.sendMessage("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)
{
//Console.WriteLine("netsh args: "+args);
Process p = new Process();
p.StartInfo.Arguments = args;
p.StartInfo.FileName = "netsh";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.Start();
this.netsh_output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
//Console.WriteLine(this.netsh_output.Trim());
if (p.ExitCode == 0)
{
return true;
}
throw new Exception(this.netsh_output.Trim());
}
internal override bool Run(Queue<string> arguments)
{
if (arguments.Count < 2)
{
this.sendMessage("To less arguments for SetNetwork class");
return false;
}
switch (arguments.Dequeue().ToLower())
{
case "auto": return this.setNetworkAuto(arguments);
case "ip": return this.setNetworkIp(arguments);
case "dns": return this.setNetworkDns(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;
}
}
internal override bool Run(Queue<string> arguments) {
this.addLog("SetNetworks.Run", "Setze Netzwerk Befehl", LogLevel.Notice);
if(arguments.Count < 1) {
this.sendMessage("To less arguments for SetNetwork class");
return false;
}
switch(arguments.Dequeue().ToLower()) {
case "auto":
return this.setNetworkAuto(arguments);
case "ip":
return this.setNetworkIp(arguments);
case "dns":
return this.setNetworkDns(arguments);
case "wins":
return this.setNetworkWins(arguments);
case "network":
return this.getNetwork(arguments);
case "adapters":
return this.getAdapters(arguments);
default:
this.sendMessage("Wrong arguments for service on SetNetwork class");
return false;
}
}
private bool getAdapters(Queue<string> arguments) {
if(arguments.Count != 0) {
this.sendMessage("To less arguments for SetNetworks.getAdapters class");
return false;
}
this.addLog("SetNetworks.getNetwork", "Lese Liste Adapter", LogLevel.Notice);
List<string> ret = new List<string>();
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|connected) [ ]+([^ ].*)$", RegexOptions.IgnoreCase)) {
ret.Add(Regex.Match(l, "(disconnected|connected) [ ]+([^ ].*)$").Groups[2].ToString());
}
}
} catch(Exception e) {
this.sendMessage(e.Message);
return false;
}
if(ret.Count == 0) {
this.sendMessage("unknown");
return false;
}
this.sendMessage("[" + String.Join("|", ret.ToArray()) + "]");
return true;
}
private bool setNetworkWins(Queue<string> data) {
if(data.Count != 2) {
this.sendMessage("To less arguments for SetNetworks.setNetworkWins class");
return false;
}
string ip = data.Dequeue();
string name = data.Dequeue();
this.addLog("SetNetworks.setNetworkWins", "Setzte Wins auf " + name + " mit " + ip, LogLevel.Notice);
string netsh = "interface ipv4 set winsservers name=\"" + name + (ip == "auto" ? "\" source=dhcp" : "\" static " + ip);
try {
this.runProgramNetsh(netsh);
} catch(Exception e) {
this.sendMessage(e.Message);
return false;
}
this.sendMessage("true");
return true;
}
private bool setNetworkDns(Queue<string> data) {
if(data.Count != 2) {
this.sendMessage("To less arguments for SetNetworks.setNetworkDns class");
return false;
}
string ip = data.Dequeue();
string name = data.Dequeue();
this.addLog("SetNetworks.setNetworkDns", "Setzte Dns auf " + name + " mit " + ip, LogLevel.Notice);
string netsh = "interface ipv4 set dnsservers name=\"" + name + (ip == "auto" ? "\" source=dhcp" : "\" static " + ip + " primary");
try {
this.runProgramNetsh(netsh);
} catch(Exception e) {
this.sendMessage(e.Message);
return false;
}
this.sendMessage("true");
return true;
}
private bool setNetworkIp(Queue<string> data) {
if(data.Count != 2 && data.Count != 4) {
this.sendMessage("To less arguments for SetNetworks.setNetworkIp class");
return false;
}
string ip = data.Dequeue();
string netsh = "";
if(ip == "auto") {
string name = data.Dequeue();
this.addLog("SetNetworks.setNetworkIp", "Setzte Ip auf " + name + " mit " + ip, LogLevel.Notice);
netsh = "interface ipv4 set address name=\"" + name + "\" source=dhcp";
} else {
string subnet = data.Dequeue();
string gw = data.Dequeue();
string name = data.Dequeue();
this.addLog("SetNetworks.setNetworkIp", "Setzte Ip auf " + name + " mit " + ip, LogLevel.Notice);
netsh = "interface ipv4 set address \"" + name + "\" static " + ip + " " + subnet + " " + gw;
}
try {
this.runProgramNetsh(netsh);
} catch(Exception e) {
this.sendMessage(e.Message);
return false;
}
this.sendMessage("true");
return true;
}
private bool setNetworkAuto(Queue<string> data) {
if(data.Count != 1) {
this.sendMessage("To less arguments for SetNetworks.setNetworkAuto class");
return false;
}
string name = data.Dequeue();
this.addLog("SetNetworks.setNetworkAuto", "Setzte DHCP auf " + name, LogLevel.Notice);
try {
this.runProgramNetsh("interface ipv4 set address name=\"" + name + "\" source=dhcp");
this.runProgramNetsh("interface ipv4 set dnsservers name=\"" + name + "\" source=dhcp");
this.runProgramNetsh("interface ipv4 set winsservers name=\"" + name + "\" source=dhcp");
} catch(Exception e) {
this.sendMessage(e.Message);
return false;
}
this.sendMessage("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();
this.addLog("SetNetworks.getNetwork", "Lese Netzwerk auf " + adapter, LogLevel.Notice);
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) {
this.addLog("SetNetworks.runProgramNetsh", "Netsh: " + args, LogLevel.Info);
//Console.WriteLine("netsh args: "+args);
Process p = new Process();
p.StartInfo.Arguments = args;
p.StartInfo.FileName = "netsh";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.Start();
this.netsh_output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
//Console.WriteLine(this.netsh_output.Trim());
if(p.ExitCode == 0) {
return true;
}
throw new Exception(this.netsh_output.Trim());
}
}
}

View File

@ -10,13 +10,14 @@ namespace NetMonitorServer {
class SetOpenVPNService : ActionClass {
internal override bool Run(Queue<string> arguments) {
this.addLog("SetOpenVPNService.Run", "Starte OpenVpn Befehl", LogLevel.Notice);
if(arguments.Count < 2) {
this.sendMessage("To less arguments for SetOpenVpnService class");
return false;
}
switch(arguments.Dequeue().ToLower()) {
case "status":
return this.getVpn(arguments);
return this.getVpnStatus(arguments);
case"start":
return this.getVpnStart(arguments);
case"stop":
@ -28,7 +29,12 @@ namespace NetMonitorServer {
}
private bool getVpnStop(Queue<string> arguments) {
if(arguments.Count != 1) {
this.sendMessage("To less arguments for SetOpenVpnService.getVpnStop");
return false;
}
string config = arguments.Dequeue();
this.addLog("SetOpenVPNService.getVpnStop", "Stoppe OpenVPN: "+config, LogLevel.Notice);
if(Model.openvpnInstances.Keys.Contains(config)) { //schon in der Liste
OpenVpnController o = Model.openvpnInstances[config];
if(o.HasExited) { //läuft nicht! Fehler!
@ -41,11 +47,16 @@ namespace NetMonitorServer {
return false;
}
this.sendMessage("true");
return false;
return true;
}
private bool getVpnStart(Queue<string> arguments) {
if(arguments.Count != 1) {
this.sendMessage("To less arguments for SetOpenVpnService.getVpnStart");
return false;
}
string config = arguments.Dequeue();
this.addLog("SetOpenVPNService.getVpnStart", "Starte OpenVPN: " + config, LogLevel.Notice);
if(Model.openvpnInstances.Keys.Contains(config)) { //schon in der Liste
OpenVpnController o = Model.openvpnInstances[config];
if(!o.HasExited) { //läuft noch! Fehler!
@ -58,32 +69,30 @@ namespace NetMonitorServer {
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");
string ovpn = Factory.getSettings().getValue("program", "openvpn");
ovpn = (ovpn.EndsWith("\\")) ? ovpn : ovpn + "\\";
try {
OpenVpnController o = new OpenVpnController(ovpn, config);
o.EventLog += this.addLog;
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;
}
this.sendMessage("true");
return true;
}
private bool getVpn(Queue<string> arguments) {
private bool getVpnStatus(Queue<string> arguments) {
if(arguments.Count != 1) {
this.sendMessage("To less arguments for SetOpenVpnService.getVpn class");
this.sendMessage("To less arguments for SetOpenVpnService.getVpnStatus");
return false;
}
string config = arguments.Dequeue();
this.addLog("SetOpenVPNService.getVpnStatus", "Status des OpenVPN: " + config, LogLevel.Notice);
string run = "";
try {
if(Model.openvpnInstances.Keys.Contains(config)) {

View File

@ -7,109 +7,93 @@ using System.Net;
using System.Net.Sockets;
using System.ServiceProcess;
namespace NetMonitorServer
{
class SetService : ActionClass
{
ServiceController serviceController;
namespace NetMonitorServer {
class SetService : ActionClass {
ServiceController serviceController;
private bool setServiceStart(Queue<string> data)
{
if (data.Count != 1)
{
this.sendMessage("To less arguments for SetService.setServiceStart class");
return false;
}
this.serviceController.ServiceName = data.Dequeue();
try
{
this.serviceController.Start();
this.serviceController.WaitForStatus(ServiceControllerStatus.Running, new TimeSpan(0, 0, 30));
}
catch (Exception e)
{
this.sendMessage(e.Message);
return false;
}
if (this.serviceController.Status == ServiceControllerStatus.Running)
{
this.sendMessage("true");
}
else
{
this.sendMessage("The service isn't started");
return false;
}
return true;
}
private bool setServiceStop(Queue<string> data)
{
if (data.Count != 1)
{
this.sendMessage("To less arguments for SetService.setServiceStop class");
return false;
}
this.serviceController.ServiceName = data.Dequeue();
try
{
this.serviceController.Stop();
this.serviceController.WaitForStatus(ServiceControllerStatus.Stopped, new TimeSpan(0, 0, 30));
}
catch (Exception e)
{
this.sendMessage(e.Message);
return false;
}
if (this.serviceController.Status == ServiceControllerStatus.Stopped)
{
this.sendMessage("true");
}
else
{
this.sendMessage("The service isn't stopped");
return false;
}
return true;
}
private bool getServiceStatus(Queue<string> data)
{
if (data.Count != 1)
{
this.sendMessage("To less arguments for SetService.setServiceStatus class");
return false;
}
try
{
this.serviceController.ServiceName = data.Dequeue();
if (this.serviceController.Status == ServiceControllerStatus.Running)
this.sendMessage("running");
else
this.sendMessage("stopped");
}
catch (Exception e)
{
this.sendMessage(e.Message);
return false;
}
return true;
}
internal override bool Run(Queue<string> arguments)
{
if (arguments.Count != 2)
{
this.sendMessage("To less arguments for SetService class");
return false;
}
this.serviceController = new ServiceController();
switch (arguments.Dequeue().ToLower())
{
case "start": return this.setServiceStart(arguments);
case "stop": return this.setServiceStop(arguments);
case "status": return this.getServiceStatus(arguments);
default: this.sendMessage("Wrong arguments for service on SetService class"); return false;
}
}
internal override bool Run(Queue<string> arguments) {
this.addLog("SetService.Run", "Starte Service Befehl", LogLevel.Notice);
if(arguments.Count != 2) {
this.sendMessage("To less arguments for SetService class");
return false;
}
this.serviceController = new ServiceController();
switch(arguments.Dequeue().ToLower()) {
case "start":
return this.setServiceStart(arguments);
case "stop":
return this.setServiceStop(arguments);
case "status":
return this.getServiceStatus(arguments);
default:
this.sendMessage("Wrong arguments for service on SetService class");
return false;
}
}
private bool setServiceStart(Queue<string> data) {
if(data.Count != 1) {
this.sendMessage("To less arguments for SetService.setServiceStart class");
return false;
}
this.serviceController.ServiceName = data.Dequeue();
this.addLog("SetService.setServiceStart", "Starte Service: " + this.serviceController.ServiceName, LogLevel.Notice);
try {
this.serviceController.Start();
this.serviceController.WaitForStatus(ServiceControllerStatus.Running, new TimeSpan(0, 0, 30));
} catch(Exception e) {
this.sendMessage(e.Message);
return false;
}
if(this.serviceController.Status == ServiceControllerStatus.Running) {
this.sendMessage("true");
} else {
this.sendMessage("The service isn't started");
return false;
}
return true;
}
private bool setServiceStop(Queue<string> data) {
if(data.Count != 1) {
this.sendMessage("To less arguments for SetService.setServiceStop class");
return false;
}
this.serviceController.ServiceName = data.Dequeue();
this.addLog("SetService.setServiceStop", "Stoppe Service: " + this.serviceController.ServiceName, LogLevel.Notice);
try {
this.serviceController.Stop();
this.serviceController.WaitForStatus(ServiceControllerStatus.Stopped, new TimeSpan(0, 0, 30));
} catch(Exception e) {
this.sendMessage(e.Message);
return false;
}
if(this.serviceController.Status == ServiceControllerStatus.Stopped) {
this.sendMessage("true");
} else {
this.sendMessage("The service isn't stopped");
return false;
}
return true;
}
private bool getServiceStatus(Queue<string> data) {
if(data.Count != 1) {
this.sendMessage("To less arguments for SetService.setServiceStatus class");
return false;
}
try {
this.serviceController.ServiceName = data.Dequeue();
this.addLog("SetService.setServiceStatus", "Status des Service: " + this.serviceController.ServiceName, LogLevel.Notice);
if(this.serviceController.Status == ServiceControllerStatus.Running)
this.sendMessage("running");
else
this.sendMessage("stopped");
} catch(Exception e) {
this.sendMessage(e.Message);
return false;
}
return true;
}
}
}

View File

@ -6,9 +6,10 @@ using System.Threading.Tasks;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.IO;
using BlubbFish.Utils;
namespace NetMonitorServer.Controller {
class OpenVpnController {
class OpenVpnController : OwnObject {
private Process proc;
public bool HasExited { get; private set; }
@ -20,8 +21,10 @@ namespace NetMonitorServer.Controller {
public string IpDate { get; private set; }
public string SuccessDate { get; private set; }
private string config;
public OpenVpnController(string path, string config) {
// TODO: Complete member initialization
this.addLog("NetMonitorServer.Start", "Erstelle OpenVPN " + config, LogLevel.Notice);
this.proc = new Process();
this.proc.StartInfo.Arguments = "--config " + config;
this.proc.StartInfo.FileName = path + "bin\\openvpn.exe";
@ -29,8 +32,9 @@ namespace NetMonitorServer.Controller {
this.HasExited = true;
this.Conntected = false;
this.Error = "";
this.config = config;
}
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]*)";
@ -47,16 +51,19 @@ namespace NetMonitorServer.Controller {
this.SuccessDate = match.Groups[1].Value;
this.Conntected = true;
}
//Console.WriteLine("L: |" + outLine.Data + "|");
this.addLog("NetMonitorServer.VpnOutputHandler", "OpenVPN: " + outLine.Data, LogLevel.Info);
}
}
private void VpnErrorHandler(object sendingProcess, DataReceivedEventArgs outLine) {
this.Error += outLine.Data;
this.addLog("NetMonitorServer.VpnErrorHandler", "OpenVPN:" + outLine.Data, LogLevel.Warn);
}
internal bool Start() {
this.addLog("NetMonitorServer.Start", "Starte OpenVPN " + this.config, LogLevel.Notice);
if(!this.HasExited) {
this.addLog("NetMonitorServer.Start", "OpenVPN wurde schon gestartet " + this.config, LogLevel.Warn);
return false;
}
this.HasExited = false;
@ -75,6 +82,7 @@ namespace NetMonitorServer.Controller {
}
internal bool Kill() {
this.addLog("NetMonitorServer.Kill", "Stoppe OpenVPN " + this.config, LogLevel.Notice);
this.proc.CancelErrorRead();
this.proc.CancelOutputRead();
this.proc.Kill();

View File

@ -2,7 +2,9 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using BlubbFish.Utils;
using System.Reflection;
namespace NetMonitorServer {
class Factory {
@ -16,7 +18,8 @@ namespace NetMonitorServer {
return null;
}
internal static InIReader getSettings() {
return InIReader.getInstance("config.ini");
string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
return InIReader.getInstance(path + "\\config.ini");
}
}
}

View File

@ -11,74 +11,93 @@ using System.Net.Sockets;
using System.Threading;
using BlubbFish.Utils;
namespace NetMonitorServer
{
public partial class MainService : ServiceBase
{
private Thread serverThread = new Thread(new ThreadStart(overwatch));
private static UdpClient receiveStream;
public MainService()
{
InitializeComponent();
this.serverThread.IsBackground = true;
}
private static void overwatch()
{
IPEndPoint networkStreamAddress = new IPEndPoint(IPAddress.Loopback, 0);
while (true)
{
if (Thread.CurrentThread.ThreadState == System.Threading.ThreadState.AbortRequested)
{
receiveStream.Close();
break;
}
byte[] data = receiveStream.Receive(ref networkStreamAddress);
Thread queryThread = new Thread(new ParameterizedThreadStart(ServerCommandProcessor));
queryThread.Start(data);
}
}
private static void ServerCommandProcessor(object threadParam)
{
string data = Encoding.UTF8.GetString((byte[])threadParam);
Console.WriteLine(data);
Queue<string> arguments = new Queue<string>(data.Split(' '));
if (arguments.Count < 2)
{
Console.WriteLine("Zu wenig Argumente");
return;
}
ActionClass a = Factory.getAction(arguments.Dequeue());
if (a == null)
{
Console.WriteLine("Falsche Angabe der ActionClass");
return;
}
a.SetAnswerStream(new UdpClient(), new IPEndPoint(IPAddress.Loopback, Int32.Parse(arguments.Dequeue())));
a.Run(arguments);
}
protected override void OnStart(string[] args)
{
this.initServerThread();
this.serverThread.Start();
}
private void initServerThread()
{
receiveStream = new UdpClient(Int32.Parse(Factory.getSettings().getValue("ports", "server")));
}
protected override void OnStop()
{
this.serverThread.Abort();
try { receiveStream.Close(); } catch { };
}
public void StartServiceConsole(string[] args)
{
this.OnStart(args);
}
namespace NetMonitorServer {
public partial class MainService : ServiceBase {
private Thread serverThread = new Thread(new ThreadStart(overwatch));
private static UdpClient receiveStream;
private static FileLogger log;
private static OwnObject.LogLevel loglevel;
public MainService() {
string folder = Factory.getSettings().getValue("program", "logfolder");
folder = folder.EndsWith("\\") ? folder : folder + "\\";
log = FileLogger.getInstance(folder + "server.log", false);
loglevel = (OwnObject.LogLevel)Enum.Parse(typeof(OwnObject.LogLevel), Factory.getSettings().getValue("program", "loglevel"));
LogEvents("MainService", "Server Starten...", OwnObject.LogLevel.Notice);
InitializeComponent();
this.serverThread.IsBackground = true;
}
private static void overwatch() {
LogEvents("MainService.overwatch", "Empfangsthread gestartet.", OwnObject.LogLevel.Notice);
IPEndPoint networkStreamAddress = new IPEndPoint(IPAddress.Loopback, 0);
while(true) {
if(Thread.CurrentThread.ThreadState == System.Threading.ThreadState.AbortRequested) {
receiveStream.Close();
break;
}
byte[] data = receiveStream.Receive(ref networkStreamAddress);
Thread queryThread = new Thread(new ParameterizedThreadStart(ServerCommandProcessor));
queryThread.Start(data);
}
}
private static void ServerCommandProcessor(object threadParam) {
string data = Encoding.UTF8.GetString((byte[])threadParam);
LogEvents("MainService.ServerCommandProcessor", "Befehl empfangen: "+data, OwnObject.LogLevel.Notice);
Queue<string> arguments = new Queue<string>(data.Split(' '));
if(arguments.Count < 2) {
LogEvents("MainService.ServerCommandProcessor", "Zu wenig Argumente", OwnObject.LogLevel.Error);
return;
}
ActionClass a = Factory.getAction(arguments.Dequeue());
a.EventLog += LogEvents;
if(a == null) {
LogEvents("MainService.ServerCommandProcessor", "Falsche Angabe der ActionClass", OwnObject.LogLevel.Error);
return;
}
a.SetAnswerStream(new UdpClient(), new IPEndPoint(IPAddress.Loopback, Int32.Parse(arguments.Dequeue())));
a.Run(arguments);
}
static void LogEvents(string location, string message, OwnObject.LogLevel level) {
LogEvents(location, message, level, DateTime.Now);
}
static void LogEvents(string location, string message, OwnObject.LogLevel level, DateTime date) {
string msg = OwnObject.logToString(location, message, level, date, true, true);
//if(level >= loglevel) {
log.setLine(msg);
//}
Console.WriteLine(msg);
}
protected override void OnStart(string[] args) {
LogEvents("MainService.OnStart", "Server gestartet", OwnObject.LogLevel.Notice);
this.initServerThread();
this.serverThread.Start();
}
private void initServerThread() {
int port = Int32.Parse(Factory.getSettings().getValue("ports", "server"));
try {
receiveStream = new UdpClient(port);
} catch(Exception e) {
LogEvents("MainService.initServerThread", "Fehler beim Initialisieren des Ports "+port+": "+e.Message, OwnObject.LogLevel.Error);
throw e;
}
}
protected override void OnStop() {
LogEvents("MainService.OnStop", "Server gestoppt", OwnObject.LogLevel.Notice);
this.serverThread.Abort();
try { receiveStream.Close(); } catch { };
}
public void StartServiceConsole(string[] args) {
loglevel = OwnObject.LogLevel.Debug;
LogEvents("MainService.StartServiceConsole", "Server über die Konsole gestartet", OwnObject.LogLevel.Notice);
this.OnStart(args);
}
}
}

View File

@ -6,54 +6,45 @@ using System.Text;
using System.Configuration.Install;
using System.ComponentModel;
namespace NetMonitorServer
{
[RunInstaller(true)]
public class TestWinInstaller : Installer
{
private ServiceInstaller m_ThisService;
private ServiceProcessInstaller m_ThisServiceProcess;
namespace NetMonitorServer {
[RunInstaller(true)]
public class TestWinInstaller : Installer {
private ServiceInstaller m_ThisService;
private ServiceProcessInstaller m_ThisServiceProcess;
public TestWinInstaller()
{
m_ThisService = new ServiceInstaller();
m_ThisServiceProcess = new ServiceProcessInstaller();
public TestWinInstaller() {
m_ThisService = new ServiceInstaller();
m_ThisServiceProcess = new ServiceProcessInstaller();
m_ThisServiceProcess.Account = ServiceAccount.LocalSystem;
m_ThisService.ServiceName = "NetMonitorServer";
m_ThisService.StartType = ServiceStartMode.Automatic;
m_ThisService.Description = "Teil von NetMonitor der die Systemnahen Befele ausführt";
m_ThisService.DisplayName = "Netzwerk Settings Tool";
m_ThisServiceProcess.Account = ServiceAccount.LocalSystem;
m_ThisService.ServiceName = "NetMonitorServer";
m_ThisService.StartType = ServiceStartMode.Automatic;
m_ThisService.Description = "Teil von NetMonitor der die Systemnahen Befele ausführt";
m_ThisService.DisplayName = "Netzwerk Settings Tool";
Installers.Add(m_ThisService);
Installers.Add(m_ThisServiceProcess);
}
}
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main(string[] args)
{
if (args.Length == 0)
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new MainService()
};
ServiceBase.Run(ServicesToRun);
}
else if (args.Length == 1 || args[0] == "-r")
{
MainService s = new MainService();
s.StartServiceConsole(args);
while (true)
{
System.Threading.Thread.Sleep(100);
}
}
}
}
Installers.Add(m_ThisService);
Installers.Add(m_ThisServiceProcess);
}
}
static class Program {
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main(string[] args) {
if(args.Length == 0) {
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new MainService()
};
ServiceBase.Run(ServicesToRun);
} else if(args.Length == 1 && args[0] == "-r") {
MainService s = new MainService();
s.StartServiceConsole(args);
while(true) {
System.Threading.Thread.Sleep(100);
}
}
}
}
}

View File

@ -6,6 +6,8 @@ using System.Threading.Tasks;
using System.Windows.Forms;
using NetMonitorUtils;
using BlubbFish.Utils;
using System.Threading;
using System.Runtime.CompilerServices;
namespace NetMonitorTray.Controller {
public class Tray : OwnController {
@ -13,12 +15,14 @@ namespace NetMonitorTray.Controller {
private static OpenVpnSetter vpn;
private static NetworkSetter network;
private static Controller.Window window;
private static Thread trayMenuRefresh;
/// <summary>
/// Tray Controller
/// </summary>
public Tray() {
vpn = new OpenVpnSetter("vpn.ini", "config.ini");
network = new NetworkSetter("network.ini", "config.ini");
trayMenuRefresh = new Thread(menuRefresh);
}
/// <summary>
/// Init!
@ -28,15 +32,38 @@ namespace NetMonitorTray.Controller {
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);
updateMenu();
} catch(Exception e) {
tray.showError(e.Message);
tray.Model.connectedStatus = false;
}
trayMenuRefresh.Start();
}
private static void menuRefresh() {
while(true) {
Thread.Sleep(10 * 60 * 1000); //Wait 10 Minutes
updateMenu();
}
}
[MethodImpl(MethodImplOptions.Synchronized)]
private static void updateMenu() {
List<string> adapter = tray.Model.getAdapterList();
tray.Model.NetworkSelected = network.getNetwork(adapter);
List<string> vpns = tray.Model.getVpnList();
tray.Model.VpnSelected = vpn.getStatus(vpns);
checkWorkingIcon();
}
private static void checkWorkingIcon() {
bool w = false;
foreach(KeyValuePair<string, string> item in tray.Model.VpnSelected) {
if(item.Value == "connected") {
w = true;
}
}
tray.Model.connectedStatus = w;
}
/// <summary>
/// User klickt auf den Eintrag Beenden
@ -44,10 +71,12 @@ namespace NetMonitorTray.Controller {
/// <param name="sender"></param>
/// <param name="e"></param>
internal static void Click_Quit(object sender, EventArgs e) {
trayMenuRefresh.Abort();
while(trayMenuRefresh.ThreadState != ThreadState.Aborted) { Thread.Sleep(100); }
tray.Dispose();
//Application.ExitThread();
Application.Exit();
}
/// <summary>
/// User klick auf einen Eintrag Service Starten/Stoppen
/// </summary>
@ -55,7 +84,6 @@ namespace NetMonitorTray.Controller {
/// <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":
@ -74,7 +102,6 @@ namespace NetMonitorTray.Controller {
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;
@ -91,12 +118,13 @@ namespace NetMonitorTray.Controller {
System.Threading.Thread.Sleep(1000);
}
} catch(Exception ex) {
tray.Model.connectedStatus = false;
tray.showError("Fehler beim beenden von Openvpn mit " + conf + ": " + ex.Message);
}
break;
}
checkWorkingIcon();
}
/// <summary>
/// User klickt Doppelt auf das TrayIcon
/// </summary>
@ -105,13 +133,14 @@ namespace NetMonitorTray.Controller {
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();
Click_Open(sender, e);
}
/// <summary>
/// User klickt auf einen Eintrag Netzwerk
@ -121,12 +150,13 @@ namespace NetMonitorTray.Controller {
internal static void Click_Network(object sender, EventArgs e) {
tray.setWorkingIcon();
try {
network.setNetwork(((ToolStripMenuItem)sender).Name);
string n = ((ToolStripMenuItem)sender).Name;
network.setNetwork(n.Split('|')[1]);
tray.Model.NetworkSelected[n.Split('|')[0]] = n.Split('|')[1];
} catch(Exception ex) {
tray.showError("Fehler beim setzen des Netzwerks: " + ex.Message);
}
checkWorkingIcon();
}
/// <summary>
/// User klickt auf den Eintrag Öffnen

View File

@ -7,32 +7,65 @@ 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()
{
}
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!");
}
}
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) {
ListView list = sender as ListView;
for(int i = 0; i < list.Items.Count; i++) {
if(list.Items[i].Selected) {
window.networkSelected(i);
}
}
}
internal static void VpnSelected(object sender, EventArgs e) {
ListView list = sender as ListView;
for(int i = 0; i < list.Items.Count; i++) {
if(list.Items[i].Selected) {
window.vpnSelected(i);
}
}
}
private void button2_Click(object sender, EventArgs e) {
}
internal static void ChangeOpenVpnFolder(object sender, EventArgs e) {
window.Folderpicker();
}
internal static void ChangeLogFolder(object sender, EventArgs e) {
window.Folderpicker();
}
internal static void ChangeOpenVpnConfigFile(object sender, EventArgs e) {
window.Filepicker();
}
internal static void NetworkAktivate(object sender, EventArgs e) {
MessageBox.Show("Network Verbinden!");
}
internal static void VpnAktivate(object sender, EventArgs e) {
MessageBox.Show("VPN Verbinden!");
}
}
}

View File

@ -6,63 +6,78 @@ using System.Threading.Tasks;
using System.Windows.Forms;
using NetMonitorTray.Properties;
using BlubbFish.Utils;
using NetMonitorUtils;
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;
}
namespace NetMonitorTray.Models {
public class Window : OwnModel<Window> {
private InIReader networkfile;
private InIReader vpnfile;
private InIReader settingsfile;
private NetworkSetter networksetter;
private Window() {
this.init();
}
override protected void init() {
this.networkfile = InIReader.getInstance("network.ini");
this.vpnfile = InIReader.getInstance("vpn.ini");
this.settingsfile = InIReader.getInstance("config.ini");
this.networksetter = new NetworkSetter("network.ini", "config.ini");
}
/// <summary>
/// Listet alle Netzwerke auf
/// </summary>
public List<string> Networks {
get { return this.networkfile.getSections(); }
}
public List<string> Vpns {
get { return this.vpnfile.getSections(); }
}
/// <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;
}
internal string getVpnProperty(string vpn, string property) {
return this.vpnfile.getValue(vpn, property);
}
public string getNetworkProperty(string network, string property) {
return this.networkfile.getValue(network, property);
}
public string getSettingsProperty(string setting, string property) {
return this.settingsfile.getValue(setting, property);
}
public List<string> getNetworkAdapters() {
return this.networksetter.getAdapters();
}
}
}

View File

@ -74,7 +74,12 @@
</ItemGroup>
<ItemGroup>
<Content Include="icon.ico" />
<Content Include="Resources\Icons\add.png" />
<Content Include="Resources\Icons\cancel.png" />
<Content Include="Resources\Icons\disk.png" />
<Content Include="Resources\Icons\door_open.png" />
<Content Include="Resources\Icons\folder.png" />
<Content Include="Resources\Icons\page_gear.png" />
<Content Include="Resources\Icons\server_connect.png" />
<Content Include="Resources\Icons\server_delete.png" />
<Content Include="Resources\Icons\server_link.png" />

View File

@ -6,15 +6,17 @@ using System.Threading.Tasks;
using System.Windows.Forms;
namespace NetMonitorTray
{
class Program
{
static void Main(string[] args)
{
Controller.Tray t = new Controller.Tray();
t.execute();
Application.Run();
}
namespace NetMonitorTray {
class Program {
[STAThread]
static void Main(string[] args) {
try {
Controller.Tray t = new Controller.Tray();
t.execute();
Application.Run();
} catch(Exception e) {
MessageBox.Show("Fehler: " + e.Message + "\nStack: " + e.StackTrace, "Exception: " + e.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@ -60,6 +60,46 @@ namespace NetMonitorTray.Properties {
}
}
/// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap add {
get {
object obj = ResourceManager.GetObject("add", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap delete {
get {
object obj = ResourceManager.GetObject("delete", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap file {
get {
object obj = ResourceManager.GetObject("file", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap folder {
get {
object obj = ResourceManager.GetObject("folder", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol).
/// </summary>
@ -139,5 +179,15 @@ namespace NetMonitorTray.Properties {
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap save {
get {
object obj = ResourceManager.GetObject("save", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -118,6 +118,12 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="add" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\icons\add.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="delete" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\icons\cancel.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="IconConnected" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\connected.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
@ -142,4 +148,13 @@
<data name="MenuImagesServerDisconnect" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Icons\server_delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="save" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\icons\disk.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="file" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\icons\page_gear.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="folder" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\icons\folder.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -41,5 +41,22 @@ namespace NetMonitorTray.View
}
public Models.Window Model { get; private set; }
public string Folderpicker() {
return this.form.FolderPicker();
}
internal void networkSelected(int i) {
this.form.showSelectedNetwork(i);
}
internal void vpnSelected(int i) {
this.form.showSelectedOpenvpn(i);
}
internal string Filepicker() {
return this.form.FilePicker();
}
}
}

View File

@ -28,165 +28,747 @@
/// </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.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.networkButtonDelete = new System.Windows.Forms.Button();
this.networkAdapter = new System.Windows.Forms.ComboBox();
this.label16 = new System.Windows.Forms.Label();
this.networkWins = new System.Windows.Forms.TextBox();
this.label15 = new System.Windows.Forms.Label();
this.networkAutoWins = new System.Windows.Forms.CheckBox();
this.networkDns = new System.Windows.Forms.TextBox();
this.label14 = new System.Windows.Forms.Label();
this.networkAutoDns = new System.Windows.Forms.CheckBox();
this.networkGateway = new System.Windows.Forms.TextBox();
this.label13 = new System.Windows.Forms.Label();
this.networkSubnet = new System.Windows.Forms.TextBox();
this.label12 = new System.Windows.Forms.Label();
this.networkIp = new System.Windows.Forms.TextBox();
this.label11 = new System.Windows.Forms.Label();
this.networkName = new System.Windows.Forms.TextBox();
this.label10 = new System.Windows.Forms.Label();
this.networkButtonSave = new System.Windows.Forms.Button();
this.networkAutoIp = new System.Windows.Forms.CheckBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.networksList = 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.networksAddButton = new System.Windows.Forms.Button();
this.openvpn = new System.Windows.Forms.TabPage();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.openvpnList = new System.Windows.Forms.ListView();
this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.openvpnButtonAdd = new System.Windows.Forms.Button();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.openvpnButtonSave = new System.Windows.Forms.Button();
this.openvpnButtonDelete = new System.Windows.Forms.Button();
this.openvpnConfig = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.openvpnButtonConfigfile = new System.Windows.Forms.Button();
this.openvpnName = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.global = new System.Windows.Forms.TabPage();
this.groupBox8 = new System.Windows.Forms.GroupBox();
this.label8 = new System.Windows.Forms.Label();
this.settingsLogLevel = new System.Windows.Forms.ComboBox();
this.settingsButtonSave = new System.Windows.Forms.Button();
this.settingsFolderPickerLog = new System.Windows.Forms.Button();
this.settingsLogFolder = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.settingsFolderpickerVpn = new System.Windows.Forms.Button();
this.settingsVpnFolder = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.label4 = new System.Windows.Forms.Label();
this.settingsClientPortTo = new System.Windows.Forms.TextBox();
this.settingsClientPortFrom = new System.Windows.Forms.TextBox();
this.settingsServerPort = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.logBox = new System.Windows.Forms.TextBox();
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.tabControl1.SuspendLayout();
this.networks.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout();
this.openvpn.SuspendLayout();
this.groupBox4.SuspendLayout();
this.groupBox3.SuspendLayout();
this.global.SuspendLayout();
this.groupBox8.SuspendLayout();
this.groupBox6.SuspendLayout();
this.groupBox5.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.Controls.Add(this.networkButtonDelete);
this.groupBox2.Controls.Add(this.networkAdapter);
this.groupBox2.Controls.Add(this.label16);
this.groupBox2.Controls.Add(this.networkWins);
this.groupBox2.Controls.Add(this.label15);
this.groupBox2.Controls.Add(this.networkAutoWins);
this.groupBox2.Controls.Add(this.networkDns);
this.groupBox2.Controls.Add(this.label14);
this.groupBox2.Controls.Add(this.networkAutoDns);
this.groupBox2.Controls.Add(this.networkGateway);
this.groupBox2.Controls.Add(this.label13);
this.groupBox2.Controls.Add(this.networkSubnet);
this.groupBox2.Controls.Add(this.label12);
this.groupBox2.Controls.Add(this.networkIp);
this.groupBox2.Controls.Add(this.label11);
this.groupBox2.Controls.Add(this.networkName);
this.groupBox2.Controls.Add(this.label10);
this.groupBox2.Controls.Add(this.networkButtonSave);
this.groupBox2.Controls.Add(this.networkAutoIp);
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 = "Eigenschaften";
//
// networkButtonDelete
//
this.networkButtonDelete.Image = global::NetMonitorTray.Properties.Resources.delete;
this.networkButtonDelete.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.networkButtonDelete.Location = new System.Drawing.Point(220, 251);
this.networkButtonDelete.Name = "networkButtonDelete";
this.networkButtonDelete.Size = new System.Drawing.Size(75, 23);
this.networkButtonDelete.TabIndex = 20;
this.networkButtonDelete.Text = "Löschen";
this.networkButtonDelete.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.networkButtonDelete.UseVisualStyleBackColor = true;
//
// networkAdapter
//
this.networkAdapter.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.networkAdapter.FormattingEnabled = true;
this.networkAdapter.Location = new System.Drawing.Point(9, 231);
this.networkAdapter.Name = "networkAdapter";
this.networkAdapter.Size = new System.Drawing.Size(198, 21);
this.networkAdapter.TabIndex = 19;
//
// label16
//
this.label16.AutoSize = true;
this.label16.Location = new System.Drawing.Point(6, 214);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(47, 13);
this.label16.TabIndex = 18;
this.label16.Text = "Adapter:";
//
// networkWins
//
this.networkWins.Location = new System.Drawing.Point(9, 191);
this.networkWins.Name = "networkWins";
this.networkWins.Size = new System.Drawing.Size(266, 20);
this.networkWins.TabIndex = 17;
//
// label15
//
this.label15.AutoSize = true;
this.label15.Location = new System.Drawing.Point(6, 175);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(34, 13);
this.label15.TabIndex = 16;
this.label15.Text = "Wins:";
//
// networkAutoWins
//
this.networkAutoWins.AutoSize = true;
this.networkAutoWins.Location = new System.Drawing.Point(281, 193);
this.networkAutoWins.Name = "networkAutoWins";
this.networkAutoWins.Size = new System.Drawing.Size(48, 17);
this.networkAutoWins.TabIndex = 15;
this.networkAutoWins.Text = "Auto";
this.networkAutoWins.UseVisualStyleBackColor = true;
//
// networkDns
//
this.networkDns.Location = new System.Drawing.Point(9, 152);
this.networkDns.Name = "networkDns";
this.networkDns.Size = new System.Drawing.Size(266, 20);
this.networkDns.TabIndex = 14;
//
// label14
//
this.label14.AutoSize = true;
this.label14.Location = new System.Drawing.Point(6, 136);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(33, 13);
this.label14.TabIndex = 13;
this.label14.Text = "DNS:";
//
// networkAutoDns
//
this.networkAutoDns.AutoSize = true;
this.networkAutoDns.Location = new System.Drawing.Point(281, 154);
this.networkAutoDns.Name = "networkAutoDns";
this.networkAutoDns.Size = new System.Drawing.Size(48, 17);
this.networkAutoDns.TabIndex = 12;
this.networkAutoDns.Text = "Auto";
this.networkAutoDns.UseVisualStyleBackColor = true;
//
// networkGateway
//
this.networkGateway.Location = new System.Drawing.Point(9, 113);
this.networkGateway.Name = "networkGateway";
this.networkGateway.Size = new System.Drawing.Size(266, 20);
this.networkGateway.TabIndex = 11;
//
// label13
//
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(6, 97);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(52, 13);
this.label13.TabIndex = 10;
this.label13.Text = "Gateway:";
//
// networkSubnet
//
this.networkSubnet.Location = new System.Drawing.Point(145, 74);
this.networkSubnet.Name = "networkSubnet";
this.networkSubnet.Size = new System.Drawing.Size(130, 20);
this.networkSubnet.TabIndex = 8;
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(142, 58);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(44, 13);
this.label12.TabIndex = 7;
this.label12.Text = "Subnet:";
//
// networkIp
//
this.networkIp.Location = new System.Drawing.Point(9, 74);
this.networkIp.Name = "networkIp";
this.networkIp.Size = new System.Drawing.Size(130, 20);
this.networkIp.TabIndex = 5;
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(6, 58);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(20, 13);
this.label11.TabIndex = 4;
this.label11.Text = "IP:";
//
// networkName
//
this.networkName.Location = new System.Drawing.Point(9, 35);
this.networkName.Name = "networkName";
this.networkName.Size = new System.Drawing.Size(266, 20);
this.networkName.TabIndex = 3;
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(6, 19);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(38, 13);
this.label10.TabIndex = 2;
this.label10.Text = "Name:";
//
// networkButtonSave
//
this.networkButtonSave.Image = global::NetMonitorTray.Properties.Resources.save;
this.networkButtonSave.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.networkButtonSave.Location = new System.Drawing.Point(301, 251);
this.networkButtonSave.Name = "networkButtonSave";
this.networkButtonSave.Size = new System.Drawing.Size(81, 23);
this.networkButtonSave.TabIndex = 1;
this.networkButtonSave.Text = "Speichern";
this.networkButtonSave.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.networkButtonSave.UseVisualStyleBackColor = true;
//
// networkAutoIp
//
this.networkAutoIp.AutoSize = true;
this.networkAutoIp.Location = new System.Drawing.Point(281, 76);
this.networkAutoIp.Name = "networkAutoIp";
this.networkAutoIp.Size = new System.Drawing.Size(48, 17);
this.networkAutoIp.TabIndex = 0;
this.networkAutoIp.Text = "Auto";
this.networkAutoIp.UseVisualStyleBackColor = true;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.networksList);
this.groupBox1.Controls.Add(this.networksAddButton);
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 = "Alle Netzwerke";
//
// networksList
//
this.networksList.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();
this.networksList.FullRowSelect = true;
this.networksList.GridLines = true;
this.networksList.HideSelection = false;
this.networksList.Location = new System.Drawing.Point(7, 19);
this.networksList.MultiSelect = false;
this.networksList.Name = "networksList";
this.networksList.ShowGroups = false;
this.networksList.Size = new System.Drawing.Size(164, 226);
this.networksList.TabIndex = 2;
this.networksList.UseCompatibleStateImageBehavior = false;
this.networksList.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "ID";
//
// columnHeader2
//
this.columnHeader2.Text = "Label";
this.columnHeader2.Width = 100;
//
// networksAddButton
//
this.networksAddButton.Image = global::NetMonitorTray.Properties.Resources.add;
this.networksAddButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.networksAddButton.Location = new System.Drawing.Point(7, 251);
this.networksAddButton.Name = "networksAddButton";
this.networksAddButton.Size = new System.Drawing.Size(164, 23);
this.networksAddButton.TabIndex = 1;
this.networksAddButton.Text = "Netzwerk Hinzufügen";
this.networksAddButton.UseVisualStyleBackColor = true;
//
// openvpn
//
this.openvpn.Controls.Add(this.groupBox4);
this.openvpn.Controls.Add(this.groupBox3);
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;
//
// groupBox4
//
this.groupBox4.Controls.Add(this.openvpnList);
this.groupBox4.Controls.Add(this.openvpnButtonAdd);
this.groupBox4.Location = new System.Drawing.Point(6, 6);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(177, 283);
this.groupBox4.TabIndex = 5;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "Alle Vpn Netze";
//
// openvpnList
//
this.openvpnList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader3,
this.columnHeader4});
this.openvpnList.FullRowSelect = true;
this.openvpnList.GridLines = true;
this.openvpnList.HideSelection = false;
this.openvpnList.Location = new System.Drawing.Point(7, 19);
this.openvpnList.MultiSelect = false;
this.openvpnList.Name = "openvpnList";
this.openvpnList.ShowGroups = false;
this.openvpnList.Size = new System.Drawing.Size(164, 226);
this.openvpnList.TabIndex = 2;
this.openvpnList.UseCompatibleStateImageBehavior = false;
this.openvpnList.View = System.Windows.Forms.View.Details;
//
// columnHeader3
//
this.columnHeader3.Text = "ID";
//
// columnHeader4
//
this.columnHeader4.Text = "Label";
this.columnHeader4.Width = 100;
//
// openvpnButtonAdd
//
this.openvpnButtonAdd.Image = global::NetMonitorTray.Properties.Resources.add;
this.openvpnButtonAdd.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.openvpnButtonAdd.Location = new System.Drawing.Point(7, 251);
this.openvpnButtonAdd.Name = "openvpnButtonAdd";
this.openvpnButtonAdd.Size = new System.Drawing.Size(164, 23);
this.openvpnButtonAdd.TabIndex = 1;
this.openvpnButtonAdd.Text = "OpenVPN Hinzufügen";
this.openvpnButtonAdd.UseVisualStyleBackColor = true;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.openvpnButtonSave);
this.groupBox3.Controls.Add(this.openvpnButtonDelete);
this.groupBox3.Controls.Add(this.openvpnConfig);
this.groupBox3.Controls.Add(this.label7);
this.groupBox3.Controls.Add(this.openvpnButtonConfigfile);
this.groupBox3.Controls.Add(this.openvpnName);
this.groupBox3.Controls.Add(this.label6);
this.groupBox3.Location = new System.Drawing.Point(189, 6);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(388, 283);
this.groupBox3.TabIndex = 4;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Eigenschaften";
//
// openvpnButtonSave
//
this.openvpnButtonSave.Image = global::NetMonitorTray.Properties.Resources.save;
this.openvpnButtonSave.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.openvpnButtonSave.Location = new System.Drawing.Point(303, 251);
this.openvpnButtonSave.Name = "openvpnButtonSave";
this.openvpnButtonSave.Size = new System.Drawing.Size(79, 23);
this.openvpnButtonSave.TabIndex = 6;
this.openvpnButtonSave.Text = "Speichern";
this.openvpnButtonSave.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.openvpnButtonSave.UseVisualStyleBackColor = true;
//
// openvpnButtonDelete
//
this.openvpnButtonDelete.Image = global::NetMonitorTray.Properties.Resources.delete;
this.openvpnButtonDelete.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.openvpnButtonDelete.Location = new System.Drawing.Point(222, 251);
this.openvpnButtonDelete.Name = "openvpnButtonDelete";
this.openvpnButtonDelete.Size = new System.Drawing.Size(75, 23);
this.openvpnButtonDelete.TabIndex = 5;
this.openvpnButtonDelete.Text = "Löschen";
this.openvpnButtonDelete.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.openvpnButtonDelete.UseVisualStyleBackColor = true;
//
// openvpnConfig
//
this.openvpnConfig.Location = new System.Drawing.Point(9, 71);
this.openvpnConfig.Name = "openvpnConfig";
this.openvpnConfig.ReadOnly = true;
this.openvpnConfig.Size = new System.Drawing.Size(248, 20);
this.openvpnConfig.TabIndex = 4;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(6, 55);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(60, 13);
this.label7.TabIndex = 3;
this.label7.Text = "Configdatei";
//
// openvpnButtonConfigfile
//
this.openvpnButtonConfigfile.Image = global::NetMonitorTray.Properties.Resources.file;
this.openvpnButtonConfigfile.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.openvpnButtonConfigfile.Location = new System.Drawing.Point(263, 69);
this.openvpnButtonConfigfile.Name = "openvpnButtonConfigfile";
this.openvpnButtonConfigfile.Size = new System.Drawing.Size(92, 23);
this.openvpnButtonConfigfile.TabIndex = 2;
this.openvpnButtonConfigfile.Text = "Datei öffnen";
this.openvpnButtonConfigfile.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.openvpnButtonConfigfile.UseVisualStyleBackColor = true;
//
// openvpnName
//
this.openvpnName.Location = new System.Drawing.Point(9, 32);
this.openvpnName.Name = "openvpnName";
this.openvpnName.Size = new System.Drawing.Size(248, 20);
this.openvpnName.TabIndex = 1;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(6, 16);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(35, 13);
this.label6.TabIndex = 0;
this.label6.Text = "Name";
//
// global
//
this.global.Controls.Add(this.groupBox8);
this.global.Controls.Add(this.groupBox6);
this.global.Controls.Add(this.groupBox5);
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;
//
// groupBox8
//
this.groupBox8.Controls.Add(this.label8);
this.groupBox8.Controls.Add(this.settingsLogLevel);
this.groupBox8.Controls.Add(this.settingsButtonSave);
this.groupBox8.Controls.Add(this.settingsFolderPickerLog);
this.groupBox8.Controls.Add(this.settingsLogFolder);
this.groupBox8.Controls.Add(this.label9);
this.groupBox8.Location = new System.Drawing.Point(3, 80);
this.groupBox8.Name = "groupBox8";
this.groupBox8.Size = new System.Drawing.Size(577, 99);
this.groupBox8.TabIndex = 2;
this.groupBox8.TabStop = false;
this.groupBox8.Text = "Allgemein";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(6, 55);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(125, 13);
this.label8.TabIndex = 5;
this.label8.Text = "Server-Log Einstellungen";
//
// settingsLogLevel
//
this.settingsLogLevel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.settingsLogLevel.FormattingEnabled = true;
this.settingsLogLevel.Location = new System.Drawing.Point(9, 71);
this.settingsLogLevel.Name = "settingsLogLevel";
this.settingsLogLevel.Size = new System.Drawing.Size(121, 21);
this.settingsLogLevel.TabIndex = 4;
//
// settingsButtonSave
//
this.settingsButtonSave.Image = global::NetMonitorTray.Properties.Resources.save;
this.settingsButtonSave.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.settingsButtonSave.Location = new System.Drawing.Point(489, 69);
this.settingsButtonSave.Name = "settingsButtonSave";
this.settingsButtonSave.Size = new System.Drawing.Size(82, 23);
this.settingsButtonSave.TabIndex = 3;
this.settingsButtonSave.Text = "Speichern";
this.settingsButtonSave.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.settingsButtonSave.UseVisualStyleBackColor = true;
//
// settingsFolderPickerLog
//
this.settingsFolderPickerLog.Image = global::NetMonitorTray.Properties.Resources.folder;
this.settingsFolderPickerLog.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.settingsFolderPickerLog.Location = new System.Drawing.Point(289, 30);
this.settingsFolderPickerLog.Name = "settingsFolderPickerLog";
this.settingsFolderPickerLog.Size = new System.Drawing.Size(66, 23);
this.settingsFolderPickerLog.TabIndex = 3;
this.settingsFolderPickerLog.Text = "Ändern";
this.settingsFolderPickerLog.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.settingsFolderPickerLog.UseVisualStyleBackColor = true;
//
// settingsLogFolder
//
this.settingsLogFolder.Location = new System.Drawing.Point(9, 32);
this.settingsLogFolder.Name = "settingsLogFolder";
this.settingsLogFolder.ReadOnly = true;
this.settingsLogFolder.Size = new System.Drawing.Size(274, 20);
this.settingsLogFolder.TabIndex = 2;
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(6, 16);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(85, 13);
this.label9.TabIndex = 1;
this.label9.Text = "Log Verzeichnis:";
//
// groupBox6
//
this.groupBox6.Controls.Add(this.settingsFolderpickerVpn);
this.groupBox6.Controls.Add(this.settingsVpnFolder);
this.groupBox6.Controls.Add(this.label5);
this.groupBox6.Location = new System.Drawing.Point(209, 3);
this.groupBox6.Name = "groupBox6";
this.groupBox6.Size = new System.Drawing.Size(371, 77);
this.groupBox6.TabIndex = 1;
this.groupBox6.TabStop = false;
this.groupBox6.Text = "VPN";
//
// settingsFolderpickerVpn
//
this.settingsFolderpickerVpn.Image = global::NetMonitorTray.Properties.Resources.folder;
this.settingsFolderpickerVpn.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.settingsFolderpickerVpn.Location = new System.Drawing.Point(290, 44);
this.settingsFolderpickerVpn.Name = "settingsFolderpickerVpn";
this.settingsFolderpickerVpn.Size = new System.Drawing.Size(66, 23);
this.settingsFolderpickerVpn.TabIndex = 2;
this.settingsFolderpickerVpn.Text = "Ändern";
this.settingsFolderpickerVpn.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.settingsFolderpickerVpn.UseVisualStyleBackColor = true;
//
// settingsVpnFolder
//
this.settingsVpnFolder.Location = new System.Drawing.Point(10, 46);
this.settingsVpnFolder.Name = "settingsVpnFolder";
this.settingsVpnFolder.ReadOnly = true;
this.settingsVpnFolder.Size = new System.Drawing.Size(274, 20);
this.settingsVpnFolder.TabIndex = 1;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(7, 23);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(148, 13);
this.label5.TabIndex = 0;
this.label5.Text = "OpenVpn Installations Ordner:";
//
// groupBox5
//
this.groupBox5.Controls.Add(this.label4);
this.groupBox5.Controls.Add(this.settingsClientPortTo);
this.groupBox5.Controls.Add(this.settingsClientPortFrom);
this.groupBox5.Controls.Add(this.settingsServerPort);
this.groupBox5.Controls.Add(this.label3);
this.groupBox5.Controls.Add(this.label2);
this.groupBox5.Location = new System.Drawing.Point(3, 3);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(200, 77);
this.groupBox5.TabIndex = 0;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "UDP Ports";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(121, 49);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(10, 13);
this.label4.TabIndex = 5;
this.label4.Text = "-";
//
// settingsClientPortTo
//
this.settingsClientPortTo.Location = new System.Drawing.Point(137, 46);
this.settingsClientPortTo.Name = "settingsClientPortTo";
this.settingsClientPortTo.Size = new System.Drawing.Size(40, 20);
this.settingsClientPortTo.TabIndex = 4;
//
// settingsClientPortFrom
//
this.settingsClientPortFrom.Location = new System.Drawing.Point(77, 46);
this.settingsClientPortFrom.Name = "settingsClientPortFrom";
this.settingsClientPortFrom.Size = new System.Drawing.Size(38, 20);
this.settingsClientPortFrom.TabIndex = 3;
//
// settingsServerPort
//
this.settingsServerPort.Location = new System.Drawing.Point(77, 20);
this.settingsServerPort.Name = "settingsServerPort";
this.settingsServerPort.Size = new System.Drawing.Size(100, 20);
this.settingsServerPort.TabIndex = 2;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(6, 49);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(63, 13);
this.label3.TabIndex = 1;
this.label3.Text = "Client Ports:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(6, 23);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(63, 13);
this.label2.TabIndex = 0;
this.label2.Text = "Server Port:";
//
// 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(59, 13);
this.label1.TabIndex = 2;
this.label1.Text = "Server-Log";
//
// 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;
//
// openFileDialog1
//
this.openFileDialog1.FileName = "openFileDialog1";
//
// 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.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.openvpn.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.global.ResumeLayout(false);
this.groupBox8.ResumeLayout(false);
this.groupBox8.PerformLayout();
this.groupBox6.ResumeLayout(false);
this.groupBox6.PerformLayout();
this.groupBox5.ResumeLayout(false);
this.groupBox5.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
@ -200,10 +782,62 @@
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.Button networksAddButton;
private System.Windows.Forms.TabPage global;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.ListView networksList;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.ListView openvpnList;
private System.Windows.Forms.ColumnHeader columnHeader3;
private System.Windows.Forms.ColumnHeader columnHeader4;
private System.Windows.Forms.Button openvpnButtonAdd;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.GroupBox groupBox5;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.GroupBox groupBox6;
private System.Windows.Forms.Button settingsFolderpickerVpn;
private System.Windows.Forms.TextBox settingsVpnFolder;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox settingsClientPortTo;
private System.Windows.Forms.TextBox settingsClientPortFrom;
private System.Windows.Forms.TextBox settingsServerPort;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
private System.Windows.Forms.Button networkButtonDelete;
private System.Windows.Forms.ComboBox networkAdapter;
private System.Windows.Forms.Label label16;
private System.Windows.Forms.TextBox networkWins;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.CheckBox networkAutoWins;
private System.Windows.Forms.TextBox networkDns;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.CheckBox networkAutoDns;
private System.Windows.Forms.TextBox networkGateway;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.TextBox networkSubnet;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.TextBox networkIp;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.TextBox networkName;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Button networkButtonSave;
private System.Windows.Forms.CheckBox networkAutoIp;
private System.Windows.Forms.GroupBox groupBox8;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.ComboBox settingsLogLevel;
private System.Windows.Forms.Button settingsButtonSave;
private System.Windows.Forms.Button settingsFolderPickerLog;
private System.Windows.Forms.TextBox settingsLogFolder;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Button openvpnButtonSave;
private System.Windows.Forms.Button openvpnButtonDelete;
private System.Windows.Forms.TextBox openvpnConfig;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Button openvpnButtonConfigfile;
private System.Windows.Forms.TextBox openvpnName;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
}
}

View File

@ -7,38 +7,181 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BlubbFish.Utils;
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;
}
namespace NetMonitorTray.View {
public partial class ViewWindowForm : Form {
private Models.Window model;
private int clickedNetwork = 0;
private int clickedVpn = 0;
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 ViewWindowForm() {
this.InitializeComponent();
this.FormClosed += Controller.Window.FormClosed;
public void SetModel(Models.Window window)
{
this.model = window;
}
this.networksList.ItemActivate += Controller.Window.NetworkAktivate;
this.openvpnList.ItemActivate += Controller.Window.VpnAktivate;
this.networksList.Click += Controller.Window.NetworkSelected;
this.openvpnList.Click += Controller.Window.VpnSelected;
this.settingsFolderpickerVpn.Click += new System.EventHandler(Controller.Window.ChangeOpenVpnFolder);
this.openvpnButtonConfigfile.Click += new System.EventHandler(Controller.Window.ChangeOpenVpnConfigFile);
this.settingsFolderPickerLog.Click += new System.EventHandler(Controller.Window.ChangeLogFolder);
}
public void UpdateForm() {
this.BeginInvoke((Action)(() => {
updateLog();
updateNetworks();
updateVpn();
updateSettings();
}));
}
private void updateLog() {
this.logBox.Text = "TODO: Read Log File";
}
private void updateVpn() {
List<string> vpns = this.model.Vpns;
foreach(string vpn in vpns) {
ListViewItem item = new ListViewItem();
item.Text = vpn;
item.SubItems.Add(this.model.getVpnProperty(vpn, "Name"));
openvpnList.Items.Add(item);
}
showSelectedOpenvpn(clickedVpn);
}
public void showSelectedOpenvpn(int i) {
List<string> vpns = this.model.Vpns;
if(vpns.Count == 0) {
return;
}
if(vpns.Count <= i) {
i = 0;
}
for(int j = 0; j < this.openvpnList.Items.Count; j++) {
if(j == i) {
this.openvpnList.Items[j].Selected = true;
} else {
this.openvpnList.Items[j].Selected = false;
}
string n = vpns[i];
string v = this.model.getVpnProperty(n, "Name");
this.openvpnName.Text = v;
v = this.model.getVpnProperty(n, "Config");
this.openvpnConfig.Text = v;
}
}
private void updateNetworks() {
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"));
networksList.Items.Add(item);
}
List<string> adapters = this.model.getNetworkAdapters();
this.networkAdapter.Items.AddRange(adapters.ToArray<string>());
showSelectedNetwork(clickedNetwork);
}
public void showSelectedNetwork(int i) {
List<string> networks = this.model.Networks;
if(networks.Count == 0) {
return;
}
if(networks.Count <= i) {
i = 0;
}
for(int j=0; j<this.networksList.Items.Count;j++) {
if(j == i) {
this.networksList.Items[j].Selected = true;
} else {
this.networksList.Items[j].Selected = false;
}
}
string n = networks[i];
string v = this.model.getNetworkProperty(n, "Name");
this.networkName.Text = v;
v = this.model.getNetworkProperty(n, "Ip");
if(v == "auto") {
this.networkIp.ReadOnly = true;
this.networkIp.Text = "";
this.networkSubnet.ReadOnly = true;
this.networkSubnet.Text = "";
this.networkGateway.ReadOnly = true;
this.networkGateway.Text = "";
this.networkAutoIp.Checked = true;
} else {
this.networkIp.ReadOnly = false;
this.networkIp.Text = v;
v = this.model.getNetworkProperty(n, "Subnet");
this.networkSubnet.ReadOnly = false;
this.networkSubnet.Text = v;
v = this.model.getNetworkProperty(n, "Gateway");
this.networkGateway.ReadOnly = false;
this.networkGateway.Text = v;
this.networkAutoIp.Checked = false;
}
v = this.model.getNetworkProperty(n, "Dns");
if(v == "auto") {
this.networkDns.ReadOnly = true;
this.networkDns.Text = "";
this.networkAutoDns.Checked = true;
} else {
this.networkDns.ReadOnly = false;
this.networkDns.Text = v;
this.networkAutoDns.Checked = false;
}
v = this.model.getNetworkProperty(n, "Wins");
if(v == "auto") {
this.networkWins.ReadOnly = true;
this.networkWins.Text = "";
this.networkAutoWins.Checked = true;
} else {
this.networkWins.ReadOnly = false;
this.networkWins.Text = v;
this.networkAutoWins.Checked = false;
}
v = this.model.getNetworkProperty(n, "Adapter");
this.networkAdapter.Text = v;
}
private void updateSettings() {
settingsServerPort.Text = this.model.getSettingsProperty("ports", "server");
settingsClientPortFrom.Text = this.model.getSettingsProperty("ports", "client_from");
settingsClientPortTo.Text = this.model.getSettingsProperty("ports", "client_to");
settingsVpnFolder.Text = this.model.getSettingsProperty("program", "openvpn");
settingsLogFolder.Text = this.model.getSettingsProperty("program", "logfolder");
foreach(OwnObject.LogLevel item in Enum.GetValues(typeof(OwnObject.LogLevel))) {
settingsLogLevel.Items.Add(item.ToString());
}
settingsLogLevel.Text = this.model.getSettingsProperty("program", "loglevel");
}
public void SetModel(Models.Window window) {
this.model = window;
}
public string FolderPicker() {
DialogResult r = this.folderBrowserDialog1.ShowDialog();
if(r == System.Windows.Forms.DialogResult.OK) {
return this.folderBrowserDialog1.SelectedPath;
}
return null;
}
internal string FilePicker() {
DialogResult r = this.openFileDialog1.ShowDialog();
if(r == System.Windows.Forms.DialogResult.OK) {
return this.openFileDialog1.FileName;
}
return null;
}
}
}

View File

@ -120,4 +120,10 @@
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>133, 17</value>
</metadata>
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>302, 17</value>
</metadata>
</root>

View File

@ -248,5 +248,9 @@ namespace NetMonitorUtils
}
return ret;
}
public List<string> getAdapters() {
return this.serviceController.NetworkGetAdapters();
}
}
}

View File

@ -37,10 +37,10 @@ namespace NetMonitorUtils {
String data = this.serviceController.VpnGetStatus(vpn);
if(data == "unknown") {
ret.Add(vpn, "unknown");
} else if(data == "disconnected") {
ret.Add(vpn, "disconnected");
} else if(data.StartsWith("[connected")) {
ret.Add(vpn, "connected");
} else {
ret.Add(vpn, "disconnected");
}
}
return ret;

View File

@ -236,5 +236,17 @@ namespace NetMonitorUtils {
}
return this.sendMessage("OPENVPN", "STOP " + name);
}
internal List<string> NetworkGetAdapters() {
String adapters = "";
try {
this.sendMessage("NET", "ADAPTERS");
} catch(ServiceControlException e) {
if(e.Message.ToLower().Substring(0, 1) == "[") {
adapters = e.Message.Substring(0, e.Message.Length - 1).Substring(1);
}
}
return adapters.Split('|').ToList<string>();
}
}
}

View File

@ -4,4 +4,6 @@ client_from=54330
client_to=54340
[program]
openvpn=C:\Program Files\OpenVPN
openvpn=C:\Program Files\OpenVPN
logfolder=E:\Programme\NetMonitor\logs
loglevel=Debug

View File

@ -7,7 +7,7 @@ Adapter=LAN-Verbindung
[network2]
Name=FHG
Ip=129.26.164.188
Ip=129.26.164.222
Subnet=255.255.248.0
Gateway=129.26.160.1
Dns=129.26.165.177
@ -19,8 +19,8 @@ Name=Test
Ip=10.15.20.25
Subnet=255.255.255.0
Gateway=0.0.0.0
Dns=none
Wins=none
Dns=0.0.0.0
Wins=0.0.0.0
Adapter=LAN-Verbindung
[network4]

View File

@ -28,7 +28,7 @@
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>E:\Programme\NetMonitor\</OutputPath>
<OutputPath>..\bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -4,4 +4,6 @@ client_from=54330
client_to=54340
[program]
openvpn=C:\Program Files\OpenVPN
openvpn=C:\Program Files\OpenVPN
logfolder=E:\Programme\NetMonitor\logs
loglevel=Debug

View File

@ -7,7 +7,7 @@ Adapter=LAN-Verbindung
[network2]
Name=FHG
Ip=129.26.164.188
Ip=129.26.164.222
Subnet=255.255.248.0
Gateway=129.26.160.1
Dns=129.26.165.177
@ -19,8 +19,8 @@ Name=Test
Ip=10.15.20.25
Subnet=255.255.255.0
Gateway=0.0.0.0
Dns=none
Wins=none
Dns=0.0.0.0
Wins=0.0.0.0
Adapter=LAN-Verbindung
[network4]

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bin/Release/Utils.dll Normal file

Binary file not shown.

9
bin/Release/config.ini Normal file
View File

@ -0,0 +1,9 @@
[ports]
server=54323
client_from=54330
client_to=54340
[program]
openvpn=C:\Program Files\OpenVPN
logfolder=E:\Programme\NetMonitor\logs
loglevel=Debug

40
bin/Release/network.ini Normal file
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.222
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=0.0.0.0
Wins=0.0.0.0
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/Release/vpn.ini Normal file
View File

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