Fix few glitches in Cyril PR

This commit is contained in:
Gioacchino Mazzurco 2020-01-07 00:54:49 +01:00
parent c96223a2a8
commit 37b5d8f307
No known key found for this signature in database
GPG Key ID: A1FBCA3872E87051
25 changed files with 430 additions and 424 deletions

View File

@ -1222,7 +1222,7 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
ev->mSslId = sslId;
ev->mPgpId = pgpId;
ev->mErrorMsg = errMsg;
ev->mErrorCode = RsAuthSslConnectionAutenticationEvent::AuthenticationCode::MISSING_AUTHENTICATION_INFO;
ev->mErrorCode = RsAuthSslError::MISSING_AUTHENTICATION_INFO;
rsEvents->postEvent(std::move(ev));
}
@ -1242,7 +1242,7 @@ 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;
ev->mErrorCode = RsAuthSslError::MISSING_AUTHENTICATION_INFO;
rsEvents->postEvent(std::move(ev));
}
@ -1273,7 +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;
ev->mErrorCode = RsAuthSslError::MISMATCHED_PGP_ID;
rsEvents->postEvent(std::move(ev));
}
@ -1299,13 +1299,18 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
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;
switch(auth_diagnostic)
{
case RS_SSL_HANDSHAKE_DIAGNOSTIC_ISSUER_UNKNOWN:
ev->mErrorCode = RsAuthSslError::NOT_A_FRIEND;
break;
case RS_SSL_HANDSHAKE_DIAGNOSTIC_WRONG_SIGNATURE:
ev->mErrorCode = RsAuthSslError::PGP_SIGNATURE_VALIDATION_FAILED;
break;
default:
ev->mErrorCode = RsAuthSslConnectionAutenticationEvent::AuthenticationCode::MISSING_AUTHENTICATION_INFO;break;
}
ev->mErrorCode = RsAuthSslError::MISSING_AUTHENTICATION_INFO;
break;
}
ev->mErrorMsg = errMsg;
rsEvents->postEvent(std::move(ev));
@ -1331,7 +1336,7 @@ 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;
ev->mErrorCode = RsAuthSslError::NOT_A_FRIEND;
rsEvents->postEvent(std::move(ev));
}
@ -1595,32 +1600,6 @@ bool AuthSSLimpl::decrypt(void *&out, int &outlen, const void *in, int inlen)
return true;
}
/********************************************************************************/
/********************************************************************************/
/********************* Cert Search / Add / Remove **************************/
/********************************************************************************/
/********************************************************************************/
// 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)
{

View File

@ -137,13 +137,6 @@ 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;
/**
* This function parse X509 certificate from the file and return some
* verified informations, like ID and signer
@ -230,14 +223,6 @@ public:
/* SSL specific functions used in pqissl/pqissllistener */
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;
private:
bool LocalStoreCert(X509* x509);

View File

@ -475,22 +475,18 @@ void p3LinkMgrIMPL::tickMonitors()
/* notify GUI */
if (rsEvents && (peer.actions & RS_PEER_CONNECTED))
{
auto e = std::make_shared<RsConnectionEvent>() ;
e->mConnectionInfoCode = RsConnectionEvent::ConnectionEventCode::PEER_CONNECTED;
auto e = std::make_shared<RsConnectionEvent>();
e->mConnectionInfoCode = RsConnectionEventCode::PEER_CONNECTED;
e->mSslId = peer.id;
rsEvents->postEvent(e);
}
if (rsEvents && (peer.actions & RS_PEER_DISCONNECTED))
{
auto e = std::make_shared<RsConnectionEvent>() ;
e->mConnectionInfoCode = RsConnectionEvent::ConnectionEventCode::PEER_DISCONNECTED;
auto e = std::make_shared<RsConnectionEvent>();
e->mConnectionInfoCode = RsConnectionEventCode::PEER_DISCONNECTED;
e->mSslId = peer.id;
rsEvents->postEvent(e);
}
rsEvents->postEvent(e);
}
}
}

View File

@ -1804,21 +1804,24 @@ bool p3PeerMgrIMPL::addCandidateForOwnExternalAddress(const RsPeerId &from, cons
// Notify for every friend that has reported a wrong external address, except if that address is in the IP whitelist.
if((rsBanList!=NULL && !rsBanList->isAddressAccepted(addr_filtered,RSBANLIST_CHECKING_FLAGS_WHITELIST)) && (!sockaddr_storage_sameip(own_addr,addr_filtered)))
{
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;
if((rsBanList && !rsBanList->isAddressAccepted(addr_filtered, RSBANLIST_CHECKING_FLAGS_WHITELIST))
&& !sockaddr_storage_sameip(own_addr, addr_filtered) )
{
RsInfo() << __PRETTY_FUNCTION__ << " Peer " << from
<< " reports a connection address (" << addr_filtered
<<") that is not your current external address ("
<< own_addr << "). This is weird." << std::endl;
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);
}
}
if(rsEvents)
{
auto ev = std::make_shared<RsConnectionEvent>();
ev->mSslId = from;
ev->mOwnLocator = RsUrl(own_addr);
ev->mReportedLocator = RsUrl(addr);
ev->mConnectionInfoCode = RsConnectionEventCode::PEER_REPORTS_WRONG_IP;
rsEvents->postEvent(ev);
}
}
// we could also sweep over all connected friends and see if some report a different address.

View File

