Version 1.0.0
This commit is contained in:
@@ -41,4 +41,27 @@ namespace ColumnLynx::Utils {
|
||||
randombytes_buf(randbytes.data(), randbytes.size());
|
||||
return randbytes;
|
||||
}
|
||||
|
||||
bool LibSodiumWrapper::recomputeKeys(PrivateSeed privateSeed, PublicKey storedPubKey) {
|
||||
int res = crypto_sign_seed_keypair(mPublicKey.data(), mPrivateKey.data(), privateSeed.data());
|
||||
|
||||
if (res != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Convert to Curve25519 keys for encryption
|
||||
res = crypto_sign_ed25519_pk_to_curve25519(mXPublicKey.data(), mPublicKey.data());
|
||||
res = crypto_sign_ed25519_sk_to_curve25519(mXPrivateKey.data(), mPrivateKey.data());
|
||||
|
||||
if (res != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Compare to stored for verification
|
||||
if (sodium_memcmp(mPublicKey.data(), storedPubKey.data(), crypto_sign_PUBLICKEYBYTES) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ namespace ColumnLynx::Utils {
|
||||
}
|
||||
|
||||
std::string getVersion() {
|
||||
return "b0.3";
|
||||
return "1.0.0";
|
||||
}
|
||||
|
||||
unsigned short serverPort() {
|
||||
@@ -101,14 +101,19 @@ namespace ColumnLynx::Utils {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
std::vector<std::string> getWhitelistedKeys() {
|
||||
std::vector<std::string> getWhitelistedKeys(std::string basePath) {
|
||||
// Currently re-reads the file every time, should be fine.
|
||||
// Advantage of it is that you don't need to reload the server binary after adding/removing keys. Disadvantage is re-reading the file every time.
|
||||
// I might redo this part.
|
||||
|
||||
std::vector<std::string> out;
|
||||
|
||||
std::ifstream file("whitelisted_keys"); // TODO: This is hardcoded for now, make dynamic
|
||||
std::ifstream file(basePath + "whitelisted_keys");
|
||||
if (!file.is_open()) {
|
||||
warn("Failed to open whitelisted_keys file at path: " + basePath + "whitelisted_keys");
|
||||
return out;
|
||||
}
|
||||
|
||||
std::string line;
|
||||
|
||||
while (std::getline(file, line)) {
|
||||
@@ -123,6 +128,10 @@ namespace ColumnLynx::Utils {
|
||||
std::vector<std::string> readLines;
|
||||
|
||||
std::ifstream file(path);
|
||||
if (!file.is_open()) {
|
||||
throw std::runtime_error("Failed to open config file at path: " + path);
|
||||
}
|
||||
|
||||
std::string line;
|
||||
|
||||
while (std::getline(file, line)) {
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace ColumnLynx::Net {
|
||||
|
||||
if (ioctl(mFd, TUNSETIFF, &ifr) < 0) {
|
||||
close(mFd);
|
||||
throw std::runtime_error("TUNSETIFF failed: " + std::string(strerror(errno)));
|
||||
throw std::runtime_error("TUNSETIFF failed (try running with sudo): " + std::string(strerror(errno)));
|
||||
}
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
@@ -96,7 +96,7 @@ namespace ColumnLynx::Net {
|
||||
|
||||
if (connect(mFd, (struct sockaddr*)&sc, sizeof(sc)) < 0) {
|
||||
if (errno == EPERM)
|
||||
throw std::runtime_error("connect(AF_SYS_CONTROL) failed: Insufficient permissions (try running as root)");
|
||||
throw std::runtime_error("connect(AF_SYS_CONTROL) failed: Insufficient permissions (try running with sudo)");
|
||||
throw std::runtime_error("connect(AF_SYS_CONTROL) failed: " + std::string(strerror(errno)));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user