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. // 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 // 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 #ifdef DEBUG_CHAT_LOBBIES
std::cerr << "lobby_count=" << lobby_count << std::endl; std::cerr << "lobby_count=" << lobby_count << std::endl;
@ -406,7 +406,7 @@ bool DistributedChatService::locked_bouncingObjectCheck(RsChatLobbyBouncingObjec
if(lst.size() > max_cnt) 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; return false;
} }
else else

View file

@ -287,17 +287,21 @@ bool MsgCircleIdsRequestVetting::cleared()
return false ; return false ;
} }
uint32_t filtered_out_msgs=0;
for(uint32_t i=0;i<mMsgs.size();) for(uint32_t i=0;i<mMsgs.size();)
if(!mCircles->isRecipient(mCircleId,mGrpId,mMsgs[i].mAuthorId)) 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[i] = mMsgs[mMsgs.size()-1] ;
mMsgs.pop_back(); mMsgs.pop_back();
} }
else else
++i ; ++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); RsPgpId pgpId = mPgpUtils->getPGPId(mPeerId);
bool can_send_res = mCircles->canSend(mCircleId, pgpId,mShouldEncrypt); 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 updatePeerAddr = false;
bool updateLastContact = 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; 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 *******/ RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/

View file

@ -158,6 +158,7 @@ public:
OK, /// Everything go as expected, no error occurred OK, /// Everything go as expected, no error occurred
ERR_ALREADY_RUNNING, /// Another istance is running already ERR_ALREADY_RUNNING, /// Another istance is running already
ERR_CANT_ACQUIRE_LOCK, /// Another istance is already running? 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? ERR_UNKNOWN /// Unkown error, maybe password is wrong?
}; };

View file

@ -954,10 +954,7 @@ bool p3IdService::deserialiseIdentityFromMemory(const std::string& radix_string,
return true; return true;
} }
bool p3IdService::createIdentity( bool p3IdService::createIdentity( RsGxsId& id, const std::string& name, const RsGxsImage& avatar, bool pseudonimous, const std::string& pgpPassword)
RsGxsId& id,
const std::string& name, const RsGxsImage& avatar,
bool pseudonimous, const std::string& pgpPassword)
{ {
bool ret = true; bool ret = true;
RsIdentityParameters params; RsIdentityParameters params;
@ -1062,6 +1059,20 @@ bool p3IdService::createIdentity(uint32_t& token, RsIdentityParameters &params)
else else
id.mMeta.mGroupFlags |= GXS_SERV::FLAG_PRIVACY_PUBLIC; 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); createGroup(token, id);
return true; return true;

View file

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

View file

@ -234,14 +234,19 @@ int main(int argc, char* argv[])
{ {
if(prefUserString == "list") if(prefUserString == "list")
{ {
std::cout << std::endl << std::endl
<< "Available accounts:" << std::endl;
std::vector<RsLoginHelper::Location> locations; std::vector<RsLoginHelper::Location> locations;
rsLoginHelper->getLocations(locations); rsLoginHelper->getLocations(locations);
int accountCountDigits = static_cast<int>( if(locations.size() == 0)
ceil(log(locations.size())/log(10.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 ) for( uint32_t i=0; i<locations.size(); ++i )
std::cout << "[" << std::setw(accountCountDigits) std::cout << "[" << std::setw(accountCountDigits)