mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-05 15:45:04 -04:00
Merge "Switched security items to new notification system #1735" csoler-v0.6-SecNotification
This commit is contained in:
commit
c96223a2a8
79 changed files with 1526 additions and 1991 deletions
|
@ -855,12 +855,8 @@ bool p3ChatService::handleRecvChatMsgItem(RsChatMsgItem *& ci)
|
|||
{
|
||||
#ifdef RS_DIRECT_CHAT
|
||||
/* notify public chat message */
|
||||
RsServer::notify()->AddPopupMessage(
|
||||
RS_POPUP_GROUPCHAT,
|
||||
ci->PeerId().toStdString(), "", message );
|
||||
RsServer::notify()->AddFeedItem(
|
||||
RS_FEED_ITEM_CHAT_NEW,
|
||||
ci->PeerId().toStdString(), message, "" );
|
||||
RsServer::notify()->AddPopupMessage( RS_POPUP_GROUPCHAT, ci->PeerId().toStdString(), "", message );
|
||||
//RsServer::notify()->AddFeedItem( RS_FEED_ITEM_CHAT_NEW, ci->PeerId().toStdString(), message, "" );
|
||||
#else // def RS_DIRECT_CHAT
|
||||
/* Ignore deprecated direct node broadcast chat messages */
|
||||
return false;
|
||||
|
|
|
@ -163,10 +163,25 @@ void RsGenExchange::tick()
|
|||
|
||||
processRoutingClues() ;
|
||||
|
||||
if(!mNotifications.empty())
|
||||
{
|
||||
notifyChanges(mNotifications);
|
||||
mNotifications.clear();
|
||||
std::vector<RsGxsNotify*> mNotifications_copy;
|
||||
|
||||
// make a non-deep copy of mNotifications so that it can be passed off-mutex to notifyChanged()
|
||||
// that will delete it. The potential high cost of notifyChanges() makes it preferable to call off-mutex.
|
||||
{
|
||||
RS_STACK_MUTEX(mGenMtx);
|
||||
if(!mNotifications.empty())
|
||||
{
|
||||
mNotifications_copy = mNotifications;
|
||||
mNotifications.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// Calling notifyChanges() calls back RsGxsIfaceHelper::receiveChanges() that deletes the pointers in the array
|
||||
// and the array itself. This is pretty bad and we should normally delete the changes here.
|
||||
|
||||
if(!mNotifications_copy.empty())
|
||||
notifyChanges(mNotifications_copy);
|
||||
}
|
||||
|
||||
// implemented service tick function
|
||||
|
@ -1118,38 +1133,25 @@ void RsGenExchange::receiveChanges(std::vector<RsGxsNotify*>& changes)
|
|||
if((mc = dynamic_cast<RsGxsMsgChange*>(n)) != nullptr)
|
||||
{
|
||||
if (mc->metaChange())
|
||||
{
|
||||
addMessageChanged(out.mMsgsMeta, mc->msgChangeMap);
|
||||
}
|
||||
else
|
||||
{
|
||||
addMessageChanged(out.mMsgs, mc->msgChangeMap);
|
||||
}
|
||||
}
|
||||
else if((gc = dynamic_cast<RsGxsGroupChange*>(n)) != nullptr)
|
||||
{
|
||||
if(gc->metaChange())
|
||||
{
|
||||
out.mGrpsMeta.splice(out.mGrpsMeta.end(), gc->mGrpIdList);
|
||||
}
|
||||
else
|
||||
{
|
||||
out.mGrps.splice(out.mGrps.end(), gc->mGrpIdList);
|
||||
}
|
||||
}
|
||||
else if(( gt =
|
||||
dynamic_cast<RsGxsDistantSearchResultChange*>(n) ) != nullptr)
|
||||
{
|
||||
else if(( gt = dynamic_cast<RsGxsDistantSearchResultChange*>(n) ) != nullptr)
|
||||
out.mDistantSearchReqs.push_back(gt->mRequestId);
|
||||
}
|
||||
else
|
||||
RsErr() << __PRETTY_FUNCTION__ << " Unknown changes type!"
|
||||
<< std::endl;
|
||||
RsErr() << __PRETTY_FUNCTION__ << " Unknown changes type!" << std::endl;
|
||||
delete n;
|
||||
}
|
||||
changes.clear() ;
|
||||
|
||||
RsServer::notify()->notifyGxsChange(out);
|
||||
if(rsEvents) rsEvents->postEvent(std::move(evt));
|
||||
}
|
||||
|
||||
|
|
|
@ -1296,7 +1296,9 @@ bool p3GxsTunnelService::locked_sendEncryptedTunnelData(RsGxsTunnelItem *item)
|
|||
}
|
||||
if(it->second.status != RS_GXS_TUNNEL_STATUS_CAN_TALK)
|
||||
{
|
||||
#ifdef DEBUG_GXS_TUNNEL
|
||||
std::cerr << "(EE) Cannot talk to tunnel id " << tunnel_id << ". Tunnel status is: " << it->second.status << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1186,11 +1186,13 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
|
|||
|
||||
RsErr() << __PRETTY_FUNCTION__ << " " << errMsg << std::endl;
|
||||
|
||||
if(rsEvents)
|
||||
{
|
||||
ev->mErrorMsg = errMsg;
|
||||
rsEvents->postEvent(std::move(ev));
|
||||
}
|
||||
// if(rsEvents)
|
||||
// {
|
||||
// ev->mErrorMsg = errMsg;
|
||||
// ev->mErrorCode = RsAuthSslConnectionAutenticationEvent::NO_CERTIFICATE_SUPPLIED;
|
||||
//
|
||||
// rsEvents->postEvent(std::move(ev));
|
||||
// }
|
||||
|
||||
return verificationFailed;
|
||||
}
|
||||
|
@ -1217,8 +1219,11 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
|
|||
if(rsEvents)
|
||||
{
|
||||
ev->mSslCn = sslCn;
|
||||
ev->mSslId = sslId;
|
||||
ev->mPgpId = pgpId;
|
||||
ev->mErrorMsg = errMsg;
|
||||
ev->mErrorCode = RsAuthSslConnectionAutenticationEvent::AuthenticationCode::MISSING_AUTHENTICATION_INFO;
|
||||
|
||||
rsEvents->postEvent(std::move(ev));
|
||||
}
|
||||
|
||||
|
@ -1237,6 +1242,8 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
|
|||
ev->mSslId = sslId;
|
||||
ev->mSslCn = sslCn;
|
||||
ev->mErrorMsg = errMsg;
|
||||
ev->mErrorCode = RsAuthSslConnectionAutenticationEvent::AuthenticationCode::MISSING_AUTHENTICATION_INFO;
|
||||
|
||||
rsEvents->postEvent(std::move(ev));
|
||||
}
|
||||
|
||||
|
@ -1266,6 +1273,7 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
|
|||
ev->mSslCn = sslCn;
|
||||
ev->mPgpId = pgpId;
|
||||
ev->mErrorMsg = errorMsg;
|
||||
ev->mErrorCode = RsAuthSslConnectionAutenticationEvent::AuthenticationCode::MISMATCHED_PGP_ID;
|
||||
rsEvents->postEvent(std::move(ev));
|
||||
}
|
||||
|
||||
|
@ -1290,12 +1298,24 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
|
|||
ev->mSslId = sslId;
|
||||
ev->mSslCn = sslCn;
|
||||
ev->mPgpId = pgpId;
|
||||
|
||||
switch(auth_diagnostic)
|
||||
{
|
||||
case RS_SSL_HANDSHAKE_DIAGNOSTIC_ISSUER_UNKNOWN: ev->mErrorCode = RsAuthSslConnectionAutenticationEvent::AuthenticationCode::NOT_A_FRIEND; break;
|
||||
case RS_SSL_HANDSHAKE_DIAGNOSTIC_WRONG_SIGNATURE: ev->mErrorCode = RsAuthSslConnectionAutenticationEvent::AuthenticationCode::PGP_SIGNATURE_VALIDATION_FAILED;break;
|
||||
default:
|
||||
ev->mErrorCode = RsAuthSslConnectionAutenticationEvent::AuthenticationCode::MISSING_AUTHENTICATION_INFO;break;
|
||||
}
|
||||
|
||||
ev->mErrorMsg = errMsg;
|
||||
rsEvents->postEvent(std::move(ev));
|
||||
}
|
||||
|
||||
return verificationFailed;
|
||||
}
|
||||
#ifdef AUTHSSL_DEBUG
|
||||
std::cerr << "******* VerifyX509Callback cert: " << std::hex << ctx->cert <<std::dec << std::endl;
|
||||
#endif
|
||||
|
||||
if ( !isSslOnlyFriend && pgpId != AuthGPG::getAuthGPG()->getGPGOwnId() && !AuthGPG::getAuthGPG()->isGPGAccepted(pgpId) )
|
||||
{
|
||||
|
@ -1311,28 +1331,20 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
|
|||
ev->mSslCn = sslCn;
|
||||
ev->mPgpId = pgpId;
|
||||
ev->mErrorMsg = errMsg;
|
||||
ev->mErrorCode = RsAuthSslConnectionAutenticationEvent::AuthenticationCode::NOT_A_FRIEND;
|
||||
rsEvents->postEvent(std::move(ev));
|
||||
}
|
||||
|
||||
return verificationFailed;
|
||||
}
|
||||
|
||||
setCurrentConnectionAttemptInfo(pgpId, sslId, sslCn);
|
||||
//setCurrentConnectionAttemptInfo(pgpId, sslId, sslCn);
|
||||
LocalStoreCert(x509Cert);
|
||||
|
||||
RsInfo() << __PRETTY_FUNCTION__ << " authentication successfull for "
|
||||
<< "sslId: " << sslId << " isSslOnlyFriend: " << isSslOnlyFriend
|
||||
<< std::endl;
|
||||
|
||||
if(rsEvents)
|
||||
{
|
||||
ev->mSuccess = true;
|
||||
ev->mSslId = sslId;
|
||||
ev->mSslCn = sslCn;
|
||||
ev->mPgpId = pgpId;
|
||||
rsEvents->postEvent(std::move(ev));
|
||||
}
|
||||
|
||||
return verificationSuccess;
|
||||
}
|
||||
|
||||
|
@ -1590,24 +1602,24 @@ bool AuthSSLimpl::decrypt(void *&out, int &outlen, const void *in, int inlen)
|
|||
/********************************************************************************/
|
||||
/********************************************************************************/
|
||||
|
||||
void AuthSSLimpl::setCurrentConnectionAttemptInfo(const RsPgpId& gpg_id,const RsPeerId& ssl_id,const std::string& ssl_cn)
|
||||
{
|
||||
#ifdef AUTHSSL_DEBUG
|
||||
std::cerr << "AuthSSL: registering connection attempt from:" << std::endl;
|
||||
std::cerr << " GPG id: " << gpg_id << std::endl;
|
||||
std::cerr << " SSL id: " << ssl_id << std::endl;
|
||||
std::cerr << " SSL cn: " << ssl_cn << std::endl;
|
||||
#endif
|
||||
_last_gpgid_to_connect = gpg_id ;
|
||||
_last_sslid_to_connect = ssl_id ;
|
||||
_last_sslcn_to_connect = ssl_cn ;
|
||||
}
|
||||
void AuthSSLimpl::getCurrentConnectionAttemptInfo(RsPgpId& gpg_id,RsPeerId& ssl_id,std::string& ssl_cn)
|
||||
{
|
||||
gpg_id = _last_gpgid_to_connect ;
|
||||
ssl_id = _last_sslid_to_connect ;
|
||||
ssl_cn = _last_sslcn_to_connect ;
|
||||
}
|
||||
// void AuthSSLimpl::setCurrentConnectionAttemptInfo(const RsPgpId& gpg_id,const RsPeerId& ssl_id,const std::string& ssl_cn)
|
||||
// {
|
||||
// #ifdef AUTHSSL_DEBUG
|
||||
// std::cerr << "AuthSSL: registering connection attempt from:" << std::endl;
|
||||
// std::cerr << " GPG id: " << gpg_id << std::endl;
|
||||
// std::cerr << " SSL id: " << ssl_id << std::endl;
|
||||
// std::cerr << " SSL cn: " << ssl_cn << std::endl;
|
||||
// #endif
|
||||
// _last_gpgid_to_connect = gpg_id ;
|
||||
// _last_sslid_to_connect = ssl_id ;
|
||||
// _last_sslcn_to_connect = ssl_cn ;
|
||||
// }
|
||||
// void AuthSSLimpl::getCurrentConnectionAttemptInfo(RsPgpId& gpg_id,RsPeerId& ssl_id,std::string& ssl_cn)
|
||||
// {
|
||||
// gpg_id = _last_gpgid_to_connect ;
|
||||
// ssl_id = _last_sslid_to_connect ;
|
||||
// ssl_cn = _last_sslcn_to_connect ;
|
||||
// }
|
||||
|
||||
/* Locked search -> internal help function */
|
||||
bool AuthSSLimpl::locked_FindCert(const RsPeerId& id, X509** cert)
|
||||
|
@ -1785,9 +1797,6 @@ bool AuthSSLimpl::loadList(std::list<RsItem*>& load)
|
|||
return true;
|
||||
}
|
||||
|
||||
RsAuthSslConnectionAutenticationEvent::RsAuthSslConnectionAutenticationEvent() :
|
||||
RsEvent(RsEventType::AUTHSSL_CONNECTION_AUTENTICATION), mSuccess(false) {}
|
||||
|
||||
const EVP_PKEY*RsX509Cert::getPubKey(const X509& x509)
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
|
||||
|
|
|
@ -52,34 +52,6 @@ RsPeerId getCertSslId(const X509& x509);
|
|||
const EVP_PKEY* getPubKey(const X509& x509);
|
||||
};
|
||||
|
||||
/**
|
||||
* Event triggered by AuthSSL when authentication of a connection attempt either
|
||||
* fail or success
|
||||
*/
|
||||
struct RsAuthSslConnectionAutenticationEvent : RsEvent
|
||||
{
|
||||
RsAuthSslConnectionAutenticationEvent();
|
||||
|
||||
bool mSuccess;
|
||||
RsPeerId mSslId;
|
||||
std::string mSslCn;
|
||||
RsPgpId mPgpId;
|
||||
std::string mErrorMsg;
|
||||
|
||||
///* @see RsEvent @see RsSerializable
|
||||
void serial_process( RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext& ctx) override
|
||||
{
|
||||
RsEvent::serial_process(j, ctx);
|
||||
RS_SERIAL_PROCESS(mSuccess);
|
||||
RS_SERIAL_PROCESS(mSslId);
|
||||
RS_SERIAL_PROCESS(mSslCn);
|
||||
RS_SERIAL_PROCESS(mPgpId);
|
||||
RS_SERIAL_PROCESS(mErrorMsg);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This is an implementation of SSL certificate authentication with PGP
|
||||
* signatures, instead of centralized certification authority.
|
||||
|
@ -165,11 +137,11 @@ public:
|
|||
/// SSL specific functions used in pqissl/pqissllistener
|
||||
virtual SSL_CTX* getCTX() = 0;
|
||||
|
||||
virtual void setCurrentConnectionAttemptInfo(
|
||||
const RsPgpId& gpg_id, const RsPeerId& ssl_id,
|
||||
const std::string& ssl_cn ) = 0;
|
||||
virtual void getCurrentConnectionAttemptInfo(
|
||||
RsPgpId& gpg_id, RsPeerId& ssl_id, std::string& ssl_cn ) = 0;
|
||||
// virtual void setCurrentConnectionAttemptInfo(
|
||||
// const RsPgpId& gpg_id, const RsPeerId& ssl_id,
|
||||
// const std::string& ssl_cn ) = 0;
|
||||
// virtual void getCurrentConnectionAttemptInfo(
|
||||
// RsPgpId& gpg_id, RsPeerId& ssl_id, std::string& ssl_cn ) = 0;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -259,11 +231,11 @@ public:
|
|||
SSL_CTX* getCTX() override;
|
||||
|
||||
/* Restored these functions: */
|
||||
void setCurrentConnectionAttemptInfo(
|
||||
const RsPgpId& gpg_id, const RsPeerId& ssl_id,
|
||||
const std::string& ssl_cn ) override;
|
||||
void getCurrentConnectionAttemptInfo(
|
||||
RsPgpId& gpg_id, RsPeerId& ssl_id, std::string& ssl_cn ) override;
|
||||
// void setCurrentConnectionAttemptInfo(
|
||||
// const RsPgpId& gpg_id, const RsPeerId& ssl_id,
|
||||
// const std::string& ssl_cn ) override;
|
||||
// void getCurrentConnectionAttemptInfo(
|
||||
// RsPgpId& gpg_id, RsPeerId& ssl_id, std::string& ssl_cn ) override;
|
||||
|
||||
|
||||
private:
|
||||
|
|
|
@ -473,26 +473,23 @@ void p3LinkMgrIMPL::tickMonitors()
|
|||
#endif
|
||||
|
||||
/* notify GUI */
|
||||
if (peer.actions & RS_PEER_CONNECTED)
|
||||
if (rsEvents && (peer.actions & RS_PEER_CONNECTED))
|
||||
{
|
||||
p3Notify *notify = RsServer::notify();
|
||||
auto e = std::make_shared<RsConnectionEvent>() ;
|
||||
|
||||
if (notify)
|
||||
{
|
||||
// normally these two below should disappear: there's no notion of popup in libretroshare.
|
||||
// all GUI-type display features should be chosen in NotifyQt.
|
||||
notify->AddPopupMessage(RS_POPUP_CONNECT, peer.id.toStdString(),"", "Online: ");
|
||||
notify->AddFeedItem(RS_FEED_ITEM_PEER_CONNECT, peer.id.toStdString());
|
||||
e->mConnectionInfoCode = RsConnectionEvent::ConnectionEventCode::PEER_CONNECTED;
|
||||
e->mSslId = peer.id;
|
||||
|
||||
notify->notifyPeerConnected(peer.id.toStdString());
|
||||
}
|
||||
rsEvents->postEvent(e);
|
||||
}
|
||||
if (peer.actions & RS_PEER_DISCONNECTED)
|
||||
if (rsEvents && (peer.actions & RS_PEER_DISCONNECTED))
|
||||
{
|
||||
p3Notify *notify = RsServer::notify();
|
||||
auto e = std::make_shared<RsConnectionEvent>() ;
|
||||
|
||||
if (notify)
|
||||
notify->notifyPeerDisconnected(peer.id.toStdString());
|
||||
e->mConnectionInfoCode = RsConnectionEvent::ConnectionEventCode::PEER_DISCONNECTED;
|
||||
e->mSslId = peer.id;
|
||||
|
||||
rsEvents->postEvent(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -217,8 +217,6 @@ void p3Notify::notifyChatLobbyEvent(uint64_t lobby_id, uint32_t event_type,const
|
|||
void p3Notify::notifyListPreChange(int list, int type) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyListPreChange(list,type) ; }
|
||||
void p3Notify::notifyListChange (int list, int type) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyListChange (list,type) ; }
|
||||
|
||||
void p3Notify::notifyPeerConnected (const std::string& peer_id) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyPeerConnected(peer_id); }
|
||||
void p3Notify::notifyPeerDisconnected (const std::string& peer_id) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyPeerDisconnected(peer_id); }
|
||||
void p3Notify::notifyErrorMsg (int list, int sev, std::string msg) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyErrorMsg(list,sev,msg) ; }
|
||||
void p3Notify::notifyChatMessage (const ChatMessage &msg) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyChatMessage(msg) ; }
|
||||
void p3Notify::notifyChatStatus (const ChatId& chat_id, const std::string& status_string) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyChatStatus(chat_id,status_string) ; }
|
||||
|
@ -235,8 +233,6 @@ void p3Notify::notifyOwnAvatarChanged ()
|
|||
void p3Notify::notifyOwnStatusMessageChanged() { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyOwnStatusMessageChanged() ; }
|
||||
void p3Notify::notifyDiskFull (uint32_t location , uint32_t size_limit_in_MB ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyDiskFull (location,size_limit_in_MB) ; }
|
||||
void p3Notify::notifyPeerStatusChanged (const std::string& peer_id , uint32_t status ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyPeerStatusChanged (peer_id,status) ; }
|
||||
void p3Notify::notifyGxsChange (const RsGxsChanges& changes) {FOR_ALL_NOTIFY_CLIENTS (*it)->notifyGxsChange(changes) ;}
|
||||
void p3Notify::notifyConnectionWithoutCert () { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyConnectionWithoutCert(); }
|
||||
|
||||
void p3Notify::notifyPeerStatusChangedSummary () { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyPeerStatusChangedSummary() ; }
|
||||
void p3Notify::notifyDiscInfoChanged () { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyDiscInfoChanged () ; }
|
||||
|
|
|
@ -91,8 +91,6 @@ class p3Notify: public RsNotify
|
|||
|
||||
// Notifications of clients. Can be called from anywhere inside libretroshare.
|
||||
//
|
||||
void notifyPeerConnected (const std::string& /* peer_id */);
|
||||
void notifyPeerDisconnected (const std::string& /* peer_id */);
|
||||
void notifyListPreChange (int /* list */, int /* type */) ;
|
||||
void notifyListChange (int /* list */, int /* type */) ;
|
||||
void notifyErrorMsg (int /* list */, int /* sev */, std::string /* msg */) ;
|
||||
|
@ -111,7 +109,6 @@ class p3Notify: public RsNotify
|
|||
void notifyOwnStatusMessageChanged () ;
|
||||
void notifyDiskFull (uint32_t /* location */, uint32_t /* size limit in MB */) ;
|
||||
void notifyPeerStatusChanged (const std::string& /* peer_id */, uint32_t /* status */) ;
|
||||
void notifyGxsChange (const RsGxsChanges& /* changes */);
|
||||
void notifyConnectionWithoutCert ();
|
||||
|
||||
void notifyPeerStatusChangedSummary () ;
|
||||
|
|
|
@ -1808,7 +1808,16 @@ bool p3PeerMgrIMPL::addCandidateForOwnExternalAddress(const RsPeerId &from, cons
|
|||
{
|
||||
std::cerr << " Peer " << from << " reports a connection address (" << sockaddr_storage_iptostring(addr_filtered) <<") that is not your current external address (" << sockaddr_storage_iptostring(own_addr) << "). This is weird." << std::endl;
|
||||
|
||||
RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED, from.toStdString(), sockaddr_storage_iptostring(own_addr), sockaddr_storage_iptostring(addr));
|
||||
if(rsEvents)
|
||||
{
|
||||
auto ev = std::make_shared<RsConnectionEvent>();
|
||||
ev->mSslId = from;
|
||||
ev->mStrInfo1 = sockaddr_storage_iptostring(addr);
|
||||
ev->mStrInfo2 = sockaddr_storage_iptostring(own_addr);
|
||||
ev->mConnectionInfoCode = RsConnectionEvent::ConnectionEventCode::PEER_REPORTS_WRONG_IP;
|
||||
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
}
|
||||
|
||||
// we could also sweep over all connected friends and see if some report a different address.
|
||||
|
|
|
@ -1096,8 +1096,7 @@ int pqissl::SSL_Connection_Complete()
|
|||
if (err != 1)
|
||||
{
|
||||
int serr = SSL_get_error(ssl_connection, err);
|
||||
if ((serr == SSL_ERROR_WANT_READ)
|
||||
|| (serr == SSL_ERROR_WANT_WRITE))
|
||||
if ((serr == SSL_ERROR_WANT_READ) || (serr == SSL_ERROR_WANT_WRITE))
|
||||
{
|
||||
#ifdef PQISSL_LOG_DEBUG
|
||||
rslog(RSL_DEBUG_BASIC, pqisslzone,
|
||||
|
@ -1108,6 +1107,16 @@ int pqissl::SSL_Connection_Complete()
|
|||
return 0;
|
||||
}
|
||||
|
||||
if(rsEvents)
|
||||
{
|
||||
auto ev = std::make_shared<RsAuthSslConnectionAutenticationEvent>();
|
||||
|
||||
X509 *x509 = SSL_get_peer_certificate(ssl_connection) ;
|
||||
|
||||
ev->mSslId = RsX509Cert::getCertSslId(*x509);
|
||||
ev->mErrorCode = RsAuthSslConnectionAutenticationEvent::AuthenticationCode::PEER_REFUSED_CONNECTION;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
|
||||
std::string out;
|
||||
rs_sprintf(out, "pqissl::SSL_Connection_Complete()\nIssues with SSL Connect(%d)!\n", err);
|
||||
|
@ -1253,10 +1262,12 @@ int pqissl::accept_locked( SSL *ssl, int fd,
|
|||
if (rsPeers->servicePermissionFlags(PeerId()) & RS_NODE_PERM_REQUIRE_WL)
|
||||
checking_flags |= RSBANLIST_CHECKING_FLAGS_WHITELIST;
|
||||
|
||||
if(rsBanList && !rsBanList->isAddressAccepted(
|
||||
foreign_addr, checking_flags, check_result ))
|
||||
if( RsX509Cert::getCertSslId(*SSL_get_peer_certificate(ssl)) != PeerId())
|
||||
std::cerr << "(EE) pqissl::accept_locked(): PeerId() is " << PeerId() << " but certificate ID is " << RsX509Cert::getCertSslId(*SSL_get_peer_certificate(ssl)) << std::endl;
|
||||
|
||||
if(rsBanList && !rsBanList->isAddressAccepted( foreign_addr, checking_flags, check_result ))
|
||||
{
|
||||
RsErr() << __PRETTY_FUNCTION__
|
||||
RsInfo() << __PRETTY_FUNCTION__
|
||||
<< " Refusing incoming SSL connection from blacklisted "
|
||||
<< "foreign address " << foreign_addr
|
||||
<< ". Reason: " << check_result << ". This should never happen "
|
||||
|
@ -1264,11 +1275,19 @@ int pqissl::accept_locked( SSL *ssl, int fd,
|
|||
<< std::endl;
|
||||
print_stacktrace();
|
||||
|
||||
RsServer::notify()->AddFeedItem(
|
||||
RS_FEED_ITEM_SEC_IP_BLACKLISTED,
|
||||
PeerId().toStdString(),
|
||||
sockaddr_storage_iptostring(foreign_addr), "", "",
|
||||
check_result);
|
||||
if(rsEvents)
|
||||
{
|
||||
auto ev = std::make_shared<RsAuthSslConnectionAutenticationEvent>();
|
||||
|
||||
X509 *x509 = SSL_get_peer_certificate(ssl) ;
|
||||
|
||||
ev->mSslId = RsX509Cert::getCertSslId(*x509);
|
||||
ev->mLocator = RsUrl(foreign_addr);
|
||||
ev->mErrorCode = RsAuthSslConnectionAutenticationEvent::AuthenticationCode::IP_IS_BLACKLISTED;
|
||||
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
|
||||
reset_locked();
|
||||
return failure;
|
||||
}
|
||||
|
@ -1324,7 +1343,7 @@ int pqissl::accept_locked( SSL *ssl, int fd,
|
|||
/* shutdown existing - in all cases use the new one */
|
||||
if ((ssl_connection) && (ssl_connection != ssl))
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__
|
||||
RsInfo() << __PRETTY_FUNCTION__
|
||||
<< " closing Previous/Existing ssl_connection" << std::endl;
|
||||
SSL_shutdown(ssl_connection);
|
||||
SSL_free (ssl_connection);
|
||||
|
@ -1332,7 +1351,7 @@ int pqissl::accept_locked( SSL *ssl, int fd,
|
|||
|
||||
if ((sockfd > -1) && (sockfd != fd))
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << " closing Previous/Existing sockfd"
|
||||
RsInfo() << __PRETTY_FUNCTION__ << " closing Previous/Existing sockfd"
|
||||
<< std::endl;
|
||||
net_internal_close(sockfd);
|
||||
}
|
||||
|
@ -1348,7 +1367,7 @@ int pqissl::accept_locked( SSL *ssl, int fd,
|
|||
*/
|
||||
sockaddr_storage_copy(foreign_addr, remote_addr);
|
||||
|
||||
std::cerr << __PRETTY_FUNCTION__ << " SUCCESSFUL connection to: "
|
||||
RsInfo() << __PRETTY_FUNCTION__ << " SUCCESSFUL connection to: "
|
||||
<< PeerId().toStdString() << " remoteaddr: "
|
||||
<< sockaddr_storage_iptostring(remote_addr) << std::endl;
|
||||
|
||||
|
|
|
@ -424,23 +424,8 @@ int pqissllistenbase::continueSSL(IncomingSSLInfo& incoming_connexion_info, bool
|
|||
{
|
||||
// attempt the accept again.
|
||||
int fd = SSL_get_fd(incoming_connexion_info.ssl);
|
||||
|
||||
AuthSSL::getAuthSSL()->setCurrentConnectionAttemptInfo(RsPgpId(),RsPeerId(),std::string()) ;
|
||||
int err = SSL_accept(incoming_connexion_info.ssl);
|
||||
|
||||
// Now grab the connection info that was filled in by the callback.
|
||||
// In the case the callback did not succeed the SSL certificate will not be accessible
|
||||
// from SSL_get_peer_certificate, so we need to get it from the callback system.
|
||||
//
|
||||
AuthSSL::getAuthSSL()->getCurrentConnectionAttemptInfo(incoming_connexion_info.gpgid,incoming_connexion_info.sslid,incoming_connexion_info.sslcn) ;
|
||||
|
||||
#ifdef DEBUG_LISTENNER
|
||||
std::cerr << "Info from callback: " << std::endl;
|
||||
std::cerr << " Got PGP Id = " << incoming_connexion_info.gpgid << std::endl;
|
||||
std::cerr << " Got SSL Id = " << incoming_connexion_info.sslid << std::endl;
|
||||
std::cerr << " Got SSL CN = " << incoming_connexion_info.sslcn << std::endl;
|
||||
#endif
|
||||
|
||||
if (err <= 0)
|
||||
{
|
||||
int ssl_err = SSL_get_error(incoming_connexion_info.ssl, err);
|
||||
|
@ -486,10 +471,24 @@ int pqissllistenbase::continueSSL(IncomingSSLInfo& incoming_connexion_info, bool
|
|||
break;
|
||||
}
|
||||
|
||||
closeConnection(fd, incoming_connexion_info.ssl) ;
|
||||
|
||||
pqioutput(PQL_WARNING, pqissllistenzone, "Read Error on the SSL Socket\nShutting it down!");
|
||||
|
||||
// We use SSL_get_verify_result() in order to differentiate two cases:
|
||||
// case 1: the incoming connection is closed because the peer is not a friend. This is already handled in authssl.
|
||||
// case 2: the incoming connection is closed because no authentication info is available, in which case it returns X509_V_OK
|
||||
auto vres = SSL_get_verify_result(incoming_connexion_info.ssl);
|
||||
|
||||
if(vres == X509_V_OK && nullptr != rsEvents)
|
||||
{
|
||||
auto ev = std::unique_ptr<RsAuthSslConnectionAutenticationEvent>(new RsAuthSslConnectionAutenticationEvent);
|
||||
|
||||
ev->mLocator = RsUrl(incoming_connexion_info.addr);
|
||||
ev->mErrorCode = RsAuthSslConnectionAutenticationEvent::AuthenticationCode::MISSING_AUTHENTICATION_INFO;
|
||||
|
||||
rsEvents->postEvent(std::move(ev));
|
||||
}
|
||||
closeConnection(fd, incoming_connexion_info.ssl) ;
|
||||
|
||||
// failure -1, pending 0, sucess 1.
|
||||
return -1;
|
||||
}
|
||||
|
@ -505,23 +504,22 @@ int pqissllistenbase::continueSSL(IncomingSSLInfo& incoming_connexion_info, bool
|
|||
incoming_connexion_info.sslcn = RsX509Cert::getCertName(*x509);
|
||||
incoming_connexion_info.sslid = RsX509Cert::getCertSslId(*x509);
|
||||
|
||||
#ifdef DEBUG_LISTENNER
|
||||
#ifndef DEBUG_LISTENNER
|
||||
std::cerr << "ContinueSSL:" << std::endl;
|
||||
std::cerr << " Got PGP Id = " << incoming_connexion_info.gpgid << std::endl;
|
||||
std::cerr << " Got SSL Id = " << incoming_connexion_info.sslid << std::endl;
|
||||
std::cerr << " Got SSL CN = " << incoming_connexion_info.sslcn << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LISTENNER
|
||||
else
|
||||
std::cerr << " no info." << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
// if it succeeds
|
||||
if (0 < completeConnection(fd, incoming_connexion_info))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* else we shut it down! */
|
||||
pqioutput(PQL_WARNING, pqissllistenzone,
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <cstdint>
|
||||
|
||||
#include "util/rsmemory.h"
|
||||
#include "util/rsurl.h"
|
||||
#include "serialiser/rsserializable.h"
|
||||
#include "serialiser/rstypeserializer.h"
|
||||
|
||||
|
@ -58,9 +59,9 @@ enum class RsEventType : uint32_t
|
|||
AUTHSSL_CONNECTION_AUTENTICATION = 3,
|
||||
|
||||
/// @see pqissl
|
||||
REMOTE_PEER_REFUSED_CONNECTION = 4,
|
||||
PEER_CONNECTION = 4,
|
||||
|
||||
/// @see RsGxsChanges
|
||||
/// @see RsGxsChanges // this one should probably be removed because it's not used anywhere
|
||||
GXS_CHANGES = 5,
|
||||
|
||||
/// Emitted when a peer state changes, @see RsPeers
|
||||
|
@ -69,6 +70,18 @@ enum class RsEventType : uint32_t
|
|||
/// @see RsMailStatusEvent
|
||||
MAIL_STATUS_CHANGE = 7,
|
||||
|
||||
/// @see RsGxsCircleEvent
|
||||
GXS_CIRCLES = 8,
|
||||
|
||||
/// @see RsGxsChannelEvent
|
||||
GXS_CHANNELS = 9,
|
||||
|
||||
/// @see RsGxsForumEvent
|
||||
GXS_FORUMS = 10,
|
||||
|
||||
/// @see RsGxsPostedEvent
|
||||
GXS_POSTED = 11,
|
||||
|
||||
MAX /// Used to detect invalid event type passed
|
||||
};
|
||||
|
||||
|
@ -170,3 +183,4 @@ public:
|
|||
|
||||
virtual ~RsEvents();
|
||||
};
|
||||
|
||||
|
|
|
@ -102,6 +102,35 @@ struct RsGxsChannelPost : RsSerializable
|
|||
~RsGxsChannelPost() override;
|
||||
};
|
||||
|
||||
struct RsGxsChannelEvent: RsEvent
|
||||
{
|
||||
RsGxsChannelEvent()
|
||||
: RsEvent(RsEventType::GXS_CHANNELS), mChannelEventCode(ChannelEventCode::UNKNOWN) {}
|
||||
|
||||
enum class ChannelEventCode: uint8_t {
|
||||
UNKNOWN = 0x00,
|
||||
NEW_CHANNEL = 0x01, // emitted when new channel is received
|
||||
UPDATED_CHANNEL = 0x02, // emitted when existing channel is updated
|
||||
NEW_MESSAGE = 0x03, // new message reeived in a particular channel (group and msg id)
|
||||
UPDATED_MESSAGE = 0x04, // existing message has been updated in a particular channel (group and msg id)
|
||||
RECEIVED_PUBLISH_KEY = 0x05, // publish key for this channel has been received.
|
||||
SUBSCRIBE_STATUS_CHANGED = 0x06, // subscription for channel mChannelGroupId changed.
|
||||
};
|
||||
|
||||
ChannelEventCode mChannelEventCode;
|
||||
RsGxsGroupId mChannelGroupId;
|
||||
RsGxsMessageId mChannelMsgId;
|
||||
|
||||
///* @see RsEvent @see RsSerializable
|
||||
void serial_process( RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) override
|
||||
{
|
||||
RsEvent::serial_process(j, ctx);
|
||||
|
||||
RS_SERIAL_PROCESS(mChannelEventCode);
|
||||
RS_SERIAL_PROCESS(mChannelGroupId);
|
||||
RS_SERIAL_PROCESS(mChannelMsgId);
|
||||
}
|
||||
};
|
||||
|
||||
class RsGxsChannels: public RsGxsIfaceHelper, public RsGxsCommentService
|
||||
{
|
||||
|
|
|
@ -123,7 +123,7 @@ struct RsGxsCircleDetails : RsSerializable
|
|||
{
|
||||
RsGxsCircleDetails() :
|
||||
mCircleType(static_cast<uint32_t>(RsGxsCircleType::EXTERNAL)),
|
||||
mAmIAllowed(false) {}
|
||||
mAmIAllowed(false),mAmIAdmin(false) {}
|
||||
~RsGxsCircleDetails() override;
|
||||
|
||||
RsGxsCircleId mCircleId;
|
||||
|
@ -136,6 +136,9 @@ struct RsGxsCircleDetails : RsSerializable
|
|||
* list & subscribed list). */
|
||||
bool mAmIAllowed;
|
||||
|
||||
/// true when we're an administrator of the circle group, meaning that we can add/remove members from the invitee list.
|
||||
bool mAmIAdmin;
|
||||
|
||||
/// This crosses admin list and subscribed list
|
||||
std::set<RsGxsId> mAllowedGxsIds;
|
||||
std::set<RsPgpId> mAllowedNodes;
|
||||
|
@ -152,12 +155,41 @@ struct RsGxsCircleDetails : RsSerializable
|
|||
RS_SERIAL_PROCESS(mCircleType);
|
||||
RS_SERIAL_PROCESS(mRestrictedCircleId);
|
||||
RS_SERIAL_PROCESS(mAmIAllowed);
|
||||
RS_SERIAL_PROCESS(mAmIAdmin);
|
||||
RS_SERIAL_PROCESS(mAllowedGxsIds);
|
||||
RS_SERIAL_PROCESS(mAllowedNodes);
|
||||
RS_SERIAL_PROCESS(mSubscriptionFlags);
|
||||
}
|
||||
};
|
||||
|
||||
struct RsGxsCircleEvent: RsEvent
|
||||
{
|
||||
RsGxsCircleEvent()
|
||||
: RsEvent(RsEventType::GXS_CIRCLES), mCircleEventType(CircleEventCode::UNKNOWN) {}
|
||||
|
||||
enum class CircleEventCode: uint8_t {
|
||||
UNKNOWN = 0x00,
|
||||
CIRCLE_MEMBERSHIP_REQUEST = 0x01, // mCircleId contains the circle id and mGxsId is the id requesting membership
|
||||
CIRCLE_MEMBERSHIP_INVITE = 0x02, // mCircleId is the circle that invites me, and mGxsId is my own Id that is invited
|
||||
CIRCLE_MEMBERSHIP_LEAVE = 0x03, // mCircleId contains the circle id and mGxsId is the id dropping membership
|
||||
CIRCLE_MEMBERSHIP_JOIN = 0x04, // mCircleId contains the circle id and mGxsId is the id of the new member
|
||||
CIRCLE_MEMBERSHIP_REVOQUED= 0x05, // mCircleId contains the circle id and mGxsId is the id that was revoqued by admin
|
||||
};
|
||||
|
||||
CircleEventCode mCircleEventType;
|
||||
RsGxsCircleId mCircleId;
|
||||
RsGxsId mGxsId;
|
||||
|
||||
///* @see RsEvent @see RsSerializable
|
||||
void serial_process( RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) override
|
||||
{
|
||||
RsEvent::serial_process(j, ctx);
|
||||
RS_SERIAL_PROCESS(mCircleEventType);
|
||||
RS_SERIAL_PROCESS(mCircleId);
|
||||
RS_SERIAL_PROCESS(mGxsId);
|
||||
}
|
||||
};
|
||||
|
||||
class RsGxsCircles: public RsGxsIfaceHelper
|
||||
{
|
||||
public:
|
||||
|
@ -243,6 +275,17 @@ public:
|
|||
*/
|
||||
virtual bool getCircleRequests( const RsGxsGroupId& circleId,
|
||||
std::vector<RsGxsCircleMsg>& requests ) = 0;
|
||||
/**
|
||||
* @brief Get specific circle request
|
||||
* @jsonapi{development}
|
||||
* @param[in] circleId id of the circle of which the requests are requested
|
||||
* @param[in] msgId id of the request
|
||||
* @param[out] msg storage for the circle request
|
||||
* @return false if something failed, true otherwhise
|
||||
*/
|
||||
virtual bool getCircleRequest(const RsGxsGroupId& circleId,
|
||||
const RsGxsMessageId& msgId,
|
||||
RsGxsCircleMsg& msg) =0;
|
||||
|
||||
/**
|
||||
* @brief Invite identities to circle
|
||||
|
|
|
@ -104,6 +104,34 @@ struct RsGxsForumMsg : RsSerializable
|
|||
~RsGxsForumMsg() override;
|
||||
};
|
||||
|
||||
struct RsGxsForumEvent: RsEvent
|
||||
{
|
||||
RsGxsForumEvent()
|
||||
: RsEvent(RsEventType::GXS_FORUMS), mForumEventCode(ForumEventCode::UNKNOWN) {}
|
||||
|
||||
enum class ForumEventCode: uint8_t {
|
||||
UNKNOWN = 0x00,
|
||||
NEW_FORUM = 0x01, // emitted when new forum is received
|
||||
UPDATED_FORUM = 0x02, // emitted when existing forum is updated
|
||||
NEW_MESSAGE = 0x03, // new message reeived in a particular forum (group and msg id)
|
||||
UPDATED_MESSAGE = 0x04, // existing message has been updated in a particular forum (group and msg id)
|
||||
SUBSCRIBE_STATUS_CHANGED = 0x05, // forum was subscribed or unsubscribed
|
||||
};
|
||||
|
||||
ForumEventCode mForumEventCode;
|
||||
RsGxsGroupId mForumGroupId;
|
||||
RsGxsMessageId mForumMsgId;
|
||||
|
||||
///* @see RsEvent @see RsSerializable
|
||||
void serial_process( RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) override
|
||||
{
|
||||
RsEvent::serial_process(j, ctx);
|
||||
|
||||
RS_SERIAL_PROCESS(mForumEventCode);
|
||||
RS_SERIAL_PROCESS(mForumGroupId);
|
||||
RS_SERIAL_PROCESS(mForumMsgId);
|
||||
}
|
||||
};
|
||||
|
||||
class RsGxsForums: public RsGxsIfaceHelper
|
||||
{
|
||||
|
|
|
@ -300,6 +300,15 @@ struct RsMailStatusEvent : RsEvent
|
|||
{
|
||||
RsMailStatusEvent() : RsEvent(RsEventType::MAIL_STATUS_CHANGE) {}
|
||||
|
||||
enum MailStatusEventCode: uint8_t {
|
||||
NEW_MESSAGE = 0x00,
|
||||
MESSAGE_REMOVED = 0x01,
|
||||
MESSAGE_SENT = 0x02,
|
||||
MESSAGE_RECEIVED_ACK = 0x03, // means the peer received the message
|
||||
FAILED_SIGNATURE = 0x04, // means the signature of the message cannot be verified
|
||||
};
|
||||
|
||||
MailStatusEventCode mMailStatusEventCode;
|
||||
std::set<RsMailMessageId> mChangedMsgIds;
|
||||
|
||||
/// @see RsEvent
|
||||
|
@ -308,6 +317,7 @@ struct RsMailStatusEvent : RsEvent
|
|||
{
|
||||
RsEvent::serial_process(j, ctx);
|
||||
RS_SERIAL_PROCESS(mChangedMsgIds);
|
||||
RS_SERIAL_PROCESS(mMailStatusEventCode);
|
||||
}
|
||||
|
||||
~RsMailStatusEvent() override;
|
||||
|
|
|
@ -79,9 +79,10 @@ const uint32_t RS_FEED_ITEM_PEER_DISCONNECT = RS_FEED_TYPE_PEER | 0x000
|
|||
const uint32_t RS_FEED_ITEM_PEER_HELLO = RS_FEED_TYPE_PEER | 0x0003;
|
||||
const uint32_t RS_FEED_ITEM_PEER_NEW = RS_FEED_TYPE_PEER | 0x0004;
|
||||
const uint32_t RS_FEED_ITEM_PEER_OFFSET = RS_FEED_TYPE_PEER | 0x0005;
|
||||
const uint32_t RS_FEED_ITEM_PEER_DENIES_CONNEXION = RS_FEED_TYPE_PEER | 0x0006;
|
||||
|
||||
const uint32_t RS_FEED_ITEM_SEC_CONNECT_ATTEMPT = RS_FEED_TYPE_SECURITY | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_SEC_AUTH_DENIED = RS_FEED_TYPE_SECURITY | 0x0002;
|
||||
const uint32_t RS_FEED_ITEM_SEC_AUTH_DENIED = RS_FEED_TYPE_SECURITY | 0x0002; // locally denied connection
|
||||
const uint32_t RS_FEED_ITEM_SEC_UNKNOWN_IN = RS_FEED_TYPE_SECURITY | 0x0003;
|
||||
const uint32_t RS_FEED_ITEM_SEC_UNKNOWN_OUT = RS_FEED_TYPE_SECURITY | 0x0004;
|
||||
const uint32_t RS_FEED_ITEM_SEC_WRONG_SIGNATURE = RS_FEED_TYPE_SECURITY | 0x0005;
|
||||
|
@ -114,8 +115,11 @@ const uint32_t RS_FEED_ITEM_CHAT_NEW = RS_FEED_TYPE_CHAT | 0x0001;
|
|||
const uint32_t RS_FEED_ITEM_MESSAGE = RS_FEED_TYPE_MSG | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_FILES_NEW = RS_FEED_TYPE_FILES | 0x0001;
|
||||
|
||||
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_REQ = RS_FEED_TYPE_CIRCLE | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_CIRCLE_INVIT_REC = RS_FEED_TYPE_CIRCLE | 0x0002;
|
||||
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_REQ = RS_FEED_TYPE_CIRCLE | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_CIRCLE_INVIT_REC = RS_FEED_TYPE_CIRCLE | 0x0002;
|
||||
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_LEAVE = RS_FEED_TYPE_CIRCLE | 0x0003;
|
||||
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_JOIN = RS_FEED_TYPE_CIRCLE | 0x0004;
|
||||
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_REVOQUED = RS_FEED_TYPE_CIRCLE | 0x0005;
|
||||
|
||||
const uint32_t RS_MESSAGE_CONNECT_ATTEMPT = 0x0001;
|
||||
|
||||
|
@ -212,8 +216,6 @@ public:
|
|||
NotifyClient() {}
|
||||
virtual ~NotifyClient() {}
|
||||
|
||||
virtual void notifyPeerConnected (const std::string& /* peer_id */) {}
|
||||
virtual void notifyPeerDisconnected (const std::string& /* peer_id */) {}
|
||||
virtual void notifyListPreChange (int /* list */, int /* type */) {}
|
||||
virtual void notifyListChange (int /* list */, int /* type */) {}
|
||||
virtual void notifyErrorMsg (int /* list */, int /* sev */, std::string /* msg */) {}
|
||||
|
@ -230,8 +232,6 @@ public:
|
|||
virtual void notifyOwnStatusMessageChanged () {}
|
||||
virtual void notifyDiskFull (uint32_t /* location */, uint32_t /* size limit in MB */) {}
|
||||
virtual void notifyPeerStatusChanged (const std::string& /* peer_id */, uint32_t /* status */) {}
|
||||
virtual void notifyGxsChange (const RsGxsChanges& /* changes */) {}
|
||||
virtual void notifyConnectionWithoutCert () {}
|
||||
|
||||
/* one or more peers has changed the states */
|
||||
virtual void notifyPeerStatusChangedSummary () {}
|
||||
|
|
|
@ -206,6 +206,85 @@ std::string RsPeerTrustString(uint32_t trustLvl);
|
|||
std::string RsPeerNetModeString(uint32_t netModel);
|
||||
std::string RsPeerLastConnectString(uint32_t lastConnect);
|
||||
|
||||
//===================================================================================================//
|
||||
// Connexion and security events //
|
||||
//===================================================================================================//
|
||||
|
||||
/**
|
||||
* Event triggered by AuthSSL when authentication of a connection attempt either
|
||||
* fail or success
|
||||
*/
|
||||
struct RsAuthSslConnectionAutenticationEvent : RsEvent
|
||||
{
|
||||
RsAuthSslConnectionAutenticationEvent() : RsEvent(RsEventType::AUTHSSL_CONNECTION_AUTENTICATION) {}
|
||||
|
||||
enum class AuthenticationCode: uint8_t {
|
||||
NO_CONNECTION_ERROR = 0x00,
|
||||
MISSING_AUTHENTICATION_INFO = 0x01,
|
||||
PGP_SIGNATURE_VALIDATION_FAILED = 0x02,
|
||||
MISMATCHED_PGP_ID = 0x03,
|
||||
NO_CERTIFICATE_SUPPLIED = 0x04,
|
||||
NOT_A_FRIEND = 0x05,
|
||||
MISSING_CERTIFICATE = 0x06,
|
||||
IP_IS_BLACKLISTED = 0x07,
|
||||
PEER_REFUSED_CONNECTION = 0x08,
|
||||
UNKNOWN_ERROR = 0x09,
|
||||
};
|
||||
|
||||
RsPeerId mSslId;
|
||||
std::string mSslCn;
|
||||
RsPgpId mPgpId;
|
||||
RsUrl mLocator;
|
||||
std::string mErrorMsg;
|
||||
AuthenticationCode mErrorCode;
|
||||
|
||||
///* @see RsEvent @see RsSerializable
|
||||
void serial_process( RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext& ctx) override
|
||||
{
|
||||
RsEvent::serial_process(j, ctx);
|
||||
RS_SERIAL_PROCESS(mSslId);
|
||||
RS_SERIAL_PROCESS(mSslCn);
|
||||
RS_SERIAL_PROCESS(mPgpId);
|
||||
RS_SERIAL_PROCESS(mLocator);
|
||||
RS_SERIAL_PROCESS(mErrorMsg);
|
||||
RS_SERIAL_PROCESS(mErrorCode);
|
||||
}
|
||||
};
|
||||
|
||||
struct RsConnectionEvent : RsEvent
|
||||
{
|
||||
RsConnectionEvent()
|
||||
: RsEvent(RsEventType::PEER_CONNECTION),
|
||||
mConnectionInfoCode(ConnectionEventCode::UNKNOWN) {}
|
||||
|
||||
enum class ConnectionEventCode: uint8_t {
|
||||
UNKNOWN = 0x00,
|
||||
PEER_CONNECTED = 0x01,
|
||||
PEER_DISCONNECTED = 0x02,
|
||||
PEER_TIME_SHIFT = 0x03, // mStrInfo1 = time shift in seconds
|
||||
PEER_REPORTS_WRONG_IP = 0x04, // mStrInfo1 = address reported, mStrInfo2 = own address
|
||||
};
|
||||
|
||||
ConnectionEventCode mConnectionInfoCode;
|
||||
RsPeerId mSslId;
|
||||
std::string mStrInfo1;
|
||||
std::string mStrInfo2;
|
||||
|
||||
///* @see RsEvent @see RsSerializable
|
||||
void serial_process( RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) override
|
||||
{
|
||||
RsEvent::serial_process(j, ctx);
|
||||
RS_SERIAL_PROCESS(mConnectionInfoCode);
|
||||
RS_SERIAL_PROCESS(mSslId);
|
||||
RS_SERIAL_PROCESS(mStrInfo1);
|
||||
RS_SERIAL_PROCESS(mStrInfo2);
|
||||
}
|
||||
};
|
||||
|
||||
//===================================================================================================//
|
||||
// Peer Details //
|
||||
//===================================================================================================//
|
||||
|
||||
/* We should definitely split this into 2 sub-structures:
|
||||
* PGP info (or profile info) with all info related to PGP keys
|
||||
|
|
|
@ -68,6 +68,30 @@ class RsPostedGroup
|
|||
std::ostream &operator<<(std::ostream &out, const RsPostedGroup &group);
|
||||
std::ostream &operator<<(std::ostream &out, const RsPostedPost &post);
|
||||
|
||||
struct RsGxsPostedEvent: RsEvent
|
||||
{
|
||||
RsGxsPostedEvent()
|
||||
: RsEvent(RsEventType::GXS_POSTED), mPostedEventCode(PostedEventCode::UNKNOWN) {}
|
||||
|
||||
enum class PostedEventCode: uint8_t {
|
||||
UNKNOWN = 0x00,
|
||||
NEW_POSTED_GROUP = 0x01,
|
||||
NEW_MESSAGE = 0x02
|
||||
};
|
||||
|
||||
PostedEventCode mPostedEventCode;
|
||||
RsGxsGroupId mPostedGroupId;
|
||||
RsGxsMessageId mPostedMsgId;
|
||||
|
||||
///* @see RsEvent @see RsSerializable
|
||||
void serial_process( RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) override
|
||||
{
|
||||
RsEvent::serial_process(j, ctx);
|
||||
RS_SERIAL_PROCESS(mPostedEventCode);
|
||||
RS_SERIAL_PROCESS(mPostedGroupId);
|
||||
RS_SERIAL_PROCESS(mPostedMsgId);
|
||||
}
|
||||
};
|
||||
|
||||
class RsPosted : public RsGxsIfaceHelper, public RsGxsCommentService
|
||||
{
|
||||
|
|
|
@ -136,14 +136,14 @@ uint32_t p3GxsChannels::channelsAuthenPolicy()
|
|||
static const uint32_t GXS_CHANNELS_CONFIG_MAX_TIME_NOTIFY_STORAGE = 86400*30*2 ; // ignore notifications for 2 months
|
||||
static const uint8_t GXS_CHANNELS_CONFIG_SUBTYPE_NOTIFY_RECORD = 0x01 ;
|
||||
|
||||
struct RsGxsForumNotifyRecordsItem: public RsItem
|
||||
struct RsGxsGroupNotifyRecordsItem: public RsItem
|
||||
{
|
||||
|
||||
RsGxsForumNotifyRecordsItem()
|
||||
RsGxsGroupNotifyRecordsItem()
|
||||
: RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_GXS_TYPE_CHANNELS_CONFIG,GXS_CHANNELS_CONFIG_SUBTYPE_NOTIFY_RECORD)
|
||||
{}
|
||||
|
||||
virtual ~RsGxsForumNotifyRecordsItem() {}
|
||||
virtual ~RsGxsGroupNotifyRecordsItem() {}
|
||||
|
||||
void serial_process( RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext& ctx )
|
||||
|
@ -167,7 +167,7 @@ public:
|
|||
|
||||
switch(item_sub_id)
|
||||
{
|
||||
case GXS_CHANNELS_CONFIG_SUBTYPE_NOTIFY_RECORD: return new RsGxsForumNotifyRecordsItem();
|
||||
case GXS_CHANNELS_CONFIG_SUBTYPE_NOTIFY_RECORD: return new RsGxsGroupNotifyRecordsItem();
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ bool p3GxsChannels::saveList(bool &cleanup, std::list<RsItem *>&saveList)
|
|||
{
|
||||
cleanup = true ;
|
||||
|
||||
RsGxsForumNotifyRecordsItem *item = new RsGxsForumNotifyRecordsItem ;
|
||||
RsGxsGroupNotifyRecordsItem *item = new RsGxsGroupNotifyRecordsItem ;
|
||||
|
||||
{
|
||||
RS_STACK_MUTEX(mKnownChannelsMutex);
|
||||
|
@ -198,7 +198,7 @@ bool p3GxsChannels::loadList(std::list<RsItem *>& loadList)
|
|||
|
||||
rstime_t now = time(NULL);
|
||||
|
||||
RsGxsForumNotifyRecordsItem *fnr = dynamic_cast<RsGxsForumNotifyRecordsItem*>(item) ;
|
||||
RsGxsGroupNotifyRecordsItem *fnr = dynamic_cast<RsGxsGroupNotifyRecordsItem*>(item) ;
|
||||
|
||||
if(fnr)
|
||||
{
|
||||
|
@ -238,12 +238,6 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
std::cerr << "p3GxsChannels::notifyChanges() : " << changes.size() << "changes to notify" << std::endl;
|
||||
#endif
|
||||
|
||||
p3Notify* notify = nullptr;
|
||||
if (!changes.empty())
|
||||
{
|
||||
notify = RsServer::notify();
|
||||
}
|
||||
|
||||
/* iterate through and grab any new messages */
|
||||
std::list<RsGxsGroupId> unprocessedGroups;
|
||||
|
||||
|
@ -256,13 +250,19 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
if (msgChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW)
|
||||
{
|
||||
/* message received */
|
||||
if (notify)
|
||||
if (rsEvents)
|
||||
{
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
for (auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
||||
{
|
||||
notify->AddFeedItem(RS_FEED_ITEM_CHANNEL_MSG, mit->first.toStdString(), mit1->toStdString());
|
||||
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||
|
||||
ev->mChannelMsgId = *mit1;
|
||||
ev->mChannelGroupId = mit->first;
|
||||
ev->mChannelEventCode = RsGxsChannelEvent::ChannelEventCode::NEW_MESSAGE;
|
||||
|
||||
rsEvents->sendEvent(ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -298,48 +298,74 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (notify)
|
||||
if (rsEvents)
|
||||
{
|
||||
RsGxsGroupChange *grpChange = dynamic_cast<RsGxsGroupChange*>(*it);
|
||||
if (grpChange)
|
||||
{
|
||||
switch (grpChange->getType())
|
||||
{
|
||||
default:
|
||||
case RsGxsNotify::TYPE_PROCESSED:
|
||||
case RsGxsNotify::TYPE_PUBLISHED:
|
||||
break;
|
||||
|
||||
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
||||
default:
|
||||
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
|
||||
{
|
||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||
std::list<RsGxsGroupId>::iterator git;
|
||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||
{
|
||||
/* group received */
|
||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||
std::list<RsGxsGroupId>::iterator git;
|
||||
RS_STACK_MUTEX(mKnownChannelsMutex);
|
||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||
{
|
||||
if(mKnownChannels.find(*git) == mKnownChannels.end())
|
||||
{
|
||||
notify->AddFeedItem(RS_FEED_ITEM_CHANNEL_NEW, git->toStdString());
|
||||
mKnownChannels.insert(std::make_pair(*git,time(NULL))) ;
|
||||
}
|
||||
else
|
||||
std::cerr << "(II) Not notifying already known channel " << *git << std::endl;
|
||||
}
|
||||
break;
|
||||
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||
|
||||
ev->mChannelGroupId = *git;
|
||||
ev->mChannelEventCode = RsGxsChannelEvent::ChannelEventCode::SUBSCRIBE_STATUS_CHANGED;
|
||||
|
||||
rsEvents->sendEvent(ev);
|
||||
}
|
||||
|
||||
case RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY:
|
||||
}
|
||||
break;
|
||||
|
||||
case RsGxsNotify::TYPE_PUBLISHED:
|
||||
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
||||
{
|
||||
/* group received */
|
||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||
std::list<RsGxsGroupId>::iterator git;
|
||||
RS_STACK_MUTEX(mKnownChannelsMutex);
|
||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||
{
|
||||
/* group received */
|
||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||
std::list<RsGxsGroupId>::iterator git;
|
||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||
if(mKnownChannels.find(*git) == mKnownChannels.end())
|
||||
{
|
||||
notify->AddFeedItem(RS_FEED_ITEM_CHANNEL_PUBLISHKEY, git->toStdString());
|
||||
mKnownChannels.insert(std::make_pair(*git,time(NULL))) ;
|
||||
IndicateConfigChanged();
|
||||
|
||||
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||
|
||||
ev->mChannelGroupId = *git;
|
||||
ev->mChannelEventCode = RsGxsChannelEvent::ChannelEventCode::NEW_CHANNEL;
|
||||
|
||||
rsEvents->sendEvent(ev);
|
||||
}
|
||||
break;
|
||||
else
|
||||
std::cerr << "(II) Not notifying already known channel " << *git << std::endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY:
|
||||
{
|
||||
/* group received */
|
||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||
std::list<RsGxsGroupId>::iterator git;
|
||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||
{
|
||||
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||
|
||||
ev->mChannelGroupId = *git;
|
||||
ev->mChannelEventCode = RsGxsChannelEvent::ChannelEventCode::RECEIVED_PUBLISH_KEY;
|
||||
|
||||
rsEvents->sendEvent(ev);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -351,6 +377,7 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
if(!unprocessedGroups.empty())
|
||||
request_SpecificSubscribedGroups(unprocessedGroups);
|
||||
|
||||
// the call below deletes changes and its content.
|
||||
RsGxsIfaceHelper::receiveChanges(changes);
|
||||
}
|
||||
|
||||
|
|
|
@ -305,6 +305,32 @@ bool p3GxsCircles::getCircleRequests( const RsGxsGroupId& circleId,
|
|||
return getMsgData(token, requests);
|
||||
}
|
||||
|
||||
bool p3GxsCircles::getCircleRequest(const RsGxsGroupId& circleId,const RsGxsMessageId& msgId,RsGxsCircleMsg& msg)
|
||||
{
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
|
||||
std::set<RsGxsMessageId> contentsIds;
|
||||
contentsIds.insert(msgId);
|
||||
|
||||
GxsMsgReq msgIds;
|
||||
msgIds[circleId] = contentsIds;
|
||||
|
||||
uint32_t token;
|
||||
if( !requestMsgInfo(token, opts, msgIds) || waitToken(token) != RsTokenService::COMPLETE )
|
||||
return false;
|
||||
|
||||
std::vector<RsGxsCircleMsg> msgs;
|
||||
|
||||
if(getMsgData(token, msgs) && msgs.size() == 1)
|
||||
{
|
||||
msg = msgs.front();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3GxsCircles::inviteIdsToCircle( const std::set<RsGxsId>& identities,
|
||||
const RsGxsCircleId& circleId )
|
||||
{
|
||||
|
@ -442,6 +468,7 @@ void p3GxsCircles::service_tick()
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||
{
|
||||
#ifdef DEBUG_CIRCLES
|
||||
|
@ -467,13 +494,33 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
#ifdef DEBUG_CIRCLES
|
||||
std::cerr << " Msgs for Group: " << mit->first << std::endl;
|
||||
#endif
|
||||
force_cache_reload(RsGxsCircleId(mit->first));
|
||||
RsGxsCircleId circle_id(mit->first);
|
||||
|
||||
if (notify && (c->getType() == RsGxsNotify::TYPE_RECEIVED_NEW) )
|
||||
force_cache_reload(circle_id);
|
||||
|
||||
RsGxsCircleDetails details;
|
||||
getCircleDetails(circle_id,details);
|
||||
|
||||
if(rsEvents && (c->getType() == RsGxsNotify::TYPE_RECEIVED_NEW) )
|
||||
for (auto msgIdIt(mit->second.begin()), end(mit->second.end()); msgIdIt != end; ++msgIdIt)
|
||||
{
|
||||
const RsGxsMessageId& msgId = *msgIdIt;
|
||||
notify->AddFeedItem(RS_FEED_ITEM_CIRCLE_MEMB_REQ,RsGxsCircleId(mit->first).toStdString(),msgId.toStdString());
|
||||
// @Gio: should this be async?
|
||||
RsGxsCircleMsg msg;
|
||||
getCircleRequest(RsGxsGroupId(circle_id),*msgIdIt,msg);
|
||||
|
||||
auto ev = std::make_shared<RsGxsCircleEvent>();
|
||||
|
||||
ev->mCircleId = circle_id;
|
||||
ev->mGxsId = msg.mMeta.mAuthorId;
|
||||
|
||||
if (msg.stuff == "SUBSCRIPTION_REQUEST_UNSUBSCRIBE")
|
||||
ev->mCircleEventType = RsGxsCircleEvent::CircleEventCode::CIRCLE_MEMBERSHIP_LEAVE;
|
||||
else if(details.mAllowedGxsIds.find(msg.mMeta.mAuthorId) != details.mAllowedGxsIds.end())
|
||||
ev->mCircleEventType = RsGxsCircleEvent::CircleEventCode::CIRCLE_MEMBERSHIP_JOIN;
|
||||
else
|
||||
ev->mCircleEventType = RsGxsCircleEvent::CircleEventCode::CIRCLE_MEMBERSHIP_REQUEST;
|
||||
|
||||
rsEvents->sendEvent(ev);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -506,15 +553,59 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
}
|
||||
|
||||
if(groupChange)
|
||||
{
|
||||
std::list<RsGxsId> own_ids;
|
||||
rsIdentity->getOwnIds(own_ids);
|
||||
|
||||
for(std::list<RsGxsGroupId>::const_iterator git(groupChange->mGrpIdList.begin());git!=groupChange->mGrpIdList.end();++git)
|
||||
{
|
||||
#ifdef DEBUG_CIRCLES
|
||||
std::cerr << " forcing cache loading for circle " << *git << " in order to trigger subscribe update." << std::endl;
|
||||
#endif
|
||||
force_cache_reload(RsGxsCircleId(*git)) ;
|
||||
if (notify && (c->getType() == RsGxsNotify::TYPE_RECEIVED_NEW) )
|
||||
notify->AddFeedItem(RS_FEED_ITEM_CIRCLE_INVIT_REC,RsGxsCircleId(*git).toStdString(),"");
|
||||
}
|
||||
|
||||
#ifdef TODO
|
||||
// This code will not work: we would like to detect changes in the circle data that reflects the fact that one of the
|
||||
// owned GXS ids is invited. But there's no way to compare the old circle data to the new if cache has to be updated.
|
||||
// For this we need to add the old metadata and group data in the RsGxsGroupChange structure and account for it.
|
||||
|
||||
if(rsEvents && (c->getType() == RsGxsNotify::TYPE_RECEIVED_NEW) )
|
||||
{
|
||||
RsGxsCircleId circle_id(*git);
|
||||
force_cache_reload(circle_id);
|
||||
|
||||
RsGxsCircleDetails details;
|
||||
getCircleDetails(circle_id,details);
|
||||
|
||||
// We check that the change corresponds to one of our own ids. Since we do not know what the change is, we notify
|
||||
// for whatever is different from what is currently known. Other ids, that get invited only trigger a notification when the
|
||||
// ID also accepts the invitation, so it becomes a member of the circle.
|
||||
|
||||
for(auto own_id: own_ids)
|
||||
{
|
||||
auto it = details.mSubscriptionFlags.find(own_id);
|
||||
|
||||
if(it == details.mSubscriptionFlags.end())
|
||||
continue;
|
||||
|
||||
bool invited ( it->second & GXS_EXTERNAL_CIRCLE_FLAGS_IN_ADMIN_LIST );
|
||||
bool subscrb ( it->second & GXS_EXTERNAL_CIRCLE_FLAGS_SUBSCRIBED );
|
||||
|
||||
if(std::find(details.mAllowedGxsIds.begin(),details.mAllowedGxsIds.end(),id) != details.mAllowedGxsIds.end() && !me_in_circle)
|
||||
{
|
||||
auto ev = std::make_shared<RsGxsCircleEvent>();
|
||||
|
||||
ev->mType = RsGxsCircleEvent::CIRCLE_MEMBERSHIP_INVITE;
|
||||
ev->mCircleId = circle_id;
|
||||
ev->mGxsId = ;
|
||||
|
||||
rsEvents->sendEvent(ev);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
RsGxsIfaceHelper::receiveChanges(changes); // this clear up the vector and delete its elements
|
||||
|
@ -550,6 +641,7 @@ bool p3GxsCircles::getCircleDetails(
|
|||
details.mSubscriptionFlags.clear();
|
||||
details.mAllowedGxsIds.clear();
|
||||
details.mAmIAllowed = false ;
|
||||
details.mAmIAdmin = bool(data.mGroupSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN);
|
||||
|
||||
for(std::map<RsGxsId,RsGxsCircleMembershipStatus>::const_iterator it(data.mMembershipStatus.begin());it!=data.mMembershipStatus.end();++it)
|
||||
{
|
||||
|
@ -860,7 +952,7 @@ RsGxsCircleCache::RsGxsCircleCache()
|
|||
mUpdateTime = 0;
|
||||
mGroupStatus = 0;
|
||||
mGroupSubscribeFlags = 0;
|
||||
mLastUpdatedMembershipTS = 0 ;
|
||||
mLastUpdatedMembershipTS = 0 ;
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -208,6 +208,11 @@ public:
|
|||
bool inviteIdsToCircle( const std::set<RsGxsId>& identities,
|
||||
const RsGxsCircleId& circleId ) override;
|
||||
|
||||
/// @see RsGxsCircles
|
||||
bool getCircleRequest(const RsGxsGroupId& circleId,
|
||||
const RsGxsMessageId& msgId,
|
||||
RsGxsCircleMsg& msg) override;
|
||||
|
||||
/// @see RsGxsCircles
|
||||
bool exportCircleLink(
|
||||
std::string& link, const RsGxsCircleId& circleId,
|
||||
|
|
|
@ -53,7 +53,7 @@ p3GxsForums::p3GxsForums( RsGeneralDataService *gds,
|
|||
RsGenExchange( gds, nes, new RsGxsForumSerialiser(),
|
||||
RS_SERVICE_GXS_TYPE_FORUMS, gixs, forumsAuthenPolicy()),
|
||||
RsGxsForums(static_cast<RsGxsIface&>(*this)), mGenToken(0),
|
||||
mGenActive(false), mGenCount(0)
|
||||
mGenActive(false), mGenCount(0), mKnownForumsMutex("GXS forums known forums timestamp cache")
|
||||
{
|
||||
// Test Data disabled in Repo.
|
||||
//RsTickEvent::schedule_in(FORUM_TESTEVENT_DUMMYDATA, DUMMYDATA_PERIOD);
|
||||
|
@ -96,14 +96,14 @@ uint32_t p3GxsForums::forumsAuthenPolicy()
|
|||
static const uint32_t GXS_FORUMS_CONFIG_MAX_TIME_NOTIFY_STORAGE = 86400*30*2 ; // ignore notifications for 2 months
|
||||
static const uint8_t GXS_FORUMS_CONFIG_SUBTYPE_NOTIFY_RECORD = 0x01 ;
|
||||
|
||||
struct RsGxsForumNotifyRecordsItem: public RsItem
|
||||
struct RsGxsGroupNotifyRecordsItem: public RsItem
|
||||
{
|
||||
|
||||
RsGxsForumNotifyRecordsItem()
|
||||
RsGxsGroupNotifyRecordsItem()
|
||||
: RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_GXS_TYPE_FORUMS_CONFIG,GXS_FORUMS_CONFIG_SUBTYPE_NOTIFY_RECORD)
|
||||
{}
|
||||
|
||||
virtual ~RsGxsForumNotifyRecordsItem() {}
|
||||
virtual ~RsGxsGroupNotifyRecordsItem() {}
|
||||
|
||||
void serial_process( RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext& ctx )
|
||||
|
@ -127,7 +127,7 @@ public:
|
|||
|
||||
switch(item_sub_id)
|
||||
{
|
||||
case GXS_FORUMS_CONFIG_SUBTYPE_NOTIFY_RECORD: return new RsGxsForumNotifyRecordsItem();
|
||||
case GXS_FORUMS_CONFIG_SUBTYPE_NOTIFY_RECORD: return new RsGxsGroupNotifyRecordsItem();
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ bool p3GxsForums::saveList(bool &cleanup, std::list<RsItem *>&saveList)
|
|||
{
|
||||
cleanup = true ;
|
||||
|
||||
RsGxsForumNotifyRecordsItem *item = new RsGxsForumNotifyRecordsItem ;
|
||||
RsGxsGroupNotifyRecordsItem *item = new RsGxsGroupNotifyRecordsItem ;
|
||||
|
||||
item->records = mKnownForums ;
|
||||
|
||||
|
@ -155,7 +155,7 @@ bool p3GxsForums::loadList(std::list<RsItem *>& loadList)
|
|||
|
||||
rstime_t now = time(NULL);
|
||||
|
||||
RsGxsForumNotifyRecordsItem *fnr = dynamic_cast<RsGxsForumNotifyRecordsItem*>(item) ;
|
||||
RsGxsGroupNotifyRecordsItem *fnr = dynamic_cast<RsGxsGroupNotifyRecordsItem*>(item) ;
|
||||
|
||||
if(fnr != NULL)
|
||||
{
|
||||
|
@ -181,82 +181,143 @@ RsSerialiser* p3GxsForums::setupSerialiser()
|
|||
|
||||
void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||
{
|
||||
if (!changes.empty())
|
||||
#ifdef GXSFORUMS_DEBUG
|
||||
std::cerr << "p3GxsForums::notifyChanges() : " << changes.size() << "changes to notify" << std::endl;
|
||||
#endif
|
||||
|
||||
std::vector<RsGxsNotify *>::iterator it;
|
||||
for(it = changes.begin(); it != changes.end(); ++it)
|
||||
{
|
||||
p3Notify *notify = RsServer::notify();
|
||||
|
||||
if (notify)
|
||||
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange *>(*it);
|
||||
if (msgChange)
|
||||
{
|
||||
std::vector<RsGxsNotify*>::iterator it;
|
||||
for(it = changes.begin(); it != changes.end(); ++it)
|
||||
{
|
||||
RsGxsNotify *c = *it;
|
||||
|
||||
switch (c->getType())
|
||||
if (msgChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW) /* message received */
|
||||
if (rsEvents)
|
||||
{
|
||||
default:
|
||||
case RsGxsNotify::TYPE_PROCESSED:
|
||||
case RsGxsNotify::TYPE_PUBLISHED:
|
||||
break;
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> >& msgChangeMap = msgChange->msgChangeMap;
|
||||
for (auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
||||
{
|
||||
auto ev = std::make_shared<RsGxsForumEvent>();
|
||||
|
||||
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
||||
ev->mForumMsgId = *mit1;
|
||||
ev->mForumGroupId = mit->first;
|
||||
ev->mForumEventCode = RsGxsForumEvent::ForumEventCode::NEW_MESSAGE;
|
||||
|
||||
rsEvents->sendEvent(ev);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NOT_USED_YET
|
||||
if (!msgChange->metaChange())
|
||||
{
|
||||
#ifdef GXSCHANNELS_DEBUG
|
||||
std::cerr << "p3GxsForums::notifyChanges() Found Message Change Notification";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
for(auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
{
|
||||
#ifdef GXSCHANNELS_DEBUG
|
||||
std::cerr << "p3GxsForums::notifyChanges() Msgs for Group: " << mit->first;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
bool enabled = false;
|
||||
if (autoDownloadEnabled(mit->first, enabled) && enabled)
|
||||
{
|
||||
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange*>(c);
|
||||
if (msgChange)
|
||||
{
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
#ifdef GXSCHANNELS_DEBUG
|
||||
std::cerr << "p3GxsChannels::notifyChanges() AutoDownload for Group: " << mit->first;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
for (auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
{
|
||||
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
||||
notify->AddFeedItem(RS_FEED_ITEM_FORUM_MSG, mit->first.toStdString(), mit1->toStdString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
RsGxsGroupChange *grpChange = dynamic_cast<RsGxsGroupChange *>(*it);
|
||||
if (grpChange)
|
||||
{
|
||||
/* group received */
|
||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||
std::list<RsGxsGroupId>::iterator git;
|
||||
|
||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||
{
|
||||
if(mKnownForums.find(*git) == mKnownForums.end())
|
||||
{
|
||||
notify->AddFeedItem(RS_FEED_ITEM_FORUM_NEW, git->toStdString());
|
||||
mKnownForums.insert(std::make_pair(*git,time(NULL))) ;
|
||||
|
||||
IndicateConfigChanged();
|
||||
}
|
||||
else
|
||||
std::cerr << "(II) Not notifying already known forum " << *git << std::endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY:
|
||||
{
|
||||
RsGxsGroupChange *grpChange = dynamic_cast<RsGxsGroupChange *>(*it);
|
||||
if (grpChange)
|
||||
{
|
||||
/* group received */
|
||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||
std::list<RsGxsGroupId>::iterator git;
|
||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||
{
|
||||
notify->AddFeedItem(RS_FEED_ITEM_FORUM_PUBLISHKEY, git->toStdString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
/* problem is most of these will be comments and votes,
|
||||
* should make it occasional - every 5mins / 10minutes TODO */
|
||||
unprocessedGroups.push_back(mit->first);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rsEvents)
|
||||
{
|
||||
RsGxsGroupChange *grpChange = dynamic_cast<RsGxsGroupChange*>(*it);
|
||||
if (grpChange)
|
||||
{
|
||||
switch (grpChange->getType())
|
||||
{
|
||||
default:
|
||||
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
|
||||
{
|
||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||
std::list<RsGxsGroupId>::iterator git;
|
||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||
{
|
||||
auto ev = std::make_shared<RsGxsForumEvent>();
|
||||
|
||||
ev->mForumGroupId = *git;
|
||||
ev->mForumEventCode = RsGxsForumEvent::ForumEventCode::SUBSCRIBE_STATUS_CHANGED;
|
||||
|
||||
rsEvents->sendEvent(ev);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case RsGxsNotify::TYPE_PUBLISHED:
|
||||
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
||||
{
|
||||
/* group received */
|
||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||
std::list<RsGxsGroupId>::iterator git;
|
||||
|
||||
RS_STACK_MUTEX(mKnownForumsMutex);
|
||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||
{
|
||||
if(mKnownForums.find(*git) == mKnownForums.end())
|
||||
{
|
||||
mKnownForums.insert(std::make_pair(*git,time(NULL))) ;
|
||||
IndicateConfigChanged();
|
||||
|
||||
auto ev = std::make_shared<RsGxsForumEvent>();
|
||||
|
||||
ev->mForumGroupId = *git;
|
||||
ev->mForumEventCode = RsGxsForumEvent::ForumEventCode::NEW_FORUM;
|
||||
|
||||
rsEvents->sendEvent(ev);
|
||||
}
|
||||
else
|
||||
std::cerr << "(II) Not notifying already known channel " << *git << std::endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef NOT_USED_YET
|
||||
case RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY:
|
||||
{
|
||||
/* group received */
|
||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||
std::list<RsGxsGroupId>::iterator git;
|
||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||
{
|
||||
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||
|
||||
ev->mChannelGroupId = *git;
|
||||
ev->mChannelEventCode = RsGxsChannelEvent::RECEIVED_PUBLISH_KEY;
|
||||
|
||||
rsEvents->sendEvent(ev);
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* shouldn't need to worry about groups - as they need to be subscribed to */
|
||||
}
|
||||
|
||||
RsGxsIfaceHelper::receiveChanges(changes);
|
||||
|
|
|
@ -166,4 +166,5 @@ bool generateGroup(uint32_t &token, std::string groupName);
|
|||
RsGxsMessageId mGenThreadId;
|
||||
std::map<RsGxsGroupId,rstime_t> mKnownForums ;
|
||||
|
||||
RsMutex mKnownForumsMutex;
|
||||
};
|
||||
|
|
|
@ -175,15 +175,14 @@ void p3MsgService::processIncomingMsg(RsMsgItem *mi)
|
|||
mi->msgFlags &= (RS_MSG_FLAGS_DISTANT | RS_MSG_FLAGS_SYSTEM); // remove flags except those
|
||||
mi->msgFlags |= RS_MSG_FLAGS_NEW;
|
||||
|
||||
p3Notify *notify = RsServer::notify();
|
||||
if (notify)
|
||||
if (rsEvents)
|
||||
{
|
||||
notify->AddPopupMessage(RS_POPUP_MSG, mi->PeerId().toStdString(), mi->subject, mi->message);
|
||||
auto ev = std::make_shared<RsMailStatusEvent>();
|
||||
ev->mMailStatusEventCode = RsMailStatusEvent::NEW_MESSAGE;
|
||||
ev->mChangedMsgIds.insert(std::to_string(mi->msgId));
|
||||
|
||||
std::string out;
|
||||
rs_sprintf(out, "%lu", mi->msgId);
|
||||
notify->AddFeedItem(RS_FEED_ITEM_MESSAGE, out, "", "");
|
||||
}
|
||||
rsEvents->sendEvent(ev);
|
||||
}
|
||||
|
||||
imsg[mi->msgId] = mi;
|
||||
RsMsgSrcId* msi = new RsMsgSrcId();
|
||||
|
@ -207,13 +206,6 @@ void p3MsgService::processIncomingMsg(RsMsgItem *mi)
|
|||
}
|
||||
|
||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_ADD);
|
||||
|
||||
if(rsEvents)
|
||||
{
|
||||
std::shared_ptr<RsMailStatusEvent> pEvent(new RsMailStatusEvent());
|
||||
pEvent->mChangedMsgIds.insert(std::to_string(mi->msgId));
|
||||
rsEvents->postEvent(pEvent);
|
||||
}
|
||||
}
|
||||
|
||||
bool p3MsgService::checkAndRebuildPartialMessage(RsMsgItem *ci)
|
||||
|
@ -345,8 +337,8 @@ int p3MsgService::checkOutgoingMessages()
|
|||
bool changed = false;
|
||||
std::list<RsMsgItem*> output_queue;
|
||||
|
||||
using Evt_t = RsMailStatusEvent;
|
||||
std::shared_ptr<Evt_t> pEvent(new Evt_t());
|
||||
auto pEvent = std::make_shared<RsMailStatusEvent>();
|
||||
pEvent->mMailStatusEventCode = RsMailStatusEvent::MESSAGE_SENT;
|
||||
|
||||
{
|
||||
RS_STACK_MUTEX(mMsgMtx); /********** STACK LOCKED MTX ******/
|
||||
|
@ -404,11 +396,10 @@ int p3MsgService::checkOutgoingMessages()
|
|||
mit->second->msgFlags |= RS_MSG_FLAGS_ROUTED;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG_DISTANT_MSG
|
||||
else
|
||||
{
|
||||
Dbg3() << __PRETTY_FUNCTION__ << " Delaying until available..."
|
||||
<< std::endl;
|
||||
}
|
||||
Dbg3() << __PRETTY_FUNCTION__ << " Delaying until available..." << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* clean up */
|
||||
|
@ -906,8 +897,10 @@ bool p3MsgService::removeMsgId(const std::string &mid)
|
|||
}
|
||||
|
||||
bool changed = false;
|
||||
using Evt_t = RsMailStatusEvent;
|
||||
std::shared_ptr<Evt_t> pEvent(new Evt_t());
|
||||
|
||||
auto pEvent = std::make_shared<RsMailStatusEvent>();
|
||||
|
||||
pEvent->mMailStatusEventCode = RsMailStatusEvent::MESSAGE_REMOVED;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
||||
|
@ -1274,8 +1267,9 @@ uint32_t p3MsgService::sendMail(
|
|||
std::back_inserter(msgInfo.files) );
|
||||
|
||||
uint32_t ret = 0;
|
||||
using Evt_t = RsMailStatusEvent;
|
||||
std::shared_ptr<Evt_t> pEvent(new Evt_t());
|
||||
|
||||
auto pEvent = std::make_shared<RsMailStatusEvent>();
|
||||
pEvent->mMailStatusEventCode = RsMailStatusEvent::MESSAGE_SENT;
|
||||
|
||||
auto pSend = [&](const std::set<RsGxsId>& sDest)
|
||||
{
|
||||
|
@ -2089,9 +2083,11 @@ void p3MsgService::notifyDataStatus( const GRouterMsgPropagationId& id,
|
|||
NOTIFY_TYPE_ADD );
|
||||
IndicateConfigChanged();
|
||||
|
||||
using Evt_t = RsMailStatusEvent;
|
||||
std::shared_ptr<Evt_t> pEvent(new Evt_t());
|
||||
auto pEvent = std::make_shared<RsMailStatusEvent>();
|
||||
|
||||
pEvent->mMailStatusEventCode = RsMailStatusEvent::NEW_MESSAGE;
|
||||
pEvent->mChangedMsgIds.insert(std::to_string(msg_id));
|
||||
|
||||
if(rsEvents) rsEvents->postEvent(pEvent);
|
||||
|
||||
return;
|
||||
|
@ -2189,11 +2185,11 @@ bool p3MsgService::notifyGxsTransSendStatus( RsGxsTransId mailId,
|
|||
Dbg2() << __PRETTY_FUNCTION__ << " " << mailId << ", "
|
||||
<< static_cast<uint32_t>(status) << std::endl;
|
||||
|
||||
using Evt_t = RsMailStatusEvent;
|
||||
std::shared_ptr<Evt_t> pEvent(new Evt_t());
|
||||
auto pEvent = std::make_shared<RsMailStatusEvent>();
|
||||
|
||||
if( status == GxsTransSendStatus::RECEIPT_RECEIVED )
|
||||
{
|
||||
pEvent->mMailStatusEventCode = RsMailStatusEvent::NEW_MESSAGE;
|
||||
uint32_t msg_id;
|
||||
|
||||
{
|
||||
|
@ -2248,6 +2244,7 @@ bool p3MsgService::notifyGxsTransSendStatus( RsGxsTransId mailId,
|
|||
else if( status >= GxsTransSendStatus::FAILED_RECEIPT_SIGNATURE )
|
||||
{
|
||||
uint32_t msg_id;
|
||||
pEvent->mMailStatusEventCode = RsMailStatusEvent::FAILED_SIGNATURE;
|
||||
|
||||
{
|
||||
RS_STACK_MUTEX(gxsOngoingMutex);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "rsitems/rsgxscommentitems.h"
|
||||
|
||||
#include "rsserver/p3face.h"
|
||||
#include "retroshare/rsnotify.h"
|
||||
#include "retroshare/rsposted.h"
|
||||
|
||||
// For Dummy Msgs.
|
||||
#include "util/rsrandom.h"
|
||||
|
@ -87,12 +87,6 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
p3Notify *notify = NULL;
|
||||
if (!changes.empty())
|
||||
{
|
||||
notify = RsServer::notify();
|
||||
}
|
||||
|
||||
std::vector<RsGxsNotify *>::iterator it;
|
||||
|
||||
for(it = changes.begin(); it != changes.end(); ++it)
|
||||
|
@ -118,13 +112,17 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
// It could be taken a step further and directly request these msgs for an update.
|
||||
addGroupForProcessing(mit->first);
|
||||
|
||||
if (notify && msgChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW)
|
||||
{
|
||||
if (rsEvents && msgChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW)
|
||||
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
||||
{
|
||||
notify->AddFeedItem(RS_FEED_ITEM_POSTED_MSG, mit->first.toStdString(), mit1->toStdString());
|
||||
auto ev = std::make_shared<RsGxsPostedEvent>();
|
||||
|
||||
ev->mPostedMsgId = *mit1;
|
||||
ev->mPostedGroupId = mit->first;
|
||||
ev->mPostedEventCode = RsGxsPostedEvent::PostedEventCode::NEW_MESSAGE;
|
||||
|
||||
rsEvents->sendEvent(ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,17 +135,22 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
#endif
|
||||
|
||||
std::list<RsGxsGroupId> &groupList = groupChange->mGrpIdList;
|
||||
std::list<RsGxsGroupId>::iterator git;
|
||||
for(git = groupList.begin(); git != groupList.end(); ++git)
|
||||
|
||||
for(auto git = groupList.begin(); git != groupList.end(); ++git)
|
||||
{
|
||||
#ifdef POSTBASE_DEBUG
|
||||
std::cerr << "p3PostBase::notifyChanges() Incoming Group: " << *git;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if (notify && groupChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW)
|
||||
if (rsEvents && groupChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW)
|
||||
{
|
||||
notify->AddFeedItem(RS_FEED_ITEM_POSTED_NEW, git->toStdString());
|
||||
auto ev = std::make_shared<RsGxsPostedEvent>();
|
||||
|
||||
ev->mPostedGroupId = *git;
|
||||
ev->mPostedEventCode = RsGxsPostedEvent::PostedEventCode::NEW_POSTED_GROUP;
|
||||
|
||||
rsEvents->sendEvent(ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include "util/rsdir.h"
|
||||
#include "retroshare/rsiface.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
#include "pqi/pqibin.h"
|
||||
#include "pqi/pqistore.h"
|
||||
#include "pqi/p3linkmgr.h"
|
||||
|
@ -367,12 +368,16 @@ int p3rtt::storePongResult(const RsPeerId& id, uint32_t counter, double recv_ts,
|
|||
peerInfo->mCurrentMeanOffset = mean / peerInfo->mPongResults.size();
|
||||
if(fabs(peerInfo->mCurrentMeanOffset) > 120)
|
||||
{
|
||||
p3Notify *notify = RsServer::notify();
|
||||
if (notify)
|
||||
{
|
||||
//notify->AddPopupMessage(RS_POPUP_OFFSET, eerInfo->mId.toStdString(),"", "Time Offset: ");
|
||||
notify->AddFeedItem(RS_FEED_ITEM_PEER_OFFSET, peerInfo->mId.toStdString());
|
||||
}
|
||||
if(rsEvents)
|
||||
{
|
||||
auto ev = std::make_shared<RsConnectionEvent>();
|
||||
|
||||
ev->mSslId = peerInfo->mId;
|
||||
ev->mStrInfo1 = RsUtil::NumberToString(peerInfo->mCurrentMeanOffset,false);
|
||||
ev->mConnectionInfoCode = RsConnectionEvent::ConnectionEventCode::PEER_TIME_SHIFT;
|
||||
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
std::cerr << "(WW) Peer:" << peerInfo->mId << " get time offset more than two minutes with you!!!" << std::endl;
|
||||
}
|
||||
}
|
||||
|
@ -438,6 +443,7 @@ bool RttPeerInfo::initialisePeerInfo(const RsPeerId& id)
|
|||
mCurrentPingTS = 0;
|
||||
mCurrentPingCounter = 0;
|
||||
mCurrentPongRecvd = true;
|
||||
mCurrentMeanOffset = 0;
|
||||
|
||||
mSentPings = 0;
|
||||
mLostPongs = 0;
|
||||
|
|
|
@ -34,6 +34,8 @@ class p3ServiceControl;
|
|||
class RttPeerInfo
|
||||
{
|
||||
public:
|
||||
RttPeerInfo()
|
||||
: mCurrentPingTS(0.0),mCurrentPingCounter(0.0),mCurrentPongRecvd(false),mCurrentMeanOffset(0.0),mLostPongs(0),mSentPings(0){}
|
||||
|
||||
bool initialisePeerInfo(const RsPeerId& id);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue