More cleanup and tests

This commit is contained in:
SChernykh
2026-03-08 20:30:07 +01:00
parent 0019d9ff0d
commit b05361653e
7 changed files with 40 additions and 22 deletions
+3 -4
View File
@@ -17,6 +17,7 @@
*/
#include "common.h"
#include "util.h"
#include "i2p.h"
LOG_CATEGORY(I2P)
@@ -35,9 +36,7 @@ hash from_i2p_b32(const std::string& address)
return {};
}
size_t pos = address.find('.');
const std::string dest_hash = address.substr(0, pos);
const hash result = from_i2p_b32_const(dest_hash.c_str());
const hash result = from_i2p_b32_const(address.c_str());
if (result.empty()) {
LOGWARN(3, "Invalid I2P address \"" << address << "\": has invalid character(s)");
@@ -65,7 +64,7 @@ std::string to_i2p_b32(const hash& dest_hash)
while (bit_size >= 5) {
bit_size -= 5;
result += "abcdefghijklmnopqrstuvwxyz234567"[(data >> bit_size) & 31];
result += base32_alphabet[(data >> bit_size) & 31];
}
}
+1 -1
View File
@@ -986,7 +986,7 @@ std::string to_onion_v3(const hash& pubkey)
while (bit_size >= 5) {
bit_size -= 5;
result += "abcdefghijklmnopqrstuvwxyz234567"[(data >> bit_size) & 31];
result += base32_alphabet[(data >> bit_size) & 31];
}
}
+2
View File
@@ -407,6 +407,8 @@ FORCEINLINE std::string tolower(const std::string& s)
return result;
}
constexpr char base32_alphabet[] = "abcdefghijklmnopqrstuvwxyz234567";
std::string to_onion_v3(const hash& pubkey);
hash from_onion_v3(const std::string& address);