@ -1107,16 +1107,14 @@ int pqissl::SSL_Connection_Complete()
return 0;
}
if(rsEvents)
{
if(rsEvents)
{
X509 *x509 = SSL_get_peer_certificate(ssl_connection);
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;
ev->mErrorCode = RsAuthSslError::PEER_REFUSED_CONNECTION;
rsEvents->postEvent(ev);
}
}
std::string out;
rs_sprintf(out, "pqissl::SSL_Connection_Complete()\nIssues with SSL Connect(%d)!\n", err);
@ -1275,18 +1273,15 @@ int pqissl::accept_locked( SSL *ssl, int fd,
<< std::endl;
print_stacktrace();
if(rsEvents)
{
if(rsEvents)
{
X509 *x509 = SSL_get_peer_certificate(ssl);
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;
ev->mErrorCode = RsAuthSslError::IP_IS_BLACKLISTED;
rsEvents->postEvent(ev);
}
}
reset_locked();
return failure;

View File

@ -480,14 +480,12 @@ int pqissllistenbase::continueSSL(IncomingSSLInfo& incoming_connexion_info, bool
if(vres == X509_V_OK && nullptr != rsEvents)
{
auto ev = std::unique_ptr<RsAuthSslConnectionAutenticationEvent>(new RsAuthSslConnectionAutenticationEvent);
auto ev = std::make_shared<RsAuthSslConnectionAutenticationEvent>();
ev->mLocator = RsUrl(incoming_connexion_info.addr);
ev->mErrorCode = RsAuthSslConnectionAutenticationEvent::AuthenticationCode::MISSING_AUTHENTICATION_INFO;
rsEvents->postEvent(std::move(ev));
ev->mErrorCode = RsAuthSslError::MISSING_AUTHENTICATION_INFO;
rsEvents->postEvent(ev);
}
closeConnection(fd, incoming_connexion_info.ssl) ;
closeConnection(fd, incoming_connexion_info.ssl);
// failure -1, pending 0, sucess 1.
return -1;

View File

@ -61,7 +61,7 @@ enum class RsEventType : uint32_t
/// @see pqissl
PEER_CONNECTION = 4,
/// @see RsGxsChanges // this one should probably be removed because it's not used anywhere
/// @see RsGxsChanges
GXS_CHANGES = 5,
/// Emitted when a peer state changes, @see RsPeers

View File

@ -102,23 +102,36 @@ struct RsGxsChannelPost : RsSerializable
~RsGxsChannelPost() override;
};
enum class RsChannelEventCode: uint8_t
{
UNKNOWN = 0x00,
NEW_CHANNEL = 0x01, /// emitted when new channel is received
/// emitted when existing channel is updated
UPDATED_CHANNEL = 0x02,
/// new message reeived in a particular channel (group and msg id)
NEW_MESSAGE = 0x03,
/// existing message has been updated in a particular channel
UPDATED_MESSAGE = 0x04,
/// publish key for this channel has been received
RECEIVED_PUBLISH_KEY = 0x05,
/// subscription for channel mChannelGroupId changed.
SUBSCRIBE_STATUS_CHANGED = 0x06,
};
struct RsGxsChannelEvent: RsEvent
{
RsGxsChannelEvent()
: RsEvent(RsEventType::GXS_CHANNELS), mChannelEventCode(ChannelEventCode::UNKNOWN) {}
RsGxsChannelEvent():
RsEvent(RsEventType::GXS_CHANNELS),
mChannelEventCode(RsChannelEventCode::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;
RsChannelEventCode mChannelEventCode;
RsGxsGroupId mChannelGroupId;
RsGxsMessageId mChannelMsgId;
///* @see RsEvent @see RsSerializable

View File

@ -162,32 +162,54 @@ struct RsGxsCircleDetails : RsSerializable
}
};
enum class RsGxsCircleEventCode: uint8_t
{
UNKNOWN = 0x00,
/** mCircleId contains the circle id and mGxsId is the id requesting
* membership */
CIRCLE_MEMBERSHIP_REQUEST = 0x01,
/** mCircleId is the circle that invites me, and mGxsId is my own Id that is
* invited */
CIRCLE_MEMBERSHIP_INVITE = 0x02,
/** mCircleId contains the circle id and mGxsId is the id dropping
* membership */
CIRCLE_MEMBERSHIP_LEAVE = 0x03,
/// mCircleId contains the circle id and mGxsId is the id of the new member
CIRCLE_MEMBERSHIP_JOIN = 0x04,
/** mCircleId contains the circle id and mGxsId is the id that was revoqued
* by admin */
CIRCLE_MEMBERSHIP_REVOQUED= 0x05,
};
struct RsGxsCircleEvent: RsEvent
{
RsGxsCircleEvent()
: RsEvent(RsEventType::GXS_CIRCLES), mCircleEventType(CircleEventCode::UNKNOWN) {}
: RsEvent(RsEventType::GXS_CIRCLES),
mCircleEventType(RsGxsCircleEventCode::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;
RsGxsCircleEventCode mCircleEventType;
RsGxsCircleId mCircleId;
RsGxsId mGxsId;
///* @see RsEvent @see RsSerializable
void serial_process( RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) override
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);
}
~RsGxsCircleEvent() override;
};
class RsGxsCircles: public RsGxsIfaceHelper

View File

@ -104,33 +104,45 @@ struct RsGxsForumMsg : RsSerializable
~RsGxsForumMsg() override;
};
enum class RsForumEventCode: uint8_t
{
UNKNOWN = 0x00,
NEW_FORUM = 0x01, /// emitted when new forum is received
UPDATED_FORUM = 0x02, /// emitted when existing forum is updated
/// new message reeived in a particular forum
NEW_MESSAGE = 0x03,
/// existing message has been updated in a particular forum
UPDATED_MESSAGE = 0x04,
/// forum was subscribed or unsubscribed
SUBSCRIBE_STATUS_CHANGED = 0x05,
};
struct RsGxsForumEvent: RsEvent
{
RsGxsForumEvent()
: RsEvent(RsEventType::GXS_FORUMS), mForumEventCode(ForumEventCode::UNKNOWN) {}
RsGxsForumEvent()
: RsEvent(RsEventType::GXS_FORUMS),
mForumEventCode(RsForumEventCode::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;
RsForumEventCode mForumEventCode;
RsGxsGroupId mForumGroupId;
RsGxsMessageId mForumMsgId;
///* @see RsEvent @see RsSerializable
void serial_process( RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) override
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);
}
}
~RsGxsForumEvent() override;
};
class RsGxsForums: public RsGxsIfaceHelper

