mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-29 01:16:20 -05:00
i2p: bob: use common i2p::keyToBase32Addr()
This commit is contained in:
parent
462f52585b
commit
4b6e12ca45
@ -250,28 +250,6 @@ void p3I2pBob::processTaskSync(taskTicket *ticket)
|
||||
}
|
||||
}
|
||||
|
||||
std::string p3I2pBob::keyToBase32Addr(const std::string &key)
|
||||
{
|
||||
std::string copy(key);
|
||||
|
||||
// replace I2P specific chars
|
||||
std::replace(copy.begin(), copy.end(), '~', '/');
|
||||
std::replace(copy.begin(), copy.end(), '-', '+');
|
||||
|
||||
// decode
|
||||
std::vector<uint8_t> bin = Radix64::decode(copy);
|
||||
// hash
|
||||
std::vector<uint8_t> sha256 = RsUtil::BinToSha256(bin);
|
||||
// encode
|
||||
std::string out = Radix32::encode(sha256);
|
||||
|
||||
// i2p uses lowercase
|
||||
std::transform(out.begin(), out.end(), out.begin(), ::tolower);
|
||||
out.append(".b32.i2p");
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
bool inline isAnswerOk(const std::string &answer) {
|
||||
return (answer.compare(0, 2, "OK") == 0);
|
||||
}
|
||||
@ -346,7 +324,7 @@ int p3I2pBob::stateMachineBOB()
|
||||
switch (mBOBState) {
|
||||
case bsNewkeysN:
|
||||
key = answer.substr(3, answer.length()-3);
|
||||
mSetting.addr = keyToBase32Addr(key);
|
||||
mSetting.addr = i2p::keyToBase32Addr(key);
|
||||
IndicateConfigChanged();
|
||||
break;
|
||||
case bsGetkeys:
|
||||
|
@ -30,9 +30,10 @@
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
#include "services/autoproxy/rsautoproxymonitor.h"
|
||||
#include "util/rsthreads.h"
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
#include "util/i2pcommon.h"
|
||||
|
||||
/*
|
||||
* This class implements I2P BOB (BASIC OPEN BRIDGE) communication to allow RS
|
||||
@ -49,7 +50,7 @@
|
||||
*
|
||||
* Note 3:
|
||||
* BOB needs a unique name as an ID for each tunnel.
|
||||
* We use 'RetroShare-' + 8 base32 characters.
|
||||
* We use 'RetroShare-' + 8 random base32 characters.
|
||||
*
|
||||
* Design:
|
||||
* The service uses three state machines to manage its task:
|
||||
@ -72,7 +73,7 @@
|
||||
* mCommands[bobState::quit] = {quit, bobState::cleared};
|
||||
*
|
||||
* stateMachineController:
|
||||
* This state machone manages the high level tasks.
|
||||
* This state machine manages the high level tasks.
|
||||
* It is controlled by mState and mTask.
|
||||
*
|
||||
* mTast:
|
||||
@ -203,8 +204,6 @@ public:
|
||||
void processTaskAsync(taskTicket *ticket);
|
||||
void processTaskSync(taskTicket *ticket);
|
||||
|
||||
static std::string keyToBase32Addr(const std::string &key);
|
||||
|
||||
void threadTick() override; /// @see RsTickingThread
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user