Skip to content

Commit

Permalink
Update CLR version to prevent required folders being removed by using…
Browse files Browse the repository at this point in the history
… a temp directory for clients.

Various bug fixes.
  • Loading branch information
Eric Thorpe committed Jun 23, 2021
1 parent 72436c7 commit 44dd949
Show file tree
Hide file tree
Showing 2 changed files with 1,039 additions and 6 deletions.
20 changes: 14 additions & 6 deletions clr/Interactive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Interactive::Interactive(String ^ path, OpenSSLHelper::Algorithm algorithm, int
bool Interactive::LoadConfig()
{
if (!File::Exists(this->configPath)) {
Console::WriteLine("ERROR: Configuration not found.");
Console::WriteLine("Change directory to location of configuration, use --path, or run init.");
return false;
}

Expand Down Expand Up @@ -269,7 +271,7 @@ bool Interactive::CreateServerConfig()
file += "dh none\n";
file += "# Note this curve probably isn't supported (yet), however OpenVPN will fall back to another (secp384r1)\n";
file += "ecdh-curve " + this->curveName + "\n";
file += "tls-cipher TLS_AES_256_GCM_SHA384\n";
file += "tls-ciphersuites TLS_AES_256_GCM_SHA384\n";
}
else { // ecdsa
file += "tls-version-min 1.2\n";
Expand Down Expand Up @@ -424,10 +426,15 @@ bool Interactive::CreateNewClientConfig(String ^ name)
}
}
String^ clientPath = Path::Combine(this->path, CN);
if (Directory::Exists(clientPath)) {
int i = 0;
do
{
i++;
clientPath = Path::Combine(this->path, CN + "_" + i.ToString());
} while (Directory::Exists(clientPath));
}
try {
if (Directory::Exists(clientPath)) {
Directory::Delete(clientPath, true);
}
Directory::CreateDirectory(clientPath);
}
catch (Exception^ e) {
Expand Down Expand Up @@ -620,6 +627,7 @@ bool Interactive::createVisz(String^ fileName, String ^ folder)
TarArchive^ tarArchive = TarArchive::CreateOutputTarArchive(gzoStream);

String^ rootPath = Directory::GetParent(folder)->ToString();
String^ folderName = Path::GetFileName(folder);
tarArchive->RootPath = rootPath->Replace('\\', '/');
if (tarArchive->RootPath->EndsWith("/")) {
tarArchive->RootPath = tarArchive->RootPath->Remove(tarArchive->RootPath->Length);
Expand All @@ -631,8 +639,8 @@ bool Interactive::createVisz(String^ fileName, String ^ folder)
// We can only have one directory deep in the tar, so set the current directory in case the folder isn't
// at the current root, then use the filename as it will be the dir name
Directory::SetCurrentDirectory(rootPath);
TarEntry^ entry = TarEntry::CreateEntryFromFile(fileName);
entry->Name = fileName;
TarEntry^ entry = TarEntry::CreateEntryFromFile(folderName);
entry->Name = folderName;
tarArchive->WriteEntry(entry, true);
tarArchive->Close();
return true;
Expand Down
Loading

0 comments on commit 44dd949

Please sign in to comment.