View File

@ -296,19 +296,25 @@ struct MsgTagType : RsSerializable
} //namespace Rs
} //namespace Msgs
enum class RsMailStatusEventCode: uint8_t
{
NEW_MESSAGE = 0x00,
MESSAGE_REMOVED = 0x01,
MESSAGE_SENT = 0x02,
/// means the peer received the message
MESSAGE_RECEIVED_ACK = 0x03,
/// An error occurred attempting to sign the message
SIGNATURE_FAILED = 0x04,
};
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;
RsMailStatusEventCode mMailStatusEventCode;
std::set<RsMailMessageId> mChangedMsgIds;
/// @see RsEvent

View File

@ -210,33 +210,35 @@ std::string RsPeerLastConnectString(uint32_t lastConnect);
// Connexion and security events //
//===================================================================================================//
enum class RsAuthSslError: uint8_t
{
NO_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,
};
/**
* 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,
};
RsAuthSslConnectionAutenticationEvent() :
RsEvent(RsEventType::AUTHSSL_CONNECTION_AUTENTICATION) {}
RsPeerId mSslId;
std::string mSslCn;
RsPgpId mPgpId;
RsUrl mLocator;
RsUrl mLocator;
std::string mErrorMsg;
AuthenticationCode mErrorCode;
RsAuthSslError mErrorCode;
///* @see RsEvent @see RsSerializable
void serial_process( RsGenericSerializer::SerializeJob j,
@ -250,36 +252,49 @@ struct RsAuthSslConnectionAutenticationEvent : RsEvent
RS_SERIAL_PROCESS(mErrorMsg);
RS_SERIAL_PROCESS(mErrorCode);
}
~RsAuthSslConnectionAutenticationEvent() override;
};
enum class RsConnectionEventCode: uint8_t
{
UNKNOWN = 0x00,
PEER_CONNECTED = 0x01,
PEER_DISCONNECTED = 0x02,
PEER_TIME_SHIFT = 0x03, // mTimeShift = time shift in seconds
PEER_REPORTS_WRONG_IP = 0x04, // mPeerLocator = address reported, mOwnLocator = own address
};
struct RsConnectionEvent : RsEvent
{
RsConnectionEvent()
: RsEvent(RsEventType::PEER_CONNECTION),
mConnectionInfoCode(ConnectionEventCode::UNKNOWN) {}
mConnectionInfoCode(RsConnectionEventCode::UNKNOWN), mTimeShift(0) {}
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;
RsConnectionEventCode mConnectionInfoCode;
RsPeerId mSslId;
std::string mStrInfo1;
std::string mStrInfo2;
RsUrl mOwnLocator;
RsUrl mReportedLocator;
/** If there is a time shift with the peer aka
* mConnectionInfoCode == PEER_TIME_SHIFT contains the time shift value in
* seconds */
rstime_t mTimeShift;
///* @see RsEvent @see RsSerializable
void serial_process( RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) override
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);
RS_SERIAL_PROCESS(mOwnLocator);
RS_SERIAL_PROCESS(mReportedLocator);
RS_SERIAL_PROCESS(mTimeShift);
}
~RsConnectionEvent() override;
};
//===================================================================================================//

View File

@ -68,18 +68,21 @@ class RsPostedGroup
std::ostream &operator<<(std::ostream &out, const RsPostedGroup &group);
std::ostream &operator<<(std::ostream &out, const RsPostedPost &post);
enum class RsPostedEventCode: uint8_t
{
UNKNOWN = 0x00,
NEW_POSTED_GROUP = 0x01,
NEW_MESSAGE = 0x02
};
struct RsGxsPostedEvent: RsEvent
{
RsGxsPostedEvent()
: RsEvent(RsEventType::GXS_POSTED), mPostedEventCode(PostedEventCode::UNKNOWN) {}
RsGxsPostedEvent():
RsEvent(RsEventType::GXS_POSTED),
mPostedEventCode(RsPostedEventCode::UNKNOWN) {}
enum class PostedEventCode: uint8_t {
UNKNOWN = 0x00,
NEW_POSTED_GROUP = 0x01,
NEW_MESSAGE = 0x02
};
PostedEventCode mPostedEventCode;
RsPostedEventCode mPostedEventCode;
RsGxsGroupId mPostedGroupId;
RsGxsMessageId mPostedMsgId;

View File

@ -1859,3 +1859,5 @@ RsPeerStateChangedEvent::RsPeerStateChangedEvent(RsPeerId sslId) :
RsEvent(RsEventType::PEER_STATE_CHANGED), mSslId(sslId) {}
RsPeers::~RsPeers() = default;
RsAuthSslConnectionAutenticationEvent::~RsAuthSslConnectionAutenticationEvent() = default;
RsConnectionEvent::~RsConnectionEvent() = default;

View File

@ -257,12 +257,10 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
{
auto ev = std::make_shared<RsGxsChannelEvent>();
ev->mChannelMsgId = *mit1;
ev->mChannelGroupId = mit->first;
ev->mChannelEventCode = RsGxsChannelEvent::ChannelEventCode::NEW_MESSAGE;
rsEvents->sendEvent(ev);
ev->mChannelEventCode = RsChannelEventCode::NEW_MESSAGE;
rsEvents->postEvent(ev);
}
}
}
@ -313,11 +311,9 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
for (git = grpList.begin(); git != grpList.end(); ++git)
{
auto ev = std::make_shared<RsGxsChannelEvent>();
ev->mChannelGroupId = *git;
ev->mChannelEventCode = RsGxsChannelEvent::ChannelEventCode::SUBSCRIBE_STATUS_CHANGED;
rsEvents->sendEvent(ev);
ev->mChannelEventCode = RsChannelEventCode::SUBSCRIBE_STATUS_CHANGED;
rsEvents->postEvent(ev);
}
}
@ -338,11 +334,9 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
IndicateConfigChanged();
auto ev = std::make_shared<RsGxsChannelEvent>();
ev->mChannelGroupId = *git;
ev->mChannelEventCode = RsGxsChannelEvent::ChannelEventCode::NEW_CHANNEL;
rsEvents->sendEvent(ev);
ev->mChannelEventCode = RsChannelEventCode::NEW_CHANNEL;
rsEvents->postEvent(ev);
}
else
std::cerr << "(II) Not notifying already known channel " << *git << std::endl;
@ -358,11 +352,9 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
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);
ev->mChannelEventCode = RsChannelEventCode::RECEIVED_PUBLISH_KEY;
rsEvents->postEvent(ev);
}
break;
}

