Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Maslakov committed Nov 8, 2015
1 parent 681ca94 commit 1cb7c28
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions OpenVpnManagement/Manager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public enum State {

private Socket socket;
private const int bufferSize = 1024;
private string? ovpnFilePath;
private string ovpnFilePath;

private void RunOpenVpnProcess() {
Process prc = new Process();
Expand All @@ -43,12 +43,12 @@ private void RunOpenVpnProcess() {
prc.StartInfo.WorkingDirectory = @"C:\Program Files\OpenVPN\config";
prc.Start();
}
public Manager(string host, int port, string? ovpnFilePath) {
if (ovpnFilePath != null && ovpnFilePath.ToString() != string.Empty) {
var ovpnFilePath2 = ovpnFilePath.ToString();
var res = File.ReadAllLines(ovpnFilePath2).Where(x => x == "management ");

public Manager(string host, int port, string ovpnFilePath) {
if (!string.IsNullOrEmpty(ovpnFilePath)) {
var res = File.ReadAllLines(ovpnFilePath).Where(x => x == "management ");
if (!res.Any()) {
File.AppendAllText(ovpnFilePath2, string.Format("management {} {}", host, port));
File.AppendAllText(ovpnFilePath, string.Format("management {} {}", host, port));
}

RunOpenVpnProcess();
Expand Down Expand Up @@ -201,7 +201,7 @@ private string SendCommand(String cmd) {

public void Dispose() {
if (socket != null) {
if (ovpnFilePath != null && ovpnFilePath != string.Empty) {
if (ovpnFilePath != null) {
SendSignal(Signal.Term);
}

Expand Down

0 comments on commit 1cb7c28

Please sign in to comment.