Merge pull request #2343 from csoler/v0.6-BugFixing_10

auto-validate own signed identities
This commit is contained in:
csoler 2021-02-20 23:19:16 +01:00 committed by GitHub
commit e765aebf8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 41 additions and 20 deletions

View File

@ -385,7 +385,7 @@ bool DistributedChatService::locked_bouncingObjectCheck(RsChatLobbyBouncingObjec
// max objects per second: lobby_count * 1/MAX_DELAY_BETWEEN_LOBBY_KEEP_ALIVE objects per second.
// So in cache, there is in average that number times MAX_MESSAGES_PER_SECONDS_PERIOD
//
float max_cnt = std::max(10.0f, 4*lobby_count / (float)MAX_DELAY_BETWEEN_LOBBY_KEEP_ALIVE * MAX_MESSAGES_PER_SECONDS_PERIOD) ;
float max_cnt = std::max(10.0f, 10*lobby_count / (float)MAX_DELAY_BETWEEN_LOBBY_KEEP_ALIVE * MAX_MESSAGES_PER_SECONDS_PERIOD) ;
#ifdef DEBUG_CHAT_LOBBIES
std::cerr << "lobby_count=" << lobby_count << std::endl;
@ -406,7 +406,7 @@ bool DistributedChatService::locked_bouncingObjectCheck(RsChatLobbyBouncingObjec
if(lst.size() > max_cnt)
{
std::cerr << "Too many messages from peer " << pid << ". Someone (name=" << obj->nick << ") is trying to flood this lobby. Message will not be forwarded." << std::endl;
std::cerr << "(WW) more than " << max_cnt << " messages forwarded by peer " << pid << ". Message from \"" << obj->nick << "\" will not be forwarded." << std::endl;
return false;
}
else

View File

@ -287,17 +287,21 @@ bool MsgCircleIdsRequestVetting::cleared()
return false ;
}
uint32_t filtered_out_msgs=0;
for(uint32_t i=0;i<mMsgs.size();)
if(!mCircles->isRecipient(mCircleId,mGrpId,mMsgs[i].mAuthorId))
{
std::cerr << "(WW) MsgCircleIdsRequestVetting::cleared() filtering out message " << mMsgs[i].mMsgId << " because it's signed by author " << mMsgs[i].mAuthorId << " which is not in circle " << mCircleId << std::endl;
++filtered_out_msgs;
mMsgs[i] = mMsgs[mMsgs.size()-1] ;
mMsgs.pop_back();
}
else
++i ;
if(filtered_out_msgs>0)
std::cerr << "(WW) " << filtered_out_msgs << " messages not sent because they are signed by author(s) not member of that circle " << mCircleId << std::endl;
RsPgpId pgpId = mPgpUtils->getPGPId(mPeerId);
bool can_send_res = mCircles->canSend(mCircleId, pgpId,mShouldEncrypt);

View File

@ -799,7 +799,9 @@ bool p3LinkMgrIMPL::connectResult(const RsPeerId &id, bool success, bool isIncom
bool updatePeerAddr = false;
bool updateLastContact = false;
#ifdef LINKMGR_DEBUG
std::cerr << "Connection result with peer " << id << ": " << success << ". Is incoming: " << isIncomingConnection << ", remote addr: " << sockaddr_storage_tostring(remote_peer_address) << std::endl;
#endif
{
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/

View File

@ -158,6 +158,7 @@ public:
OK, /// Everything go as expected, no error occurred
ERR_ALREADY_RUNNING, /// Another istance is running already
ERR_CANT_ACQUIRE_LOCK, /// Another istance is already running?
ERR_NO_AVAILABLE_ACCOUNT, /// Used in retroshare-service -U list when no account is available
ERR_UNKNOWN /// Unkown error, maybe password is wrong?
};

View File

@ -954,10 +954,7 @@ bool p3IdService::deserialiseIdentityFromMemory(const std::string& radix_string,
return true;
}
bool p3IdService::createIdentity(
RsGxsId& id,
const std::string& name, const RsGxsImage& avatar,
bool pseudonimous, const std::string& pgpPassword)
bool p3IdService::createIdentity( RsGxsId& id, const std::string& name, const RsGxsImage& avatar, bool pseudonimous, const std::string& pgpPassword)
{
bool ret = true;
RsIdentityParameters params;
@ -1062,6 +1059,20 @@ bool p3IdService::createIdentity(uint32_t& token, RsIdentityParameters &params)
else
id.mMeta.mGroupFlags |= GXS_SERV::FLAG_PRIVACY_PUBLIC;
// Anticipate signature validation, since we're creating the signature ourselves.
SSGxsIdGroup ssdata;
ssdata.pgp.validatedSignature = params.isPgpLinked;
if(params.isPgpLinked)
{
ssdata.pgp.pgpId = AuthGPG::getAuthGPG()->getGPGOwnId();
ssdata.pgp.lastCheckTs = time(nullptr);
}
/* save string */
id.mMeta.mServiceString = ssdata.save();
createGroup(token, id);
return true;

View File

@ -38,7 +38,6 @@
/****
* #define POSTBASE_DEBUG 1
****/
#define POSTBASE_DEBUG 1
#define POSTBASE_BACKGROUND_PROCESSING 0x0002
#define PROCESSING_START_PERIOD 30
@ -630,8 +629,7 @@ void p3PostBase::background_loadMsgs(const uint32_t &token, bool unprocessed)
else
{
/* unknown! */
std::cerr << "p3PostBase::background_processNewMessages() ERROR Strange NEW Message:";
std::cerr << std::endl;
std::cerr << "p3PostBase::background_processNewMessages() ERROR Strange NEW Message:" << std::endl;
std::cerr << "\t" << (*vit)->meta;
std::cerr << std::endl;

View File

@ -234,14 +234,19 @@ int main(int argc, char* argv[])
{
if(prefUserString == "list")
{
std::cout << std::endl << std::endl
<< "Available accounts:" << std::endl;
std::vector<RsLoginHelper::Location> locations;
rsLoginHelper->getLocations(locations);
int accountCountDigits = static_cast<int>(
ceil(log(locations.size())/log(10.0)) );
if(locations.size() == 0)
{
RsErr() << "No available accounts. You cannot use option -U list" << std::endl;
return -RsInit::ERR_NO_AVAILABLE_ACCOUNT;
}
std::cout << std::endl << std::endl
<< "Available accounts:" << std::endl;
int accountCountDigits = static_cast<int>( ceil(log(locations.size())/log(10.0)) );
for( uint32_t i=0; i<locations.size(); ++i )
std::cout << "[" << std::setw(accountCountDigits)