View File

@ -504,23 +504,21 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
if(rsEvents && (c->getType() == RsGxsNotify::TYPE_RECEIVED_NEW) )
for (auto msgIdIt(mit->second.begin()), end(mit->second.end()); msgIdIt != end; ++msgIdIt)
{
// @Gio: should this be async?
RsGxsCircleMsg msg;
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;
ev->mCircleEventType = RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_LEAVE;
else if(details.mAllowedGxsIds.find(msg.mMeta.mAuthorId) != details.mAllowedGxsIds.end())
ev->mCircleEventType = RsGxsCircleEvent::CircleEventCode::CIRCLE_MEMBERSHIP_JOIN;
ev->mCircleEventType = RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_JOIN;
else
ev->mCircleEventType = RsGxsCircleEvent::CircleEventCode::CIRCLE_MEMBERSHIP_REQUEST;
ev->mCircleEventType = RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REQUEST;
rsEvents->sendEvent(ev);
rsEvents->postEvent(ev);
}
}
@ -2416,3 +2414,4 @@ RsGxsCircles::~RsGxsCircles() = default;
RsGxsCircleMsg::~RsGxsCircleMsg() = default;
RsGxsCircleDetails::~RsGxsCircleDetails() = default;
RsGxsCircleGroup::~RsGxsCircleGroup() = default;
RsGxsCircleEvent::~RsGxsCircleEvent() = default;

View File

@ -199,12 +199,10 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
{
auto ev = std::make_shared<RsGxsForumEvent>();
ev->mForumMsgId = *mit1;
ev->mForumGroupId = mit->first;
ev->mForumEventCode = RsGxsForumEvent::ForumEventCode::NEW_MESSAGE;
rsEvents->sendEvent(ev);
ev->mForumEventCode = RsForumEventCode::NEW_MESSAGE;
rsEvents->postEvent(ev);
}
}
@ -256,11 +254,9 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
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);
ev->mForumEventCode = RsForumEventCode::SUBSCRIBE_STATUS_CHANGED;
rsEvents->postEvent(ev);
}
}
@ -278,18 +274,19 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
{
if(mKnownForums.find(*git) == mKnownForums.end())
{
mKnownForums.insert(std::make_pair(*git,time(NULL))) ;
mKnownForums.insert(
std::make_pair(*git, time(nullptr)));
IndicateConfigChanged();
auto ev = std::make_shared<RsGxsForumEvent>();
ev->mForumGroupId = *git;
ev->mForumEventCode = RsGxsForumEvent::ForumEventCode::NEW_FORUM;
rsEvents->sendEvent(ev);
ev->mForumEventCode = RsForumEventCode::NEW_FORUM;
rsEvents->postEvent(ev);
}
else
std::cerr << "(II) Not notifying already known channel " << *git << std::endl;
RsInfo() << __PRETTY_FUNCTION__
<< " Not notifying already known forum "
<< *git << std::endl;
}
break;
}
@ -1148,3 +1145,4 @@ bool RsGxsForumGroup::canEditPosts(const RsGxsId& id) const
RsGxsForumGroup::~RsGxsForumGroup() = default;
RsGxsForumMsg::~RsGxsForumMsg() = default;
RsGxsForums::~RsGxsForums() = default;
RsGxsForumEvent::~RsGxsForumEvent() = default;

View File

