masscheckin ganz viel kram

This commit is contained in:
2015-11-16 00:10:59 +00:00
parent 8264cbfa7b
commit dfc14d9c36
45 changed files with 1862 additions and 834 deletions
@@ -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();