More cleanup and tests
This commit is contained in:
+3
-4
@@ -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
@@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user