@ -177,12 +177,11 @@ void p3MsgService::processIncomingMsg(RsMsgItem *mi)
if (rsEvents)
{
auto ev = std::make_shared<RsMailStatusEvent>();
ev->mMailStatusEventCode = RsMailStatusEvent::NEW_MESSAGE;
auto ev = std::make_shared<RsMailStatusEvent>();
ev->mMailStatusEventCode = RsMailStatusEventCode::NEW_MESSAGE;
ev->mChangedMsgIds.insert(std::to_string(mi->msgId));
rsEvents->sendEvent(ev);
}
rsEvents->postEvent(ev);
}
imsg[mi->msgId] = mi;
RsMsgSrcId* msi = new RsMsgSrcId();
@ -337,8 +336,8 @@ int p3MsgService::checkOutgoingMessages()
bool changed = false;
std::list<RsMsgItem*> output_queue;
auto pEvent = std::make_shared<RsMailStatusEvent>();
pEvent->mMailStatusEventCode = RsMailStatusEvent::MESSAGE_SENT;
auto pEvent = std::make_shared<RsMailStatusEvent>();
pEvent->mMailStatusEventCode = RsMailStatusEventCode::MESSAGE_SENT;
{
RS_STACK_MUTEX(mMsgMtx); /********** STACK LOCKED MTX ******/
@ -898,9 +897,8 @@ bool p3MsgService::removeMsgId(const std::string &mid)
bool changed = false;
auto pEvent = std::make_shared<RsMailStatusEvent>();
pEvent->mMailStatusEventCode = RsMailStatusEvent::MESSAGE_REMOVED;
auto pEvent = std::make_shared<RsMailStatusEvent>();
pEvent->mMailStatusEventCode = RsMailStatusEventCode::MESSAGE_REMOVED;
{
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
@ -1268,8 +1266,8 @@ uint32_t p3MsgService::sendMail(
uint32_t ret = 0;
auto pEvent = std::make_shared<RsMailStatusEvent>();
pEvent->mMailStatusEventCode = RsMailStatusEvent::MESSAGE_SENT;
auto pEvent = std::make_shared<RsMailStatusEvent>();
pEvent->mMailStatusEventCode = RsMailStatusEventCode::MESSAGE_SENT;
auto pSend = [&](const std::set<RsGxsId>& sDest)
{
@ -2083,12 +2081,13 @@ void p3MsgService::notifyDataStatus( const GRouterMsgPropagationId& id,
NOTIFY_TYPE_ADD );
IndicateConfigChanged();
auto pEvent = std::make_shared<RsMailStatusEvent>();
pEvent->mMailStatusEventCode = RsMailStatusEvent::NEW_MESSAGE;
pEvent->mChangedMsgIds.insert(std::to_string(msg_id));
if(rsEvents) rsEvents->postEvent(pEvent);
if(rsEvents)
{
auto pEvent = std::make_shared<RsMailStatusEvent>();
pEvent->mMailStatusEventCode = RsMailStatusEventCode::NEW_MESSAGE;
pEvent->mChangedMsgIds.insert(std::to_string(msg_id));
rsEvents->postEvent(pEvent);
}
return;
}
@ -2185,11 +2184,11 @@ bool p3MsgService::notifyGxsTransSendStatus( RsGxsTransId mailId,
Dbg2() << __PRETTY_FUNCTION__ << " " << mailId << ", "
<< static_cast<uint32_t>(status) << std::endl;
auto pEvent = std::make_shared<RsMailStatusEvent>();
auto pEvent = std::make_shared<RsMailStatusEvent>();
if( status == GxsTransSendStatus::RECEIPT_RECEIVED )
{
pEvent->mMailStatusEventCode = RsMailStatusEvent::NEW_MESSAGE;
pEvent->mMailStatusEventCode = RsMailStatusEventCode::NEW_MESSAGE;
uint32_t msg_id;
{
@ -2244,20 +2243,20 @@ bool p3MsgService::notifyGxsTransSendStatus( RsGxsTransId mailId,
else if( status >= GxsTransSendStatus::FAILED_RECEIPT_SIGNATURE )
{
uint32_t msg_id;
pEvent->mMailStatusEventCode = RsMailStatusEvent::FAILED_SIGNATURE;
pEvent->mMailStatusEventCode = RsMailStatusEventCode::SIGNATURE_FAILED;
{
RS_STACK_MUTEX(gxsOngoingMutex);
std::cerr << __PRETTY_FUNCTION__ << " mail delivery "
<< "mailId: " << mailId
<< " failed with " << static_cast<uint32_t>(status);
RsErr() << __PRETTY_FUNCTION__ << " mail delivery "
<< "mailId: " << mailId
<< " failed with " << static_cast<uint32_t>(status);
auto it = gxsOngoingMessages.find(mailId);
if(it == gxsOngoingMessages.end())
{
std::cerr << " cannot find pending message to notify"
<< std::endl;
RsErr() << __PRETTY_FUNCTION__
<< " cannot find pending message to notify"
<< std::endl;
return false;
}

View File

@ -115,13 +115,11 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
if (rsEvents && msgChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW)
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
{
auto ev = std::make_shared<RsGxsPostedEvent>();
ev->mPostedMsgId = *mit1;
ev->mPostedGroupId = mit->first;
ev->mPostedEventCode = RsGxsPostedEvent::PostedEventCode::NEW_MESSAGE;
rsEvents->sendEvent(ev);
auto ev = std::make_shared<RsGxsPostedEvent>();
ev->mPostedMsgId = *mit1;
ev->mPostedGroupId = mit->first;
ev->mPostedEventCode = RsPostedEventCode::NEW_MESSAGE;
rsEvents->postEvent(ev);
}
}
}
@ -146,11 +144,9 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
if (rsEvents && groupChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW)
{
auto ev = std::make_shared<RsGxsPostedEvent>();
ev->mPostedGroupId = *git;
ev->mPostedEventCode = RsGxsPostedEvent::PostedEventCode::NEW_POSTED_GROUP;
rsEvents->sendEvent(ev);
ev->mPostedEventCode = RsPostedEventCode::NEW_POSTED_GROUP;
rsEvents->postEvent(ev);
}
}
}

View File

@ -20,6 +20,8 @@
* *
*******************************************************************************/
#include <iomanip>
#include <sys/time.h>
#include <cmath>
#include "util/rsdir.h"
#include "retroshare/rsiface.h"
@ -28,12 +30,10 @@
#include "pqi/pqistore.h"
#include "pqi/p3linkmgr.h"
#include "rsserver/p3face.h"
#include "util/cxx17retrocompat.h"
#include "services/p3rtt.h"
#include "rsitems/rsrttitems.h"
#include <sys/time.h>
#include <math.h>
/****
* #define DEBUG_RTT 1
@ -353,32 +353,29 @@ int p3rtt::storePongResult(const RsPeerId& id, uint32_t counter, double recv_ts,
while(peerInfo->mPongResults.size() > MAX_PONG_RESULTS)
{
peerInfo->mPongResults.pop_front();
}
//Wait at least 20 pongs before compute mean time offset
if(peerInfo->mPongResults.size() > 20)
{
double mean = 0;
for(std::list<RsRttPongResult>::const_iterator prIt = peerInfo->mPongResults.begin(), end = peerInfo->mPongResults.end(); prIt != end; ++ prIt)
{
mean += prIt->mOffset;
}
for(auto prIt : std::as_const(peerInfo->mPongResults))
mean += prIt.mOffset;
peerInfo->mCurrentMeanOffset = mean / peerInfo->mPongResults.size();
if(fabs(peerInfo->mCurrentMeanOffset) > 120)
{
if(rsEvents)
{
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;
ev->mTimeShift = static_cast<rstime_t>(peerInfo->mCurrentMeanOffset);
ev->mConnectionInfoCode = RsConnectionEventCode::PEER_TIME_SHIFT;
rsEvents->postEvent(ev);
}
std::cerr << "(WW) Peer:" << peerInfo->mId << " get time offset more than two minutes with you!!!" << std::endl;
}
RsWarn() << __PRETTY_FUNCTION__ << " Peer: " << peerInfo->mId
<< " have a time offset of more than two minutes with you"
<< std::endl;
}
}
return 1;

View File

@ -196,83 +196,78 @@ void NewsFeed::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
void NewsFeed::handleMailEvent(std::shared_ptr<const RsEvent> event)
{
const RsMailStatusEvent *pe = dynamic_cast<const RsMailStatusEvent*>(event.get());
if(!pe)
return;
const RsMailStatusEvent *pe =
dynamic_cast<const RsMailStatusEvent*>(event.get());
if(!pe) return;
switch(pe->mMailStatusEventCode)
{
case RsMailStatusEvent::NEW_MESSAGE:
for(auto msgid: pe->mChangedMsgIds)
addFeedItem( new MsgItem(this, NEWSFEED_MESSAGELIST, msgid, false));
break;
default:
break;
}
switch(pe->mMailStatusEventCode)
{
case RsMailStatusEventCode::NEW_MESSAGE:
for(auto msgid: pe->mChangedMsgIds)
addFeedItem( new MsgItem(this, NEWSFEED_MESSAGELIST, msgid, false));
break;
default: break;
}
}
void NewsFeed::handlePostedEvent(std::shared_ptr<const RsEvent> event)
{
const RsGxsPostedEvent *pe = dynamic_cast<const RsGxsPostedEvent*>(event.get());
if(!pe)
return;
const RsGxsPostedEvent *pe =
dynamic_cast<const RsGxsPostedEvent*>(event.get());
if(!pe) return;
switch(pe->mPostedEventCode)
{
case RsGxsPostedEvent::PostedEventCode::NEW_POSTED_GROUP: addFeedItem( new PostedGroupItem(this, NEWSFEED_POSTEDNEWLIST, pe->mPostedGroupId, false, true));
break;
case RsGxsPostedEvent::PostedEventCode::NEW_MESSAGE: addFeedItem( new PostedItem(this, NEWSFEED_POSTEDMSGLIST, pe->mPostedGroupId, pe->mPostedMsgId, false, true));
break;
default:
break;
}
switch(pe->mPostedEventCode)
{
case RsPostedEventCode::NEW_POSTED_GROUP:
addFeedItem( new PostedGroupItem(this, NEWSFEED_POSTEDNEWLIST, pe->mPostedGroupId, false, true));
break;
case RsPostedEventCode::NEW_MESSAGE:
addFeedItem( new PostedItem(this, NEWSFEED_POSTEDMSGLIST, pe->mPostedGroupId, pe->mPostedMsgId, false, true));
break;
default: break;
}
}
void NewsFeed::handleForumEvent(std::shared_ptr<const RsEvent> event)
{
const RsGxsForumEvent *pe = dynamic_cast<const RsGxsForumEvent*>(event.get());
if(!pe)
return;
const RsGxsForumEvent *pe = dynamic_cast<const RsGxsForumEvent*>(event.get());
if(!pe) return;
switch(pe->mForumEventCode)
{
case RsGxsForumEvent::ForumEventCode::UPDATED_FORUM:
case RsGxsForumEvent::ForumEventCode::NEW_FORUM: addFeedItem(new GxsForumGroupItem(this, NEWSFEED_FORUMNEWLIST, pe->mForumGroupId, false, true));
break;
case RsGxsForumEvent::ForumEventCode::UPDATED_MESSAGE:
case RsGxsForumEvent::ForumEventCode::NEW_MESSAGE: addFeedItem(new GxsForumMsgItem(this, NEWSFEED_FORUMNEWLIST, pe->mForumGroupId, pe->mForumMsgId, false, true));
break;
default:
break;
}
switch(pe->mForumEventCode)
{
case RsForumEventCode::UPDATED_FORUM:
case RsForumEventCode::NEW_FORUM:
addFeedItem(new GxsForumGroupItem(this, NEWSFEED_FORUMNEWLIST, pe->mForumGroupId, false, true));
break;
case RsForumEventCode::UPDATED_MESSAGE:
case RsForumEventCode::NEW_MESSAGE:
addFeedItem(new GxsForumMsgItem(this, NEWSFEED_FORUMNEWLIST, pe->mForumGroupId, pe->mForumMsgId, false, true));
break;
default: break;
}
}
void NewsFeed::handleChannelEvent(std::shared_ptr<const RsEvent> event)
{
const RsGxsChannelEvent *pe = dynamic_cast<const RsGxsChannelEvent*>(event.get());
if(!pe)
return;
const RsGxsChannelEvent* pe =
dynamic_cast<const RsGxsChannelEvent*>(event.get());
if(!pe) return;
switch(pe->mChannelEventCode)
{
case RsGxsChannelEvent::ChannelEventCode::UPDATED_CHANNEL:
case RsGxsChannelEvent::ChannelEventCode::NEW_CHANNEL: addFeedItem(new GxsChannelGroupItem(this, NEWSFEED_CHANNELNEWLIST, pe->mChannelGroupId, false, true));
break;
case RsGxsChannelEvent::ChannelEventCode::UPDATED_MESSAGE:
case RsGxsChannelEvent::ChannelEventCode::NEW_MESSAGE: addFeedItem(new GxsChannelPostItem(this, NEWSFEED_CHANNELNEWLIST, pe->mChannelGroupId, pe->mChannelMsgId, false, true));
break;
case RsGxsChannelEvent::ChannelEventCode::RECEIVED_PUBLISH_KEY: addFeedItem(new GxsChannelGroupItem(this, NEWSFEED_CHANNELPUBKEYLIST, pe->mChannelGroupId, false, true));
break;
default:
break;
}
switch(pe->mChannelEventCode)
{
case RsChannelEventCode::UPDATED_CHANNEL: // [[fallthrough]];
case RsChannelEventCode::NEW_CHANNEL:
addFeedItem(new GxsChannelGroupItem(this, NEWSFEED_CHANNELNEWLIST, pe->mChannelGroupId, false, true));
break;
case RsChannelEventCode::UPDATED_MESSAGE: // [[fallthrough]];
case RsChannelEventCode::NEW_MESSAGE:
addFeedItem(new GxsChannelPostItem(this, NEWSFEED_CHANNELNEWLIST, pe->mChannelGroupId, pe->mChannelMsgId, false, true));
break;
case RsChannelEventCode::RECEIVED_PUBLISH_KEY:
addFeedItem(new GxsChannelGroupItem(this, NEWSFEED_CHANNELPUBKEYLIST, pe->mChannelGroupId, false, true));
break;
default: break;
}
}
void NewsFeed::handleCircleEvent(std::shared_ptr<const RsEvent> event)
@ -291,62 +286,62 @@ void NewsFeed::handleCircleEvent(std::shared_ptr<const RsEvent> event)
// Check if the circle is one of which we belong to. If so, then notify in the GUI about other members leaving/subscribing
if(details.mAmIAllowed || details.mAmIAdmin)
if(details.mAmIAllowed || details.mAmIAdmin)
{
switch(pe->mCircleEventType)
{
case RsGxsCircleEvent::CircleEventCode::CIRCLE_MEMBERSHIP_REQUEST: // only show membership requests if we're an admin of that circle
if(details.mAmIAdmin)
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_REQ),true);
break;
case RsGxsCircleEvent::CircleEventCode::CIRCLE_MEMBERSHIP_JOIN:
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_JOIN),true);
break;
case RsGxsCircleEvent::CircleEventCode::CIRCLE_MEMBERSHIP_LEAVE:
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_LEAVE),true);
break;
case RsGxsCircleEvent::CircleEventCode::CIRCLE_MEMBERSHIP_INVITE:
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_INVIT_REC),true);
break;
case RsGxsCircleEvent::CircleEventCode::CIRCLE_MEMBERSHIP_REVOQUED:
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_REVOQUED),true);
break;
default:
break;
}
switch(pe->mCircleEventType)
{
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REQUEST:
// only show membership requests if we're an admin of that circle
if(details.mAmIAdmin)
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_REQ),true);
break;
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_JOIN:
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_JOIN),true);
break;
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_LEAVE:
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_LEAVE),true);
break;
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_INVITE:
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_INVIT_REC),true);
break;
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REVOQUED:
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_REVOQUED),true);
break;
default: break;
}
}
}
void NewsFeed::handleConnectionEvent(std::shared_ptr<const RsEvent> event)
{
const RsConnectionEvent *pe = dynamic_cast<const RsConnectionEvent*>(event.get());
if(!pe)
return;
const RsConnectionEvent *pe = dynamic_cast<const RsConnectionEvent*>(event.get());
if(!pe) return;
auto& e(*pe);
auto& e(*pe);
#ifdef NEWS_DEBUG
std::cerr << "NotifyQt: handling connection event from peer " << e.mSslId << std::endl;
#endif
switch(e.mConnectionInfoCode)
{
case RsConnectionEvent::ConnectionEventCode::PEER_CONNECTED: addFeedItemIfUnique(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_CONNECT, false), true);
switch(e.mConnectionInfoCode)
{
case RsConnectionEventCode::PEER_CONNECTED:
addFeedItemIfUnique(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_CONNECT, false), true);
break;
case RsConnectionEvent::ConnectionEventCode::PEER_DISCONNECTED: // not handled yet
break;
case RsConnectionEvent::ConnectionEventCode::PEER_TIME_SHIFT:addFeedItemIfUnique(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_OFFSET, false),false);
break;
case RsConnectionEvent::ConnectionEventCode::PEER_REPORTS_WRONG_IP: addFeedItemIfUnique(new SecurityIpItem(this, e.mSslId, e.mStrInfo2, e.mStrInfo1, RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED, false), false);
break;
default: break;
}
case RsConnectionEventCode::PEER_DISCONNECTED: // not handled yet
break;
case RsConnectionEventCode::PEER_TIME_SHIFT:
addFeedItemIfUnique(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_OFFSET, false),false);
break;
case RsConnectionEventCode::PEER_REPORTS_WRONG_IP:
addFeedItemIfUnique(new SecurityIpItem(
this, e.mSslId, e.mOwnLocator.toString(),
e.mReportedLocator.toString(),
RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED,
false ), false);
break;
default: break;
}
}
void NewsFeed::handleSecurityEvent(std::shared_ptr<const RsEvent> event)
@ -362,27 +357,31 @@ void NewsFeed::handleSecurityEvent(std::shared_ptr<const RsEvent> event)
#endif
uint flags = Settings->getNewsFeedFlags();
if(e.mErrorCode == RsAuthSslConnectionAutenticationEvent::AuthenticationCode::PEER_REFUSED_CONNECTION)
{
if(e.mErrorCode == RsAuthSslError::PEER_REFUSED_CONNECTION)
{
addFeedItemIfUnique(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_HELLO, false), true );
return;
}
return;
}
uint32_t FeedItemType=0;
switch(e.mErrorCode)
{
case RsAuthSslConnectionAutenticationEvent::AuthenticationCode::NO_CERTIFICATE_SUPPLIED:
case RsAuthSslConnectionAutenticationEvent::AuthenticationCode::MISMATCHED_PGP_ID: // fallthrough
case RsAuthSslConnectionAutenticationEvent::AuthenticationCode::MISSING_AUTHENTICATION_INFO: FeedItemType = RS_FEED_ITEM_SEC_BAD_CERTIFICATE; break;
case RsAuthSslConnectionAutenticationEvent::AuthenticationCode::PGP_SIGNATURE_VALIDATION_FAILED: FeedItemType = RS_FEED_ITEM_SEC_WRONG_SIGNATURE; break;
case RsAuthSslConnectionAutenticationEvent::AuthenticationCode::NOT_A_FRIEND: FeedItemType = RS_FEED_ITEM_SEC_CONNECT_ATTEMPT; break;
case RsAuthSslConnectionAutenticationEvent::AuthenticationCode::IP_IS_BLACKLISTED: FeedItemType = RS_FEED_ITEM_SEC_IP_BLACKLISTED; break;
case RsAuthSslConnectionAutenticationEvent::AuthenticationCode::MISSING_CERTIFICATE: FeedItemType = RS_FEED_ITEM_SEC_MISSING_CERTIFICATE; break;
default:
return; // display nothing
}
case RsAuthSslError::NO_CERTIFICATE_SUPPLIED: // fallthrough
case RsAuthSslError::MISMATCHED_PGP_ID: // fallthrough
case RsAuthSslError::MISSING_AUTHENTICATION_INFO:
FeedItemType = RS_FEED_ITEM_SEC_BAD_CERTIFICATE; break;
case RsAuthSslError::PGP_SIGNATURE_VALIDATION_FAILED:
FeedItemType = RS_FEED_ITEM_SEC_WRONG_SIGNATURE; break;
case RsAuthSslError::NOT_A_FRIEND:
FeedItemType = RS_FEED_ITEM_SEC_CONNECT_ATTEMPT; break;
case RsAuthSslError::IP_IS_BLACKLISTED:
FeedItemType = RS_FEED_ITEM_SEC_IP_BLACKLISTED; break;
case RsAuthSslError::MISSING_CERTIFICATE:
FeedItemType = RS_FEED_ITEM_SEC_MISSING_CERTIFICATE; break;
default:
return; // display nothing
}
RsPeerDetails det;
rsPeers->getPeerDetails(e.mSslId,det) || rsPeers->getGPGDetails(e.mPgpId,det);

View File

@ -66,7 +66,7 @@ void GxsChannelDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> ev
switch(e->mChannelEventCode)
{
case RsGxsChannelEvent::ChannelEventCode::SUBSCRIBE_STATUS_CHANGED: updateDisplay(true);
case RsChannelEventCode::SUBSCRIBE_STATUS_CHANGED: updateDisplay(true);
break;
default:
break;

View File

@ -146,10 +146,10 @@ void GxsChannelPostsWidget::handleEvent_main_thread(std::shared_ptr<const RsEven
switch(e->mChannelEventCode)
{
case RsGxsChannelEvent::ChannelEventCode::UPDATED_CHANNEL:
case RsGxsChannelEvent::ChannelEventCode::NEW_CHANNEL:
case RsGxsChannelEvent::ChannelEventCode::UPDATED_MESSAGE:
case RsGxsChannelEvent::ChannelEventCode::NEW_MESSAGE:
case RsChannelEventCode::UPDATED_CHANNEL:
case RsChannelEventCode::NEW_CHANNEL:
case RsChannelEventCode::UPDATED_MESSAGE:
case RsChannelEventCode::NEW_MESSAGE:
if(e->mChannelGroupId == mChannelGroupId)
updateDisplay(true);
break;

View File

@ -441,26 +441,23 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
void GxsForumThreadWidget::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
{
if(event->mType == RsEventType::GXS_FORUMS)
{
const RsGxsForumEvent *e = dynamic_cast<const RsGxsForumEvent*>(event.get());
if(event->mType == RsEventType::GXS_FORUMS)
{
const RsGxsForumEvent *e = dynamic_cast<const RsGxsForumEvent*>(event.get());
if(!e) return;
if(!e)
return;
switch(e->mForumEventCode)
{
case RsGxsForumEvent::ForumEventCode::UPDATED_FORUM:
case RsGxsForumEvent::ForumEventCode::NEW_FORUM:
case RsGxsForumEvent::ForumEventCode::UPDATED_MESSAGE:
case RsGxsForumEvent::ForumEventCode::NEW_MESSAGE:
if(e->mForumGroupId == mForumGroup.mMeta.mGroupId)
switch(e->mForumEventCode)
{
case RsForumEventCode::UPDATED_FORUM: // [[fallthrough]];
case RsForumEventCode::NEW_FORUM: // [[fallthrough]];
case RsForumEventCode::UPDATED_MESSAGE: // [[fallthrough]];
case RsForumEventCode::NEW_MESSAGE:
if(e->mForumGroupId == mForumGroup.mMeta.mGroupId)
updateDisplay(true);
break;
default:
break;
}
}
break;
default: break;
}
}
}
void GxsForumThreadWidget::blank()

View File

@ -59,7 +59,7 @@ void GxsForumsDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> eve
switch(e->mForumEventCode)
{
case RsGxsForumEvent::ForumEventCode::SUBSCRIBE_STATUS_CHANGED: updateDisplay(true);
case RsForumEventCode::SUBSCRIBE_STATUS_CHANGED: updateDisplay(true);
break;
default:
break;