mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-09 23:02:29 -04:00
merged upstream/master
This commit is contained in:
commit
6848a586f3
94 changed files with 1618 additions and 758 deletions
|
@ -254,7 +254,9 @@ void ChunkMap::setChunkCheckingResult(uint32_t chunk_number,bool check_succeeded
|
|||
}
|
||||
}
|
||||
|
||||
bool ChunkMap::reAskPendingChunk(const RsPeerId& peer_id,uint32_t size_hint,uint64_t& offset,uint32_t& size)
|
||||
bool ChunkMap::reAskPendingChunk( const RsPeerId& peer_id,
|
||||
uint32_t /*size_hint*/,
|
||||
uint64_t& offset, uint32_t& size)
|
||||
{
|
||||
// make sure that we're at the end of the file. No need to be too greedy in the middle of it.
|
||||
|
||||
|
|
|
@ -1213,7 +1213,7 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b
|
|||
const RsGxsGroupId& grpId = mit->first;
|
||||
|
||||
// if vector empty then request all messages
|
||||
const std::vector<RsGxsMessageId>& msgIdV = mit->second;
|
||||
const std::set<RsGxsMessageId>& msgIdV = mit->second;
|
||||
std::vector<RsNxsMsg*> msgSet;
|
||||
|
||||
if(msgIdV.empty()){
|
||||
|
@ -1231,7 +1231,7 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b
|
|||
}else{
|
||||
|
||||
// request each grp
|
||||
std::vector<RsGxsMessageId>::const_iterator sit = msgIdV.begin();
|
||||
std::set<RsGxsMessageId>::const_iterator sit = msgIdV.begin();
|
||||
|
||||
for(; sit!=msgIdV.end();++sit){
|
||||
const RsGxsMessageId& msgId = *sit;
|
||||
|
@ -1301,7 +1301,7 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
|
|||
const RsGxsGroupId& grpId = mit->first;
|
||||
|
||||
// if vector empty then request all messages
|
||||
const std::vector<RsGxsMessageId>& msgIdV = mit->second;
|
||||
const std::set<RsGxsMessageId>& msgIdV = mit->second;
|
||||
std::vector<RsGxsMsgMetaData*> metaSet;
|
||||
|
||||
if(msgIdV.empty()){
|
||||
|
@ -1317,7 +1317,7 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
|
|||
}else{
|
||||
|
||||
// request each grp
|
||||
std::vector<RsGxsMessageId>::const_iterator sit = msgIdV.begin();
|
||||
std::set<RsGxsMessageId>::const_iterator sit = msgIdV.begin();
|
||||
|
||||
for(; sit!=msgIdV.end(); ++sit){
|
||||
const RsGxsMessageId& msgId = *sit;
|
||||
|
@ -1557,7 +1557,7 @@ int RsDataService::removeMsgs(const GxsMsgReq& msgIds)
|
|||
|
||||
for(; mit != msgIds.end(); ++mit)
|
||||
{
|
||||
const std::vector<RsGxsMessageId>& msgIdV = mit->second;
|
||||
const std::set<RsGxsMessageId>& msgIdV = mit->second;
|
||||
const RsGxsGroupId& grpId = mit->first;
|
||||
|
||||
// delete messages
|
||||
|
@ -1618,7 +1618,7 @@ int RsDataService::retrieveGroupIds(std::vector<RsGxsGroupId> &grpIds)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int RsDataService::retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_vector& msgIds)
|
||||
int RsDataService::retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_set& msgIds)
|
||||
{
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||
rstime::RsScopeTimer timer("");
|
||||
|
@ -1639,7 +1639,7 @@ int RsDataService::retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std
|
|||
if(c->columnCount() != 1)
|
||||
std::cerr << "(EE) ********* not retrieving all columns!!" << std::endl;
|
||||
|
||||
msgIds.push_back(RsGxsMessageId(msgId));
|
||||
msgIds.insert(RsGxsMessageId(msgId));
|
||||
valid = c->moveToNext();
|
||||
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||
|
@ -1670,8 +1670,8 @@ bool RsDataService::locked_removeMessageEntries(const GxsMsgReq& msgIds)
|
|||
for(; mit != msgIds.end(); ++mit)
|
||||
{
|
||||
const RsGxsGroupId& grpId = mit->first;
|
||||
const std::vector<RsGxsMessageId>& msgsV = mit->second;
|
||||
std::vector<RsGxsMessageId>::const_iterator vit = msgsV.begin();
|
||||
const std::set<RsGxsMessageId>& msgsV = mit->second;
|
||||
std::set<RsGxsMessageId>::const_iterator vit = msgsV.begin();
|
||||
|
||||
for(; vit != msgsV.end(); ++vit)
|
||||
{
|
||||
|
|
|
@ -106,7 +106,7 @@ public:
|
|||
* @param msgId msgsids retrieved
|
||||
* @return error code
|
||||
*/
|
||||
int retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_vector& msgId);
|
||||
int retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_set& msgId);
|
||||
|
||||
/*!
|
||||
* @return the cache size set for this RsGeneralDataService in bytes
|
||||
|
|
|
@ -204,7 +204,7 @@ public:
|
|||
* @param msgId msgsids retrieved
|
||||
* @return error code
|
||||
*/
|
||||
virtual int retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_vector& msgId) = 0;
|
||||
virtual int retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_set& msgId) = 0;
|
||||
|
||||
/*!
|
||||
* @return the cache size set for this RsGeneralDataService in bytes
|
||||
|
|
|
@ -212,7 +212,7 @@ void RsGenExchange::tick()
|
|||
RS_STACK_MUTEX(mGenMtx) ;
|
||||
|
||||
std::list<RsGxsGroupId> grpIds;
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgIds;
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgIds;
|
||||
mIntegrityCheck->getDeletedIds(grpIds, msgIds);
|
||||
|
||||
if (!grpIds.empty())
|
||||
|
@ -1073,23 +1073,19 @@ bool RsGenExchange::checkAuthenFlag(const PrivacyBitPos& pos, const uint8_t& fla
|
|||
}
|
||||
}
|
||||
|
||||
static void addMessageChanged(std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgs, const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgChanged)
|
||||
static void addMessageChanged(std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgs, const std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChanged)
|
||||
{
|
||||
if (msgs.empty()) {
|
||||
msgs = msgChanged;
|
||||
} else {
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::const_iterator mapIt;
|
||||
for (mapIt = msgChanged.begin(); mapIt != msgChanged.end(); ++mapIt) {
|
||||
for (auto mapIt = msgChanged.begin(); mapIt != msgChanged.end(); ++mapIt)
|
||||
{
|
||||
const RsGxsGroupId &grpId = mapIt->first;
|
||||
const std::vector<RsGxsMessageId> &srcMsgIds = mapIt->second;
|
||||
std::vector<RsGxsMessageId> &destMsgIds = msgs[grpId];
|
||||
const std::set<RsGxsMessageId> &srcMsgIds = mapIt->second;
|
||||
std::set<RsGxsMessageId> &destMsgIds = msgs[grpId];
|
||||
|
||||
std::vector<RsGxsMessageId>::const_iterator msgIt;
|
||||
for (msgIt = srcMsgIds.begin(); msgIt != srcMsgIds.end(); ++msgIt) {
|
||||
if (std::find(destMsgIds.begin(), destMsgIds.end(), *msgIt) == destMsgIds.end()) {
|
||||
destMsgIds.push_back(*msgIt);
|
||||
}
|
||||
}
|
||||
for (auto msgIt = srcMsgIds.begin(); msgIt != srcMsgIds.end(); ++msgIt)
|
||||
destMsgIds.insert(*msgIt) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1784,8 +1780,8 @@ void RsGenExchange::deleteMsgs(uint32_t& token, const GxsMsgReq& msgs)
|
|||
|
||||
if(mNetService != NULL)
|
||||
for(GxsMsgReq::const_iterator it(msgs.begin());it!=msgs.end();++it)
|
||||
for(uint32_t i=0;i<it->second.size();++i)
|
||||
mNetService->rejectMessage(it->second[i]) ;
|
||||
for(auto it2(it->second.begin());it2!=it->second.end();++it2)
|
||||
mNetService->rejectMessage(*it2);
|
||||
}
|
||||
|
||||
void RsGenExchange::publishMsg(uint32_t& token, RsGxsMsgItem *msgItem)
|
||||
|
@ -1956,8 +1952,8 @@ void RsGenExchange::processMsgMetaChanges()
|
|||
if(m.val.getAsInt32(RsGeneralDataService::MSG_META_STATUS+GXS_MASK, mask))
|
||||
{
|
||||
GxsMsgReq req;
|
||||
std::vector<RsGxsMessageId> msgIdV;
|
||||
msgIdV.push_back(m.msgId.second);
|
||||
std::set<RsGxsMessageId> msgIdV;
|
||||
msgIdV.insert(m.msgId.second);
|
||||
req.insert(std::make_pair(m.msgId.first, msgIdV));
|
||||
GxsMsgMetaResult result;
|
||||
mDataStore->retrieveGxsMsgMetaData(req, result);
|
||||
|
@ -1989,7 +1985,7 @@ void RsGenExchange::processMsgMetaChanges()
|
|||
mDataAccess->updatePublicRequestStatus(token, RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE);
|
||||
if (changed)
|
||||
{
|
||||
msgIds[m.msgId.first].push_back(m.msgId.second);
|
||||
msgIds[m.msgId.first].insert(m.msgId.second);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2005,7 +2001,7 @@ void RsGenExchange::processMsgMetaChanges()
|
|||
|
||||
if (!msgIds.empty()) {
|
||||
RS_STACK_MUTEX(mGenMtx);
|
||||
RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, true);
|
||||
RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, false);
|
||||
c->msgChangeMap = msgIds;
|
||||
mNotifications.push_back(c);
|
||||
}
|
||||
|
@ -2140,7 +2136,7 @@ void RsGenExchange::publishMsgs()
|
|||
mMsgsToPublish.insert(std::make_pair(sign_it->first, item.mItem));
|
||||
}
|
||||
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgChangeMap;
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgChangeMap;
|
||||
std::map<uint32_t, RsGxsMsgItem*>::iterator mit = mMsgsToPublish.begin();
|
||||
|
||||
for(; mit != mMsgsToPublish.end(); ++mit)
|
||||
|
@ -2268,7 +2264,7 @@ void RsGenExchange::publishMsgs()
|
|||
mDataAccess->addMsgData(msg);
|
||||
delete msg ;
|
||||
|
||||
msgChangeMap[grpId].push_back(msgId);
|
||||
msgChangeMap[grpId].insert(msgId);
|
||||
|
||||
delete[] metaDataBuff;
|
||||
|
||||
|
@ -2967,10 +2963,10 @@ void RsGenExchange::processRecvdMessages()
|
|||
msg->metaData->mMsgStatus = GXS_SERV::GXS_MSG_STATUS_UNPROCESSED | GXS_SERV::GXS_MSG_STATUS_GUI_NEW | GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD;
|
||||
msgs_to_store.push_back(msg);
|
||||
|
||||
std::vector<RsGxsMessageId> &msgv = msgIds[msg->grpId];
|
||||
|
||||
if (std::find(msgv.begin(), msgv.end(), msg->msgId) == msgv.end())
|
||||
msgv.push_back(msg->msgId);
|
||||
msgIds[msg->grpId].insert(msg->msgId);
|
||||
// std::vector<RsGxsMessageId> &msgv = msgIds[msg->grpId];
|
||||
// if (std::find(msgv.begin(), msgv.end(), msg->msgId) == msgv.end())
|
||||
// msgv.push_back(msg->msgId);
|
||||
|
||||
computeHash(msg->msg, msg->metaData->mHash);
|
||||
msg->metaData->recvTS = time(NULL);
|
||||
|
@ -3325,7 +3321,7 @@ void RsGenExchange::removeDeleteExistingMessages( std::list<RsNxsMsg*>& msgs, Gx
|
|||
|
||||
//RsGxsGroupId::std_list grpIds(mGrpIdsUnique.begin(), mGrpIdsUnique.end());
|
||||
//RsGxsGroupId::std_list::const_iterator it = grpIds.begin();
|
||||
typedef std::map<RsGxsGroupId, RsGxsMessageId::std_vector> MsgIdReq;
|
||||
typedef std::map<RsGxsGroupId, RsGxsMessageId::std_set> MsgIdReq;
|
||||
MsgIdReq msgIdReq;
|
||||
|
||||
// now get a list of all msgs ids for each group
|
||||
|
@ -3345,7 +3341,7 @@ void RsGenExchange::removeDeleteExistingMessages( std::list<RsNxsMsg*>& msgs, Gx
|
|||
// now for each msg to be stored that exist in the retrieved msg/grp "index" delete and erase from map
|
||||
for(std::list<RsNxsMsg*>::iterator cit2 = msgs.begin(); cit2 != msgs.end();)
|
||||
{
|
||||
const RsGxsMessageId::std_vector& msgIds = msgIdReq[(*cit2)->metaData->mGroupId];
|
||||
const RsGxsMessageId::std_set& msgIds = msgIdReq[(*cit2)->metaData->mGroupId];
|
||||
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << " grpid=" << (*cit2)->grpId << ", msgid=" << (*cit2)->msgId ;
|
||||
|
@ -3353,12 +3349,13 @@ void RsGenExchange::removeDeleteExistingMessages( std::list<RsNxsMsg*>& msgs, Gx
|
|||
|
||||
// Avoid storing messages that are already in the database, as well as messages that are too old (or generally do not pass the database storage test)
|
||||
//
|
||||
if(std::find(msgIds.begin(), msgIds.end(), (*cit2)->metaData->mMsgId) != msgIds.end() || !messagePublicationTest( *(*cit2)->metaData))
|
||||
if(msgIds.find((*cit2)->metaData->mMsgId) != msgIds.end() || !messagePublicationTest( *(*cit2)->metaData))
|
||||
{
|
||||
// msg exist in retrieved index. We should use a std::set here instead of a vector.
|
||||
|
||||
RsGxsMessageId::std_vector& notifyIds = msgIdsNotify[ (*cit2)->metaData->mGroupId];
|
||||
RsGxsMessageId::std_vector::iterator it2 = std::find(notifyIds.begin(), notifyIds.end(), (*cit2)->metaData->mMsgId);
|
||||
RsGxsMessageId::std_set& notifyIds = msgIdsNotify[ (*cit2)->metaData->mGroupId];
|
||||
RsGxsMessageId::std_set::iterator it2 = notifyIds.find((*cit2)->metaData->mMsgId);
|
||||
|
||||
if(it2 != notifyIds.end())
|
||||
{
|
||||
notifyIds.erase(it2);
|
||||
|
|
|
@ -222,7 +222,7 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType,
|
|||
MsgMetaReq* mmr = new MsgMetaReq();
|
||||
|
||||
for(; lit != grpIds.end(); ++lit)
|
||||
mmr->mMsgIds[*lit] = std::vector<RsGxsMessageId>();
|
||||
mmr->mMsgIds[*lit] = std::set<RsGxsMessageId>();
|
||||
|
||||
req = mmr;
|
||||
}else if(reqType & GXS_REQUEST_TYPE_MSG_DATA)
|
||||
|
@ -230,7 +230,7 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType,
|
|||
MsgDataReq* mdr = new MsgDataReq();
|
||||
|
||||
for(; lit != grpIds.end(); ++lit)
|
||||
mdr->mMsgIds[*lit] = std::vector<RsGxsMessageId>();
|
||||
mdr->mMsgIds[*lit] = std::set<RsGxsMessageId>();
|
||||
|
||||
req = mdr;
|
||||
}else if(reqType & GXS_REQUEST_TYPE_MSG_IDS)
|
||||
|
@ -238,7 +238,7 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType,
|
|||
MsgIdReq* mir = new MsgIdReq();
|
||||
|
||||
for(; lit != grpIds.end(); ++lit)
|
||||
mir->mMsgIds[*lit] = std::vector<RsGxsMessageId>();
|
||||
mir->mMsgIds[*lit] = std::set<RsGxsMessageId>();
|
||||
|
||||
req = mir;
|
||||
}
|
||||
|
@ -1188,7 +1188,7 @@ bool RsGxsDataAccess::getMsgList(const GxsMsgReq& msgIds, const RsTokReqOptions&
|
|||
// Add the discovered Latest Msgs.
|
||||
for(oit = origMsgTs.begin(); oit != origMsgTs.end(); ++oit)
|
||||
{
|
||||
msgIdsOut[grpId].push_back(oit->second.first);
|
||||
msgIdsOut[grpId].insert(oit->second.first);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1225,7 +1225,7 @@ bool RsGxsDataAccess::getMsgList(const GxsMsgReq& msgIds, const RsTokReqOptions&
|
|||
|
||||
if (add)
|
||||
{
|
||||
msgIdsOut[grpId].push_back(msgMeta->mMsgId);
|
||||
msgIdsOut[grpId].insert(msgMeta->mMsgId);
|
||||
metaFilter[grpId].insert(std::make_pair(msgMeta->mMsgId, msgMeta));
|
||||
}
|
||||
|
||||
|
@ -1370,7 +1370,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
|
|||
// get meta data for all in group
|
||||
GxsMsgMetaResult result;
|
||||
GxsMsgReq msgIds;
|
||||
msgIds.insert(std::make_pair(grpMsgIdPair.first, std::vector<RsGxsMessageId>()));
|
||||
msgIds.insert(std::make_pair(grpMsgIdPair.first, std::set<RsGxsMessageId>()));
|
||||
mDataStore->retrieveGxsMsgMetaData(msgIds, result);
|
||||
std::vector<RsGxsMsgMetaData*>& metaV = result[grpMsgIdPair.first];
|
||||
std::vector<RsGxsMsgMetaData*>::iterator vit_meta;
|
||||
|
@ -1379,7 +1379,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
|
|||
const RsGxsMessageId& msgId = grpMsgIdPair.second;
|
||||
const RsGxsGroupId& grpId = grpMsgIdPair.first;
|
||||
|
||||
std::vector<RsGxsMessageId> outMsgIds;
|
||||
std::set<RsGxsMessageId> outMsgIds;
|
||||
|
||||
RsGxsMsgMetaData* origMeta = NULL;
|
||||
for(vit_meta = metaV.begin(); vit_meta != metaV.end(); ++vit_meta)
|
||||
|
@ -1474,7 +1474,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
|
|||
// Add the discovered Latest Msgs.
|
||||
for(oit = origMsgTs.begin(); oit != origMsgTs.end(); ++oit)
|
||||
{
|
||||
outMsgIds.push_back(oit->second.first);
|
||||
outMsgIds.insert(oit->second.first);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1499,7 +1499,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
|
|||
}
|
||||
}
|
||||
}
|
||||
outMsgIds.push_back(latestMsgId);
|
||||
outMsgIds.insert(latestMsgId);
|
||||
metaMap.insert(std::make_pair(latestMsgId, latestMeta));
|
||||
}
|
||||
}
|
||||
|
@ -1511,7 +1511,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
|
|||
|
||||
if (meta->mOrigMsgId == origMsgId)
|
||||
{
|
||||
outMsgIds.push_back(meta->mMsgId);
|
||||
outMsgIds.insert(meta->mMsgId);
|
||||
metaMap.insert(std::make_pair(meta->mMsgId, meta));
|
||||
}
|
||||
}
|
||||
|
@ -1553,7 +1553,7 @@ bool RsGxsDataAccess::getGroupStatistic(GroupStatisticRequest *req)
|
|||
{
|
||||
// filter based on options
|
||||
GxsMsgIdResult metaReq;
|
||||
metaReq[req->mGrpId] = std::vector<RsGxsMessageId>();
|
||||
metaReq[req->mGrpId] = std::set<RsGxsMessageId>();
|
||||
GxsMsgMetaResult metaResult;
|
||||
mDataStore->retrieveGxsMsgMetaData(metaReq, metaResult);
|
||||
|
||||
|
@ -1669,7 +1669,7 @@ bool RsGxsDataAccess::getMsgList(MsgIdReq* req)
|
|||
for(; vit != vit_end; ++vit)
|
||||
{
|
||||
RsGxsMsgMetaData* meta = *vit;
|
||||
req->mMsgIdResult[grpId].push_back(meta->mMsgId);
|
||||
req->mMsgIdResult[grpId].insert(meta->mMsgId);
|
||||
delete meta; // discard meta data mem
|
||||
}
|
||||
}
|
||||
|
@ -1715,8 +1715,8 @@ void RsGxsDataAccess::filterMsgList(GxsMsgIdResult& msgIds, const RsTokReqOption
|
|||
if(cit == msgMetas.end())
|
||||
continue;
|
||||
|
||||
std::vector<RsGxsMessageId>& msgs = mit->second;
|
||||
std::vector<RsGxsMessageId>::iterator vit = msgs.begin();
|
||||
std::set<RsGxsMessageId>& msgs = mit->second;
|
||||
std::set<RsGxsMessageId>::iterator vit = msgs.begin();
|
||||
const std::map<RsGxsMessageId, RsGxsMsgMetaData*>& meta = cit->second;
|
||||
std::map<RsGxsMessageId, RsGxsMsgMetaData*>::const_iterator cit2;
|
||||
|
||||
|
|
|
@ -781,7 +781,7 @@ void RsGxsNetService::handleRecvSyncGrpStatistics(RsNxsSyncGrpStatsItem *grs)
|
|||
// now count available messages
|
||||
|
||||
GxsMsgReq reqIds;
|
||||
reqIds[grs->grpId] = std::vector<RsGxsMessageId>();
|
||||
reqIds[grs->grpId] = std::set<RsGxsMessageId>();
|
||||
GxsMsgMetaResult result;
|
||||
|
||||
#ifdef NXS_NET_DEBUG_6
|
||||
|
@ -2754,7 +2754,7 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
|
|||
#endif
|
||||
|
||||
GxsMsgReq reqIds;
|
||||
reqIds[grpId] = std::vector<RsGxsMessageId>();
|
||||
reqIds[grpId] = std::set<RsGxsMessageId>();
|
||||
GxsMsgMetaResult result;
|
||||
mDataStore->retrieveGxsMsgMetaData(reqIds, result);
|
||||
std::vector<RsGxsMsgMetaData*> &msgMetaV = result[grpId];
|
||||
|
@ -3293,7 +3293,7 @@ void RsGxsNetService::locked_genSendMsgsTransaction(NxsTransaction* tr)
|
|||
RsNxsSyncMsgItem* item = dynamic_cast<RsNxsSyncMsgItem*>(*lit);
|
||||
if (item)
|
||||
{
|
||||
msgIds[item->grpId].push_back(item->msgId);
|
||||
msgIds[item->grpId].insert(item->msgId);
|
||||
|
||||
if(grpId.isNull())
|
||||
grpId = item->grpId;
|
||||
|
@ -4124,7 +4124,7 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsgReqItem *item,bool item_
|
|||
}
|
||||
|
||||
GxsMsgReq req;
|
||||
req[item->grpId] = std::vector<RsGxsMessageId>();
|
||||
req[item->grpId] = std::set<RsGxsMessageId>();
|
||||
|
||||
GxsMsgMetaResult metaResult;
|
||||
mDataStore->retrieveGxsMsgMetaData(req, metaResult);
|
||||
|
|
|
@ -63,7 +63,7 @@ bool RsGxsMessageCleanUp::clean()
|
|||
GxsMsgReq req;
|
||||
GxsMsgMetaResult result;
|
||||
|
||||
req[grpId] = std::vector<RsGxsMessageId>();
|
||||
req[grpId] = std::set<RsGxsMessageId>();
|
||||
mDs->retrieveGxsMsgMetaData(req, result);
|
||||
|
||||
GxsMsgMetaResult::iterator mit = result.begin();
|
||||
|
@ -113,7 +113,7 @@ bool RsGxsMessageCleanUp::clean()
|
|||
|
||||
if( remove )
|
||||
{
|
||||
req[grpId].push_back(meta->mMsgId);
|
||||
req[grpId].insert(meta->mMsgId);
|
||||
|
||||
#ifdef DEBUG_GXSUTIL
|
||||
std::cerr << " Scheduling for removal." << std::endl;
|
||||
|
@ -237,9 +237,9 @@ bool RsGxsIntegrityCheck::check()
|
|||
for (msgIdsIt = msgIds.begin(); msgIdsIt != msgIds.end(); ++msgIdsIt)
|
||||
{
|
||||
const RsGxsGroupId& grpId = msgIdsIt->first;
|
||||
std::vector<RsGxsMessageId> &msgIdV = msgIdsIt->second;
|
||||
std::set<RsGxsMessageId> &msgIdV = msgIdsIt->second;
|
||||
|
||||
std::vector<RsGxsMessageId>::iterator msgIdIt;
|
||||
std::set<RsGxsMessageId>::iterator msgIdIt;
|
||||
for (msgIdIt = msgIdV.begin(); msgIdIt != msgIdV.end(); ++msgIdIt)
|
||||
{
|
||||
const RsGxsMessageId& msgId = *msgIdIt;
|
||||
|
@ -257,7 +257,7 @@ bool RsGxsIntegrityCheck::check()
|
|||
|
||||
if (nxsMsgIt == nxsMsgV.end())
|
||||
{
|
||||
msgsToDel[grpId].push_back(msgId);
|
||||
msgsToDel[grpId].insert(msgId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ bool RsGxsIntegrityCheck::check()
|
|||
if(msg->metaData == NULL || currHash != msg->metaData->mHash)
|
||||
{
|
||||
std::cerr << "(EE) deleting message data with wrong hash or null meta data. meta=" << (void*)msg->metaData << std::endl;
|
||||
msgsToDel[msg->grpId].push_back(msg->msgId);
|
||||
msgsToDel[msg->grpId].insert(msg->msgId);
|
||||
}
|
||||
else if(!msg->metaData->mAuthorId.isNull() && subscribed_groups.find(msg->metaData->mGroupId)!=subscribed_groups.end())
|
||||
{
|
||||
|
@ -373,7 +373,7 @@ bool RsGxsIntegrityCheck::isDone()
|
|||
return mDone;
|
||||
}
|
||||
|
||||
void RsGxsIntegrityCheck::getDeletedIds(std::list<RsGxsGroupId>& grpIds, std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgIds)
|
||||
void RsGxsIntegrityCheck::getDeletedIds(std::list<RsGxsGroupId>& grpIds, std::map<RsGxsGroupId, std::set<RsGxsMessageId> >& msgIds)
|
||||
{
|
||||
RsStackMutex stack(mIntegrityMutex);
|
||||
|
||||
|
|
|
@ -205,7 +205,7 @@ public:
|
|||
|
||||
void run();
|
||||
|
||||
void getDeletedIds(std::list<RsGxsGroupId>& grpIds, std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgIds);
|
||||
void getDeletedIds(std::list<RsGxsGroupId>& grpIds, std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgIds);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -214,7 +214,7 @@ private:
|
|||
bool mDone;
|
||||
RsMutex mIntegrityMutex;
|
||||
std::list<RsGxsGroupId> mDeletedGrps;
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > mDeletedMsgs;
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > mDeletedMsgs;
|
||||
|
||||
RsGixs *mGixs ;
|
||||
};
|
||||
|
|
|
@ -458,7 +458,7 @@ void p3GxsTrans::GxsTransIntegrityCleanupThread::run()
|
|||
|
||||
if(stored_msgs.end() != it2)
|
||||
{
|
||||
msgsToDel[it2->second.first].push_back(it2->second.second);
|
||||
msgsToDel[it2->second.first].insert(it2->second.second);
|
||||
|
||||
#ifdef DEBUG_GXSTRANS
|
||||
std::cerr << " scheduling msg " << std::hex << it2->second.first << "," << it2->second.second << " for deletion." << std::endl;
|
||||
|
|
|
@ -38,11 +38,6 @@ DESTDIR = lib
|
|||
#QMAKE_CFLAGS += -Werror
|
||||
#QMAKE_CXXFLAGS += -Werror
|
||||
|
||||
# when rapidjson is mainstream on all distribs, we will not need the sources anymore
|
||||
# in the meantime, they are part of the RS directory so that it is always possible to find them
|
||||
|
||||
INCLUDEPATH += ../../rapidjson-1.1.0
|
||||
|
||||
debug {
|
||||
# DEFINES *= DEBUG
|
||||
# DEFINES *= OPENDHT_DEBUG DHT_DEBUG CONN_DEBUG DEBUG_UDP_SORTER P3DISC_DEBUG DEBUG_UDP_LAYER FT_DEBUG EXTADDRSEARCH_DEBUG
|
||||
|
@ -288,8 +283,6 @@ win32-g++ {
|
|||
|
||||
DEFINES += USE_CMD_ARGS
|
||||
|
||||
CONFIG += upnp_miniupnpc
|
||||
|
||||
wLibs = ws2_32 gdi32 uuid iphlpapi crypt32 ole32 winmm
|
||||
LIBS += $$linkDynamicLibs(wLibs)
|
||||
}
|
||||
|
@ -300,22 +293,10 @@ mac {
|
|||
QMAKE_CC = $${QMAKE_CXX}
|
||||
OBJECTS_DIR = temp/obj
|
||||
MOC_DIR = temp/moc
|
||||
#DEFINES = WINDOWS_SYS WIN32 STATICLIB MINGW
|
||||
#DEFINES *= MINIUPNPC_VERSION=13
|
||||
|
||||
CONFIG += upnp_miniupnpc
|
||||
CONFIG += c++11
|
||||
|
||||
# zeroconf disabled at the end of libretroshare.pro (but need the code)
|
||||
#CONFIG += zeroconf
|
||||
#CONFIG += zcnatassist
|
||||
|
||||
# Beautiful Hack to fix 64bit file access.
|
||||
QMAKE_CXXFLAGS *= -Dfseeko64=fseeko -Dftello64=ftello -Dfopen64=fopen -Dvstatfs64=vstatfs
|
||||
|
||||
#GPG_ERROR_DIR = ../../../../libgpg-error-1.7
|
||||
#GPGME_DIR = ../../../../gpgme-1.1.8
|
||||
|
||||
for(lib, LIB_DIR):LIBS += -L"$$lib"
|
||||
for(bin, BIN_DIR):LIBS += -L"$$bin"
|
||||
|
||||
|
@ -541,7 +522,8 @@ HEADERS += util/folderiterator.h \
|
|||
util/rstime.h \
|
||||
util/stacktrace.h \
|
||||
util/rsdeprecate.h \
|
||||
util/cxx11retrocompat.h
|
||||
util/cxx11retrocompat.h \
|
||||
util/rsurl.h
|
||||
|
||||
SOURCES += ft/ftchunkmap.cc \
|
||||
ft/ftcontroller.cc \
|
||||
|
@ -684,7 +666,8 @@ SOURCES += util/folderiterator.cc \
|
|||
util/rsrandom.cc \
|
||||
util/rstickevent.cc \
|
||||
util/rsrecogn.cc \
|
||||
util/rstime.cc
|
||||
util/rstime.cc \
|
||||
util/rsurl.cc
|
||||
|
||||
## Added for retrocompatibility remove ASAP
|
||||
isEmpty(RS_UPNP_LIB) {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright 2016 Cyril Soler <csoler@users.sourceforge.net> *
|
||||
* Copyright 2018 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -32,25 +33,21 @@
|
|||
|
||||
//#define DEBUG_RSCERTIFICATE
|
||||
|
||||
static const std::string PGP_CERTIFICATE_START ( "-----BEGIN PGP PUBLIC KEY BLOCK-----" );
|
||||
static const std::string PGP_CERTIFICATE_END ( "-----END PGP PUBLIC KEY BLOCK-----" );
|
||||
static const std::string EXTERNAL_IP_BEGIN_SECTION ( "--EXT--" );
|
||||
static const std::string LOCAL_IP_BEGIN_SECTION ( "--LOCAL--" );
|
||||
static const std::string SSLID_BEGIN_SECTION ( "--SSLID--" );
|
||||
static const std::string LOCATION_BEGIN_SECTION ( "--LOCATION--" );
|
||||
static const std::string HIDDEN_NODE_BEGIN_SECTION ( "--HIDDEN--" );
|
||||
static const uint8_t CERTIFICATE_VERSION_06 = 0x06;
|
||||
|
||||
static const uint8_t CERTIFICATE_PTAG_PGP_SECTION = 0x01 ;
|
||||
static const uint8_t CERTIFICATE_PTAG_EXTIPANDPORT_SECTION = 0x02 ;
|
||||
static const uint8_t CERTIFICATE_PTAG_LOCIPANDPORT_SECTION = 0x03 ;
|
||||
static const uint8_t CERTIFICATE_PTAG_DNS_SECTION = 0x04 ;
|
||||
static const uint8_t CERTIFICATE_PTAG_SSLID_SECTION = 0x05 ;
|
||||
static const uint8_t CERTIFICATE_PTAG_NAME_SECTION = 0x06 ;
|
||||
static const uint8_t CERTIFICATE_PTAG_CHECKSUM_SECTION = 0x07 ;
|
||||
static const uint8_t CERTIFICATE_PTAG_HIDDENNODE_SECTION = 0x08 ;
|
||||
static const uint8_t CERTIFICATE_PTAG_VERSION_SECTION = 0x09 ;
|
||||
|
||||
static const uint8_t CERTIFICATE_VERSION_06 = 0x06 ;
|
||||
enum CertificatePtag : uint8_t
|
||||
{
|
||||
CERTIFICATE_PTAG_PGP_SECTION = 0x01,
|
||||
CERTIFICATE_PTAG_EXTIPANDPORT_SECTION = 0x02,
|
||||
CERTIFICATE_PTAG_LOCIPANDPORT_SECTION = 0x03,
|
||||
CERTIFICATE_PTAG_DNS_SECTION = 0x04,
|
||||
CERTIFICATE_PTAG_SSLID_SECTION = 0x05,
|
||||
CERTIFICATE_PTAG_NAME_SECTION = 0x06,
|
||||
CERTIFICATE_PTAG_CHECKSUM_SECTION = 0x07,
|
||||
CERTIFICATE_PTAG_HIDDENNODE_SECTION = 0x08,
|
||||
CERTIFICATE_PTAG_VERSION_SECTION = 0x09,
|
||||
CERTIFICATE_PTAG_EXTRA_LOCATOR = 10
|
||||
};
|
||||
|
||||
static bool is_acceptable_radix64Char(char c)
|
||||
{
|
||||
|
@ -116,6 +113,14 @@ std::string RsCertificate::toStdString() const
|
|||
|
||||
addPacket( CERTIFICATE_PTAG_NAME_SECTION , (unsigned char *)location_name.c_str() ,location_name.length() , buf, p, BS ) ;
|
||||
addPacket( CERTIFICATE_PTAG_SSLID_SECTION , location_id.toByteArray() ,location_id.SIZE_IN_BYTES, buf, p, BS ) ;
|
||||
|
||||
for (const RsUrl& locator : mLocators)
|
||||
{
|
||||
std::string urlStr(locator.toString());
|
||||
addPacket( CERTIFICATE_PTAG_EXTRA_LOCATOR,
|
||||
(unsigned char *) urlStr.c_str(), urlStr.size(),
|
||||
buf, p, BS );
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t computed_crc = PGPKeyManagement::compute24bitsCRC(buf,p) ;
|
||||
|
@ -216,7 +221,10 @@ RsCertificate::RsCertificate(const RsPeerDetails& Detail, const unsigned char *b
|
|||
memset(ipv4_external_ip_and_port,0,6) ;
|
||||
}
|
||||
|
||||
dns_name = Detail.dyndns ;
|
||||
dns_name = Detail.dyndns;
|
||||
|
||||
for(auto&& ipr : Detail.ipAddressList)
|
||||
mLocators.insert(RsUrl(ipr.substr(0, ipr.find(' '))));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -275,19 +283,19 @@ bool RsCertificate::initFromString(const std::string& instr,uint32_t& err_code)
|
|||
std::vector<uint8_t> bf = Radix64::decode(str) ;
|
||||
size_t size = bf.size();
|
||||
|
||||
bool checksum_check_passed = false ;
|
||||
unsigned char *buf = bf.data() ;
|
||||
size_t total_s = 0 ;
|
||||
only_pgp = true ;
|
||||
uint8_t certificate_version = 0x00 ;
|
||||
bool checksum_check_passed = false;
|
||||
unsigned char *buf = bf.data();
|
||||
size_t total_s = 0;
|
||||
only_pgp = true;
|
||||
uint8_t certificate_version = 0x00;
|
||||
|
||||
while(total_s < size)
|
||||
{
|
||||
uint8_t ptag = buf[0];
|
||||
buf = &buf[1] ;
|
||||
buf = &buf[1];
|
||||
|
||||
unsigned char *buf2 = buf ;
|
||||
uint32_t s = PGPKeyParser::read_125Size(buf) ;
|
||||
unsigned char *buf2 = buf;
|
||||
uint32_t s = PGPKeyParser::read_125Size(buf);
|
||||
|
||||
total_s += 1 + ((unsigned long)buf-(unsigned long)buf2) ;
|
||||
|
||||
|
@ -302,90 +310,80 @@ bool RsCertificate::initFromString(const std::string& instr,uint32_t& err_code)
|
|||
#endif
|
||||
switch(ptag)
|
||||
{
|
||||
case CERTIFICATE_PTAG_VERSION_SECTION: certificate_version = buf[0] ;
|
||||
buf = &buf[s] ;
|
||||
break ;
|
||||
|
||||
|
||||
case CERTIFICATE_PTAG_PGP_SECTION: binary_pgp_key = new unsigned char[s] ;
|
||||
memcpy(binary_pgp_key,buf,s) ;
|
||||
binary_pgp_key_size = s ;
|
||||
buf = &buf[s] ;
|
||||
break ;
|
||||
|
||||
case CERTIFICATE_PTAG_NAME_SECTION: location_name = std::string((char *)buf,s) ;
|
||||
buf = &buf[s] ;
|
||||
break ;
|
||||
|
||||
case CERTIFICATE_PTAG_SSLID_SECTION:
|
||||
if(s != location_id.SIZE_IN_BYTES)
|
||||
{
|
||||
err_code = CERTIFICATE_PARSING_ERROR_INVALID_LOCATION_ID ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
location_id = RsPeerId(buf) ;
|
||||
buf = &buf[s] ;
|
||||
only_pgp = false ;
|
||||
break ;
|
||||
|
||||
case CERTIFICATE_PTAG_DNS_SECTION: dns_name = std::string((char *)buf,s) ;
|
||||
buf = &buf[s] ;
|
||||
break ;
|
||||
|
||||
case CERTIFICATE_PTAG_HIDDENNODE_SECTION:
|
||||
hidden_node_address = std::string((char *)buf,s);
|
||||
hidden_node = true;
|
||||
buf = &buf[s];
|
||||
|
||||
break ;
|
||||
|
||||
case CERTIFICATE_PTAG_LOCIPANDPORT_SECTION:
|
||||
if(s != 6)
|
||||
|
||||
{
|
||||
err_code = CERTIFICATE_PARSING_ERROR_INVALID_LOCAL_IP;
|
||||
return false ;
|
||||
}
|
||||
|
||||
memcpy(ipv4_internal_ip_and_port,buf,s) ;
|
||||
buf = &buf[s] ;
|
||||
break ;
|
||||
case CERTIFICATE_PTAG_EXTIPANDPORT_SECTION:
|
||||
if(s != 6)
|
||||
{
|
||||
err_code = CERTIFICATE_PARSING_ERROR_INVALID_EXTERNAL_IP;
|
||||
return false ;
|
||||
}
|
||||
|
||||
memcpy(ipv4_external_ip_and_port,buf,s) ;
|
||||
buf = &buf[s] ;
|
||||
break ;
|
||||
case CERTIFICATE_PTAG_CHECKSUM_SECTION:
|
||||
{
|
||||
if(s != 3 || total_s+3 != size)
|
||||
{
|
||||
err_code = CERTIFICATE_PARSING_ERROR_INVALID_CHECKSUM_SECTION ;
|
||||
return false ;
|
||||
}
|
||||
uint32_t computed_crc = PGPKeyManagement::compute24bitsCRC(bf.data(),size-5) ;
|
||||
uint32_t certificate_crc = buf[0] + (buf[1] << 8) + (buf[2] << 16) ;
|
||||
|
||||
if(computed_crc != certificate_crc)
|
||||
{
|
||||
err_code = CERTIFICATE_PARSING_ERROR_CHECKSUM_ERROR ;
|
||||
return false ;
|
||||
}
|
||||
else
|
||||
checksum_check_passed = true ;
|
||||
}
|
||||
break ;
|
||||
default:
|
||||
std::cerr << "(WW) unknwown PTAG 0x" << std::hex << ptag << std::dec << " in certificate! Ignoring it." << std::endl;
|
||||
buf = &buf[s] ;
|
||||
break ;
|
||||
case CERTIFICATE_PTAG_VERSION_SECTION:
|
||||
certificate_version = buf[0];
|
||||
break;
|
||||
case CERTIFICATE_PTAG_PGP_SECTION:
|
||||
binary_pgp_key = new unsigned char[s];
|
||||
memcpy(binary_pgp_key,buf,s);
|
||||
binary_pgp_key_size = s;
|
||||
break;
|
||||
case CERTIFICATE_PTAG_NAME_SECTION:
|
||||
location_name = std::string((char *)buf,s);
|
||||
break;
|
||||
case CERTIFICATE_PTAG_SSLID_SECTION:
|
||||
if(s != location_id.SIZE_IN_BYTES)
|
||||
{
|
||||
err_code = CERTIFICATE_PARSING_ERROR_INVALID_LOCATION_ID;
|
||||
return false;
|
||||
}
|
||||
location_id = RsPeerId(buf);
|
||||
only_pgp = false;
|
||||
break;
|
||||
case CERTIFICATE_PTAG_DNS_SECTION:
|
||||
dns_name = std::string((char *)buf,s);
|
||||
break;
|
||||
case CERTIFICATE_PTAG_HIDDENNODE_SECTION:
|
||||
hidden_node_address = std::string((char *)buf,s);
|
||||
hidden_node = true;
|
||||
break;
|
||||
case CERTIFICATE_PTAG_LOCIPANDPORT_SECTION:
|
||||
if(s != 6)
|
||||
{
|
||||
err_code = CERTIFICATE_PARSING_ERROR_INVALID_LOCAL_IP;
|
||||
return false;
|
||||
}
|
||||
memcpy(ipv4_internal_ip_and_port,buf,s);
|
||||
break;
|
||||
case CERTIFICATE_PTAG_EXTIPANDPORT_SECTION:
|
||||
if(s != 6)
|
||||
{
|
||||
err_code = CERTIFICATE_PARSING_ERROR_INVALID_EXTERNAL_IP;
|
||||
return false;
|
||||
}
|
||||
memcpy(ipv4_external_ip_and_port,buf,s);
|
||||
break;
|
||||
case CERTIFICATE_PTAG_CHECKSUM_SECTION:
|
||||
{
|
||||
if(s != 3 || total_s+3 != size)
|
||||
{
|
||||
err_code =
|
||||
CERTIFICATE_PARSING_ERROR_INVALID_CHECKSUM_SECTION;
|
||||
return false;
|
||||
}
|
||||
uint32_t computed_crc =
|
||||
PGPKeyManagement::compute24bitsCRC(bf.data(),size-5);
|
||||
uint32_t certificate_crc =
|
||||
buf[0] + (buf[1] << 8) + (buf[2] << 16);
|
||||
if(computed_crc != certificate_crc)
|
||||
{
|
||||
err_code = CERTIFICATE_PARSING_ERROR_CHECKSUM_ERROR;
|
||||
return false;
|
||||
}
|
||||
else checksum_check_passed = true;
|
||||
break;
|
||||
}
|
||||
case CERTIFICATE_PTAG_EXTRA_LOCATOR:
|
||||
mLocators.insert(RsUrl(std::string((char *)buf, s)));
|
||||
break;
|
||||
default:
|
||||
std::cerr << "(WW) unknwown PTAG 0x" << std::hex << ptag
|
||||
<< std::dec << " in certificate! Ignoring it."
|
||||
<< std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
buf = &buf[s];
|
||||
total_s += s ;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,30 @@
|
|||
#pragma once
|
||||
|
||||
#pragma once
|
||||
/*
|
||||
* RetroShare
|
||||
*
|
||||
* Copyright (C) 2012-2014 Cyril Soler <csoler@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "retroshare/rstypes.h"
|
||||
#include "util/rsurl.h"
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <retroshare/rstypes.h>
|
||||
|
||||
class RsPeerDetails ;
|
||||
|
||||
|
@ -65,6 +86,7 @@ class RsCertificate
|
|||
size_t pgp_key_size() const { return binary_pgp_key_size ; }
|
||||
|
||||
static bool cleanCertificate(const std::string& input, std::string& output, RsCertificate::Format& format, int& error_code, bool check_content) ;
|
||||
const std::set<RsUrl>& locators() const { return mLocators; }
|
||||
|
||||
private:
|
||||
static bool cleanCertificate(const std::string& input,std::string& output,int&) ; // new radix format
|
||||
|
@ -92,6 +114,7 @@ class RsCertificate
|
|||
std::string pgp_version ;
|
||||
std::string dns_name ;
|
||||
std::string hidden_node_address;
|
||||
std::set<RsUrl> mLocators;
|
||||
|
||||
bool only_pgp ; // does the cert contain only pgp info?
|
||||
bool hidden_node; // IP or hidden Node Address.
|
||||
|
|
|
@ -983,8 +983,8 @@ bool p3NetMgrIMPL::checkNetAddress()
|
|||
bool addrChanged = false;
|
||||
bool validAddr = false;
|
||||
|
||||
struct sockaddr_storage prefAddr;
|
||||
struct sockaddr_storage oldAddr;
|
||||
sockaddr_storage prefAddr;
|
||||
sockaddr_storage oldAddr;
|
||||
|
||||
if (mNetMode & RS_NET_MODE_TRY_LOOPBACK)
|
||||
{
|
||||
|
@ -992,7 +992,7 @@ bool p3NetMgrIMPL::checkNetAddress()
|
|||
std::cerr << "p3NetMgrIMPL::checkNetAddress() LOOPBACK ... forcing to 127.0.0.1";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
sockaddr_storage_ipv4_aton(prefAddr, "127.0.0.1");
|
||||
sockaddr_storage_ipv4_aton(prefAddr, "127.0.0.1");
|
||||
validAddr = true;
|
||||
}
|
||||
else
|
||||
|
@ -1008,7 +1008,7 @@ bool p3NetMgrIMPL::checkNetAddress()
|
|||
std::vector<sockaddr_storage> addrs;
|
||||
if (getLocalAddresses(addrs))
|
||||
{
|
||||
for (auto it = addrs.begin(); it!=addrs.end(); ++it)
|
||||
for (auto it = addrs.begin(); it != addrs.end(); ++it)
|
||||
{
|
||||
sockaddr_storage& addr(*it);
|
||||
if( sockaddr_storage_isValidNet(addr) &&
|
||||
|
@ -1056,8 +1056,8 @@ bool p3NetMgrIMPL::checkNetAddress()
|
|||
|
||||
{
|
||||
RS_STACK_MUTEX(mNetMtx);
|
||||
|
||||
oldAddr = mLocalAddr;
|
||||
|
||||
sockaddr_storage_copy(mLocalAddr, oldAddr);
|
||||
addrChanged = !sockaddr_storage_sameip(prefAddr, mLocalAddr);
|
||||
|
||||
#ifdef NETMGR_DEBUG_TICK
|
||||
|
@ -1083,7 +1083,7 @@ bool p3NetMgrIMPL::checkNetAddress()
|
|||
|
||||
// update address.
|
||||
sockaddr_storage_copyip(mLocalAddr, prefAddr);
|
||||
mNetFlags.mLocalAddr = mLocalAddr;
|
||||
sockaddr_storage_copy(mLocalAddr, mNetFlags.mLocalAddr);
|
||||
|
||||
if(sockaddr_storage_isLoopbackNet(mLocalAddr))
|
||||
{
|
||||
|
@ -1115,12 +1115,7 @@ bool p3NetMgrIMPL::checkNetAddress()
|
|||
#ifdef NETMGR_DEBUG
|
||||
std::cerr << "p3NetMgrIMPL::checkNetAddress() Correcting Port to DEFAULT" << std::endl;
|
||||
#endif
|
||||
// Generate a default port from SSL id. The port will always be the
|
||||
// same, but appear random from peer to peer.
|
||||
// Random port avoids clashes, improves anonymity.
|
||||
//
|
||||
|
||||
int new_port = htons(PQI_MIN_PORT_RNG + (RSRandom::random_u32() % (PQI_MAX_PORT - PQI_MIN_PORT_RNG)));
|
||||
uint16_t new_port = htons(PQI_MIN_PORT_RNG + (RSRandom::random_u32() % (PQI_MAX_PORT - PQI_MIN_PORT_RNG)));
|
||||
sockaddr_storage_setport(mLocalAddr, new_port);
|
||||
|
||||
addrChanged = true;
|
||||
|
@ -1130,9 +1125,13 @@ bool p3NetMgrIMPL::checkNetAddress()
|
|||
* are the same (modify server)... this mismatch can
|
||||
* occur when the local port is changed....
|
||||
*/
|
||||
if (sockaddr_storage_sameip(mLocalAddr, mExtAddr))
|
||||
if (sockaddr_storage_sameip(mLocalAddr, mExtAddr) && sockaddr_storage_port(mLocalAddr) != sockaddr_storage_port(mExtAddr))
|
||||
{
|
||||
#ifdef NETMGR_DEBUG_RESET
|
||||
std::cerr << "p3NetMgrIMPL::checkNetAddress() local and external ports are not the same. Setting external port to " << sockaddr_storage_port(mLocalAddr) << std::endl;
|
||||
#endif
|
||||
sockaddr_storage_setport(mExtAddr, sockaddr_storage_port(mLocalAddr));
|
||||
addrChanged = true;
|
||||
}
|
||||
|
||||
// ensure that address family is set, otherwise windows Barfs.
|
||||
|
|
|
@ -1235,11 +1235,11 @@ bool p3PeerMgrIMPL::UpdateOwnAddress( const sockaddr_storage& pLocalAddr,
|
|||
sockaddr_storage_copy(pExtAddr, extAddr);
|
||||
sockaddr_storage_ipv6_to_ipv4(extAddr);
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
//#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::UpdateOwnAddress("
|
||||
<< sockaddr_storage_tostring(localAddr) << ", "
|
||||
<< sockaddr_storage_tostring(extAddr) << ")" << std::endl;
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
if( rsBanList &&
|
||||
!rsBanList->isAddressAccepted(localAddr,
|
||||
|
@ -1361,16 +1361,63 @@ bool p3PeerMgrIMPL::UpdateOwnAddress( const sockaddr_storage& pLocalAddr,
|
|||
}
|
||||
|
||||
|
||||
bool p3PeerMgrIMPL::addPeerLocator(const RsPeerId &sslId, const RsUrl& locator)
|
||||
{
|
||||
std::string host(locator.host());
|
||||
pqiIpAddress ip;
|
||||
if(!locator.hasPort() || host.empty() ||
|
||||
!sockaddr_storage_inet_pton(ip.mAddr, host) ||
|
||||
!sockaddr_storage_setport(ip.mAddr, locator.port())) return false;
|
||||
ip.mSeenTime = time(NULL);
|
||||
|
||||
bool changed = false;
|
||||
|
||||
bool p3PeerMgrIMPL::setLocalAddress(const RsPeerId &id, const struct sockaddr_storage &addr)
|
||||
if (sslId == AuthSSL::getAuthSSL()->OwnId())
|
||||
{
|
||||
RS_STACK_MUTEX(mPeerMtx);
|
||||
changed = mOwnState.ipAddrs.updateLocalAddrs(ip);
|
||||
}
|
||||
else
|
||||
{
|
||||
RS_STACK_MUTEX(mPeerMtx);
|
||||
auto it = mFriendList.find(sslId);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
it = mOthersList.find(sslId);
|
||||
if (it == mOthersList.end())
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << __PRETTY_FUNCTION__ << "cannot add address "
|
||||
<< "info, peer id: " << sslId << " not found in list"
|
||||
<< std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
changed = it->second.ipAddrs.updateLocalAddrs(ip);
|
||||
}
|
||||
|
||||
if (changed)
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << __PRETTY_FUNCTION__ << " Added locator: "
|
||||
<< locator.toString() << std::endl;
|
||||
#endif
|
||||
IndicateConfigChanged();
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::setLocalAddress( const RsPeerId &id,
|
||||
const sockaddr_storage &addr )
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
if (id == AuthSSL::getAuthSSL()->OwnId())
|
||||
{
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
RS_STACK_MUTEX(mPeerMtx);
|
||||
if (!sockaddr_storage_same(mOwnState.localaddr, addr))
|
||||
{
|
||||
mOwnState.localaddr = addr;
|
||||
|
@ -1388,7 +1435,7 @@ bool p3PeerMgrIMPL::setLocalAddress(const RsPeerId &id, const struct sockaddr
|
|||
return changed;
|
||||
}
|
||||
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
RS_STACK_MUTEX(mPeerMtx);
|
||||
/* check if it is a friend */
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||
|
@ -1396,7 +1443,9 @@ bool p3PeerMgrIMPL::setLocalAddress(const RsPeerId &id, const struct sockaddr
|
|||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::setLocalAddress() cannot add addres info : peer id not found in friend list id: " << id << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::setLocalAddress() cannot add addres "
|
||||
<< "info : peer id not found in friend list id: "
|
||||
<< id << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
@ -1417,28 +1466,29 @@ bool p3PeerMgrIMPL::setLocalAddress(const RsPeerId &id, const struct sockaddr
|
|||
it->second.updateIpAddressList(ipAddressTimed);
|
||||
#endif
|
||||
|
||||
if (changed) {
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
}
|
||||
|
||||
if (changed) IndicateConfigChanged();
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::setExtAddress(const RsPeerId &id, const struct sockaddr_storage &addr)
|
||||
bool p3PeerMgrIMPL::setExtAddress( const RsPeerId &id,
|
||||
const sockaddr_storage &addr )
|
||||
{
|
||||
bool changed = false;
|
||||
uint32_t check_res = 0 ;
|
||||
bool changed = false;
|
||||
uint32_t check_res = 0;
|
||||
|
||||
if(rsBanList!=NULL && !rsBanList->isAddressAccepted(addr,RSBANLIST_CHECKING_FLAGS_BLACKLIST,&check_res))
|
||||
{
|
||||
std::cerr << "(SS) trying to set external contact address for peer " << id << " to a banned address " << sockaddr_storage_iptostring(addr )<< std::endl;
|
||||
return false ;
|
||||
}
|
||||
if( rsBanList!=NULL && !rsBanList->isAddressAccepted(
|
||||
addr, RSBANLIST_CHECKING_FLAGS_BLACKLIST, &check_res) )
|
||||
{
|
||||
std::cerr << "(SS) trying to set external contact address for peer "
|
||||
<< id << " to a banned address "
|
||||
<< sockaddr_storage_iptostring(addr) << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (id == AuthSSL::getAuthSSL()->OwnId())
|
||||
{
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
RS_STACK_MUTEX(mPeerMtx);
|
||||
if (!sockaddr_storage_same(mOwnState.serveraddr, addr))
|
||||
{
|
||||
mOwnState.serveraddr = addr;
|
||||
|
@ -1451,7 +1501,7 @@ bool p3PeerMgrIMPL::setExtAddress(const RsPeerId &id, const struct sockaddr_s
|
|||
return changed;
|
||||
}
|
||||
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
RS_STACK_MUTEX(mPeerMtx);
|
||||
/* check if it is a friend */
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||
|
@ -1459,7 +1509,9 @@ bool p3PeerMgrIMPL::setExtAddress(const RsPeerId &id, const struct sockaddr_s
|
|||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::setLocalAddress() cannot add addres info : peer id not found in friend list id: " << id << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::setLocalAddress() cannot add addres "
|
||||
<< "info : peer id not found in friend list id: " << id
|
||||
<< std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -159,6 +159,7 @@ virtual bool assignPeersToGroup(const RsNodeGroupId &groupId, const std::list
|
|||
* 3) p3disc - reasonable
|
||||
*/
|
||||
|
||||
virtual bool addPeerLocator(const RsPeerId &ssl_id, const RsUrl& locator) = 0;
|
||||
virtual bool setLocalAddress(const RsPeerId &id, const struct sockaddr_storage &addr) = 0;
|
||||
virtual bool setExtAddress(const RsPeerId &id, const struct sockaddr_storage &addr) = 0;
|
||||
virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns) = 0;
|
||||
|
@ -273,6 +274,7 @@ public:
|
|||
* 3) p3disc - reasonable
|
||||
*/
|
||||
|
||||
virtual bool addPeerLocator(const RsPeerId &ssl_id, const RsUrl& locator);
|
||||
virtual bool setLocalAddress(const RsPeerId &id, const struct sockaddr_storage &addr);
|
||||
virtual bool setExtAddress(const RsPeerId &id, const struct sockaddr_storage &addr);
|
||||
virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns);
|
||||
|
|
|
@ -223,6 +223,15 @@ int pqissludp::Initiate_Connection()
|
|||
return -1;
|
||||
}
|
||||
|
||||
if(!sockaddr_storage_ipv6_to_ipv4(remote_addr))
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << "Error: remote_addr is not "
|
||||
<< "valid IPv4!" << std::endl;
|
||||
sockaddr_storage_dump(remote_addr);
|
||||
print_stacktrace();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mTimeoutTS = time(NULL) + mConnectTimeout;
|
||||
//std::cerr << "Setting Connect Timeout " << mConnectTimeout << " Seconds into Future " << std::endl;
|
||||
//std::cerr << " Connect Period is:" << mConnectPeriod << std::endl;
|
||||
|
@ -250,32 +259,22 @@ int pqissludp::Initiate_Connection()
|
|||
struct sockaddr_in proxyaddr;
|
||||
struct sockaddr_in remoteaddr;
|
||||
|
||||
bool nonIpV4 = false;
|
||||
if(!sockaddr_storage_ipv6_to_ipv4(remote_addr))
|
||||
{
|
||||
nonIpV4 = true;
|
||||
std::cerr << __PRETTY_FUNCTION__ << "Error: remote_addr is not "
|
||||
<< "valid IPv4!" << std::endl;
|
||||
sockaddr_storage_dump(remote_addr);
|
||||
}
|
||||
if(!sockaddr_storage_ipv6_to_ipv4(mConnectSrcAddr))
|
||||
{
|
||||
nonIpV4 = true;
|
||||
std::cerr << __PRETTY_FUNCTION__ << "Error: mConnectSrcAddr is "
|
||||
<< "not valid IPv4!" << std::endl;
|
||||
sockaddr_storage_dump(mConnectSrcAddr);
|
||||
print_stacktrace();
|
||||
return -EINVAL;
|
||||
}
|
||||
if(!sockaddr_storage_ipv6_to_ipv4(mConnectProxyAddr))
|
||||
{
|
||||
nonIpV4 = true;
|
||||
std::cerr << __PRETTY_FUNCTION__ << "Error: mConnectProxyAddr "
|
||||
<< "is not valid IPv4!" << std::endl;
|
||||
sockaddr_storage_dump(mConnectProxyAddr);
|
||||
}
|
||||
if(!nonIpV4)
|
||||
{
|
||||
print_stacktrace();
|
||||
return -EINVAL;
|
||||
|
||||
}
|
||||
|
||||
struct sockaddr_in *rap = (struct sockaddr_in *) &remote_addr;
|
||||
|
@ -297,7 +296,6 @@ int pqissludp::Initiate_Connection()
|
|||
err = tou_connect_via_relay(sockfd, &srcaddr, &proxyaddr, &remoteaddr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*** It seems that the UDP Layer sees x 1.2 the traffic of the SSL layer.
|
||||
* We need to compensate somewhere... we drop the maximum traffic to 75% of limit
|
||||
|
|
|
@ -163,10 +163,9 @@ public:
|
|||
|
||||
class RsFiles
|
||||
{
|
||||
public:
|
||||
|
||||
RsFiles() { return; }
|
||||
virtual ~RsFiles() { return; }
|
||||
public:
|
||||
RsFiles() {}
|
||||
virtual ~RsFiles() {}
|
||||
|
||||
/**
|
||||
* Provides file data for the gui: media streaming or rpc clients.
|
||||
|
|
|
@ -40,8 +40,8 @@ class RsGxsChanges
|
|||
public:
|
||||
RsGxsChanges(): mService(0){}
|
||||
RsTokenService *mService;
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > mMsgs;
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > mMsgsMeta;
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > mMsgs;
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > mMsgsMeta;
|
||||
std::list<RsGxsGroupId> mGrps;
|
||||
std::list<RsGxsGroupId> mGrpsMeta;
|
||||
};
|
||||
|
|
|
@ -38,10 +38,10 @@ typedef Sha1CheckSum RsGxsMessageId;
|
|||
typedef GXSId RsGxsId;
|
||||
typedef GXSCircleId RsGxsCircleId;
|
||||
|
||||
typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgIdResult;
|
||||
typedef std::map<RsGxsGroupId, std::set<RsGxsMessageId> > GxsMsgIdResult;
|
||||
typedef std::pair<RsGxsGroupId, RsGxsMessageId> RsGxsGrpMsgIdPair;
|
||||
typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsGxsMessageId> > MsgRelatedIdResult;
|
||||
typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgReq;
|
||||
typedef std::map<RsGxsGrpMsgIdPair, std::set<RsGxsMessageId> > MsgRelatedIdResult;
|
||||
typedef std::map<RsGxsGroupId, std::set<RsGxsMessageId> > GxsMsgReq;
|
||||
|
||||
struct RsMsgMetaData;
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ class RsGxsMsgChange : public RsGxsNotify
|
|||
{
|
||||
public:
|
||||
RsGxsMsgChange(NotifyType type, bool metaChange) : NOTIFY_TYPE(type), mMetaChange(metaChange) {}
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgChangeMap;
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgChangeMap;
|
||||
NotifyType getType(){ return NOTIFY_TYPE;}
|
||||
bool metaChange() { return mMetaChange; }
|
||||
private:
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <retroshare/rstypes.h>
|
||||
#include <retroshare/rsfiles.h>
|
||||
#include <retroshare/rsids.h>
|
||||
#include "util/rsurl.h"
|
||||
|
||||
/* The Main Interface Class - for information about your Peers
|
||||
* A peer is another RS instance, means associated with an SSL certificate
|
||||
|
@ -366,6 +367,7 @@ public:
|
|||
virtual bool setHiddenNode(const RsPeerId &id, const std::string &address, uint16_t port) = 0;
|
||||
virtual bool isHiddenNode(const RsPeerId &id) = 0;
|
||||
|
||||
virtual bool addPeerLocator(const RsPeerId &ssl_id, const RsUrl& locator) = 0;
|
||||
virtual bool setLocalAddress(const RsPeerId &ssl_id, const std::string &addr, uint16_t port) = 0;
|
||||
virtual bool setExtAddress( const RsPeerId &ssl_id, const std::string &addr, uint16_t port) = 0;
|
||||
virtual bool setDynDNS(const RsPeerId &id, const std::string &addr) = 0;
|
||||
|
@ -380,11 +382,30 @@ public:
|
|||
virtual bool resetOwnExternalAddressList() = 0;
|
||||
virtual bool getAllowServerIPDetermination() = 0 ;
|
||||
|
||||
/**
|
||||
* @brief Get RetroShare invite of the given peer
|
||||
* @param[in] sslId Id of the peer of which we want to generate an invite
|
||||
* @param[in] includeSignatures true to add key signatures to the invite
|
||||
* @param[in] includeExtraLocators false to avoid to add extra locators
|
||||
* @return invite string
|
||||
*/
|
||||
virtual std::string GetRetroshareInvite(
|
||||
const RsPeerId& sslId, bool includeSignatures = false,
|
||||
bool includeExtraLocators = true ) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get RetroShare invite of our own peer
|
||||
* @param[in] includeSignatures true to add key signatures to the invite
|
||||
* @param[in] includeExtraLocators false to avoid to add extra locators
|
||||
* @return invite string
|
||||
*/
|
||||
virtual std::string GetRetroshareInvite(
|
||||
bool includeSignatures = false,
|
||||
bool includeExtraLocators = true ) = 0;
|
||||
|
||||
/* Auth Stuff */
|
||||
virtual std::string GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures) = 0;
|
||||
virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures) = 0;
|
||||
virtual bool GetPGPBase64StringAndCheckSum(const RsPgpId& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum) = 0;
|
||||
virtual std::string GetRetroshareInvite(bool include_signatures) = 0;
|
||||
virtual bool hasExportMinimal() = 0;
|
||||
|
||||
// Add keys to the keyring
|
||||
|
|
|
@ -57,14 +57,17 @@
|
|||
|
||||
/* TODO CLEANUP: RS_TOKREQ_ANSTYPE_* values are meaningless and not used by
|
||||
* RsTokenService or its implementation, and may be arbitrarly defined by each
|
||||
* GXS client as they are of no usage, their use is deprecated */
|
||||
* GXS client as they are of no usage, their use is deprecated, up until the
|
||||
* definitive cleanup is done new code must use RS_DEPRECATED_TOKREQ_ANSTYPE for
|
||||
* easier cleanup. */
|
||||
#ifndef RS_NO_WARN_DEPRECATED
|
||||
# warning RS_TOKREQ_ANSTYPE_* macros are deprecated!
|
||||
#endif
|
||||
#define RS_TOKREQ_ANSTYPE_LIST 0x0001
|
||||
#define RS_TOKREQ_ANSTYPE_SUMMARY 0x0002
|
||||
#define RS_TOKREQ_ANSTYPE_DATA 0x0003
|
||||
#define RS_TOKREQ_ANSTYPE_ACK 0x0004
|
||||
#define RS_DEPRECATED_TOKREQ_ANSTYPE 0x0000
|
||||
#define RS_TOKREQ_ANSTYPE_LIST 0x0001
|
||||
#define RS_TOKREQ_ANSTYPE_SUMMARY 0x0002
|
||||
#define RS_TOKREQ_ANSTYPE_DATA 0x0003
|
||||
#define RS_TOKREQ_ANSTYPE_ACK 0x0004
|
||||
|
||||
|
||||
/*!
|
||||
|
|
|
@ -57,24 +57,23 @@ void RsGxsPhotoAlbumItem::serial_process(RsGenericSerializer::SerializeJob j,RsG
|
|||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_LOCATION, album.mWhere, "mWhere");
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_PIC_TYPE, album.mThumbnail.type,"mThumbnail.type");
|
||||
|
||||
RsTlvBinaryDataRef b(RS_SERVICE_GXS_TYPE_PHOTO, album.mThumbnail.data,album.mThumbnail.size);
|
||||
|
||||
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,b,"thumbnail binary data") ;
|
||||
RsTlvBinaryDataRef b(RS_SERVICE_GXS_TYPE_PHOTO, album.mThumbnail.data, album.mThumbnail.size);
|
||||
RsTypeSerializer::serial_process<RsTlvItem>(j, ctx, b, "thumbnail binary data") ;
|
||||
}
|
||||
void RsGxsPhotoPhotoItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_CAPTION, photo.mCaption);
|
||||
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_CATEGORY, photo.mCategory);
|
||||
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_DESCR, photo.mDescription);
|
||||
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_HASH_TAG, photo.mHashTags);
|
||||
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_MSG, photo.mOther);
|
||||
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_PIC_AUTH, photo.mPhotographer);
|
||||
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_DATE, photo.mWhen);
|
||||
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_LOCATION, photo.mWhere);
|
||||
RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_PIC_TYPE, photo.mThumbnail.type);
|
||||
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_CAPTION, photo.mCaption, "mCaption");
|
||||
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_CATEGORY, photo.mCategory, "mCategory");
|
||||
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_DESCR, photo.mDescription, "mDescription");
|
||||
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_HASH_TAG, photo.mHashTags, "mHashTags");
|
||||
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_MSG, photo.mOther, "mOther");
|
||||
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_PIC_AUTH, photo.mPhotographer, "mPhotographer");
|
||||
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_DATE, photo.mWhen, "mWhen");
|
||||
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_LOCATION, photo.mWhere, "mWhere");
|
||||
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_PIC_TYPE, photo.mThumbnail.type, "mThumbnail.type");
|
||||
|
||||
RsTlvBinaryDataRef b(RS_SERVICE_GXS_TYPE_PHOTO,photo.mThumbnail.data, photo.mThumbnail.size);
|
||||
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx, b, "mThumbnail") ;
|
||||
RsTlvBinaryDataRef b(RS_SERVICE_GXS_TYPE_PHOTO, photo.mThumbnail.data, photo.mThumbnail.size);
|
||||
RsTypeSerializer::serial_process<RsTlvItem>(j, ctx, b, "mThumbnail") ;
|
||||
}
|
||||
void RsGxsPhotoCommentItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
virtual ~RsGxsPhotoAlbumItem() { return;}
|
||||
|
||||
void clear();
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
// std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
|
|
|
@ -332,8 +332,8 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
|||
if(!sockaddr_storage_isnull(ps.localaddr))
|
||||
{
|
||||
sockaddr_storage_ipv6_to_ipv4(ps.localaddr);
|
||||
d.localAddr = sockaddr_storage_iptostring(ps.localaddr);
|
||||
d.localPort = sockaddr_storage_port(ps.localaddr);
|
||||
d.localAddr = sockaddr_storage_iptostring(ps.localaddr);
|
||||
d.localPort = sockaddr_storage_port(ps.localaddr);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -900,6 +900,9 @@ bool p3Peers::setHiddenNode(const RsPeerId &id, const std::string &address, uin
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3Peers::addPeerLocator(const RsPeerId &ssl_id, const RsUrl& locator)
|
||||
{ return mPeerMgr->addPeerLocator(ssl_id, locator); }
|
||||
|
||||
bool p3Peers::setLocalAddress(const RsPeerId &id,
|
||||
const std::string &addr_str, uint16_t port)
|
||||
{
|
||||
|
@ -1041,9 +1044,11 @@ bool p3Peers::setProxyServer(const uint32_t type, const std::string &addr_str, c
|
|||
|
||||
//===========================================================================
|
||||
/* Auth Stuff */
|
||||
std::string p3Peers::GetRetroshareInvite(bool include_signatures)
|
||||
std::string p3Peers::GetRetroshareInvite(
|
||||
bool include_signatures, bool includeExtraLocators )
|
||||
{
|
||||
return GetRetroshareInvite(getOwnId(),include_signatures);
|
||||
return GetRetroshareInvite(
|
||||
getOwnId(), include_signatures, includeExtraLocators );
|
||||
}
|
||||
std::string p3Peers::getPGPKey(const RsPgpId& pgp_id,bool include_signatures)
|
||||
{
|
||||
|
@ -1094,37 +1099,42 @@ bool p3Peers::GetPGPBase64StringAndCheckSum( const RsPgpId& gpg_id,
|
|||
return true ;
|
||||
}
|
||||
|
||||
std::string p3Peers::GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures)
|
||||
std::string p3Peers::GetRetroshareInvite(
|
||||
const RsPeerId& ssl_id, bool include_signatures,
|
||||
bool includeExtraLocators )
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::GetRetroshareInvite()" << std::endl;
|
||||
std::cerr << __PRETTY_FUNCTION__ << std::endl;
|
||||
#endif
|
||||
|
||||
//add the sslid, location, ip local and external address after the signature
|
||||
RsPeerDetails Detail;
|
||||
std::string invite ;
|
||||
RsPeerDetails detail;
|
||||
std::string invite;
|
||||
|
||||
if (getPeerDetails(ssl_id, Detail))
|
||||
if (getPeerDetails(ssl_id, detail))
|
||||
{
|
||||
unsigned char *mem_block = NULL;
|
||||
if(!includeExtraLocators) detail.ipAddressList.clear();
|
||||
|
||||
unsigned char *mem_block = nullptr;
|
||||
size_t mem_block_size = 0;
|
||||
|
||||
if(!AuthGPG::getAuthGPG()->exportPublicKey(RsPgpId(Detail.gpg_id),mem_block,mem_block_size,false,include_signatures))
|
||||
if(!AuthGPG::getAuthGPG()->exportPublicKey(
|
||||
RsPgpId(detail.gpg_id), mem_block, mem_block_size, false,
|
||||
include_signatures ))
|
||||
{
|
||||
std::cerr << "Cannot output certificate for id \"" << Detail.gpg_id << "\". Sorry." << std::endl;
|
||||
return "" ;
|
||||
std::cerr << "Cannot output certificate for id \"" << detail.gpg_id
|
||||
<< "\". Sorry." << std::endl;
|
||||
return "";
|
||||
}
|
||||
|
||||
RsCertificate cert( Detail,mem_block,mem_block_size ) ;
|
||||
|
||||
delete[] mem_block ;
|
||||
|
||||
return cert.toStdString() ;
|
||||
RsCertificate cert(detail, mem_block, mem_block_size);
|
||||
delete[] mem_block;
|
||||
|
||||
return cert.toStdString();
|
||||
}
|
||||
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::GetRetroshareInvite() returns : \n" << invite << std::endl;
|
||||
std::cerr << __PRETTY_FUNCTION__ << " returns : \n" << invite << std::endl;
|
||||
#endif
|
||||
return invite;
|
||||
}
|
||||
|
@ -1144,11 +1154,12 @@ bool p3Peers::loadCertificateFromString(const std::string& cert, RsPeerId& ssl_
|
|||
return res ;
|
||||
}
|
||||
|
||||
bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetails &pd,uint32_t& error_code)
|
||||
bool p3Peers::loadDetailsFromStringCert( const std::string &certstr,
|
||||
RsPeerDetails &pd,
|
||||
uint32_t& error_code )
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::LoadCertificateFromString() ";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3Peers::LoadCertificateFromString() " << std::endl;
|
||||
#endif
|
||||
//parse the text to get ip address
|
||||
try
|
||||
|
@ -1188,9 +1199,11 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai
|
|||
pd.localPort = cert.loc_port_us();
|
||||
pd.extAddr = cert.ext_ip_string();
|
||||
pd.extPort = cert.ext_port_us();
|
||||
pd.dyndns = cert.dns_string() ;
|
||||
pd.dyndns = cert.dns_string();
|
||||
for(const RsUrl& locator : cert.locators())
|
||||
pd.ipAddressList.push_back(locator.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(uint32_t e)
|
||||
{
|
||||
std::cerr << "ConnectFriendWizard : Parse ip address error :" << e << std::endl;
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#endif
|
||||
|
||||
#include "retroshare/rspeers.h"
|
||||
#include "util/rsurl.h"
|
||||
|
||||
class p3LinkMgr;
|
||||
class p3PeerMgr;
|
||||
|
@ -91,7 +92,8 @@ public:
|
|||
virtual bool setHiddenNode(const RsPeerId &id, const std::string &address, uint16_t port);
|
||||
virtual bool isHiddenNode(const RsPeerId &id);
|
||||
|
||||
virtual bool setLocalAddress(const RsPeerId &id, const std::string &addr, uint16_t port);
|
||||
virtual bool addPeerLocator(const RsPeerId &ssl_id, const RsUrl& locator);
|
||||
virtual bool setLocalAddress(const RsPeerId &id, const std::string &addr, uint16_t port);
|
||||
virtual bool setExtAddress(const RsPeerId &id, const std::string &addr, uint16_t port);
|
||||
virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns);
|
||||
virtual bool setNetworkMode(const RsPeerId &id, uint32_t netMode);
|
||||
|
@ -108,11 +110,15 @@ public:
|
|||
|
||||
/* Auth Stuff */
|
||||
// Get the invitation (GPG cert + local/ext address + SSL id for the given peer)
|
||||
virtual std::string GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures);
|
||||
virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures) ;
|
||||
virtual std::string GetRetroshareInvite(
|
||||
const RsPeerId& ssl_id, bool include_signatures = false,
|
||||
bool includeExtraLocators = true );
|
||||
virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures);
|
||||
|
||||
// same but for own id
|
||||
virtual std::string GetRetroshareInvite(bool include_signatures);
|
||||
virtual std::string GetRetroshareInvite(
|
||||
bool include_signatures = false,
|
||||
bool includeExtraLocators = true );
|
||||
virtual bool GetPGPBase64StringAndCheckSum(const RsPgpId& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum);
|
||||
|
||||
virtual bool hasExportMinimal();
|
||||
|
|
|
@ -1348,11 +1348,11 @@ int RsServer::StartupRetroShare()
|
|||
|
||||
p3Wiki *mWiki = new p3Wiki(wiki_ds, NULL, mGxsIdService);
|
||||
// create GXS wiki service
|
||||
RsGxsNetService* wiki_ns = new RsGxsNetService(
|
||||
RS_SERVICE_GXS_TYPE_WIKI, wiki_ds, nxsMgr,
|
||||
mWiki, mWiki->getServiceInfo(),
|
||||
mGxsIdService, mGxsCircles,
|
||||
pgpAuxUtils);
|
||||
RsGxsNetService* wiki_ns = new RsGxsNetService(
|
||||
RS_SERVICE_GXS_TYPE_WIKI, wiki_ds, nxsMgr,
|
||||
mWiki, mWiki->getServiceInfo(),
|
||||
mReputations, mGxsCircles, mGxsIdService,
|
||||
pgpAuxUtils);
|
||||
|
||||
mWiki->setNetworkExchangeService(wiki_ns) ;
|
||||
#endif
|
||||
|
|
|
@ -222,6 +222,13 @@ struct RsGenericSerializer : RsSerialType
|
|||
/** Allow shared allocator usage to avoid costly JSON deepcopy for
|
||||
* nested RsSerializable */
|
||||
SerializeContext(
|
||||
uint8_t *data, uint32_t size,
|
||||
SerializationFlags flags = SERIALIZATION_FLAG_NONE,
|
||||
RsJson::AllocatorType* allocator = nullptr) :
|
||||
mData(data), mSize(size), mOffset(0), mOk(true), mFlags(flags),
|
||||
mJson(rapidjson::kObjectType, allocator) {}
|
||||
|
||||
RS_DEPRECATED SerializeContext(
|
||||
uint8_t *data, uint32_t size, SerializationFormat format,
|
||||
SerializationFlags flags,
|
||||
RsJson::AllocatorType* allocator = nullptr) :
|
||||
|
|
|
@ -288,8 +288,8 @@ bool RsTypeSerializer::from_JSON( const std::string& memberName,
|
|||
uint64_t& member, RsJson& jDoc )
|
||||
{
|
||||
SAFE_GET_JSON_V();
|
||||
ret = ret && v.IsUint();
|
||||
if(ret) member = v.GetUint();
|
||||
ret = ret && v.IsUint64();
|
||||
if(ret) member = v.GetUint64();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -214,8 +214,7 @@ RsGenExchange::ServiceCreate_Return p3GxsChannels::service_CreateGroup(RsGxsGrpI
|
|||
void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||
{
|
||||
#ifdef GXSCHANNELS_DEBUG
|
||||
std::cerr << "p3GxsChannels::notifyChanges()";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3GxsChannels::notifyChanges() : " << changes.size() << "changes to notify" << std::endl;
|
||||
#endif
|
||||
|
||||
p3Notify *notify = NULL;
|
||||
|
@ -238,16 +237,12 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
/* message received */
|
||||
if (notify)
|
||||
{
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit;
|
||||
for (mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
{
|
||||
std::vector<RsGxsMessageId>::iterator mit1;
|
||||
for (mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -258,9 +253,8 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit;
|
||||
for(mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
for(auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
{
|
||||
#ifdef GXSCHANNELS_DEBUG
|
||||
std::cerr << "p3GxsChannels::notifyChanges() Msgs for Group: " << mit->first;
|
||||
|
@ -804,10 +798,7 @@ void p3GxsChannels::request_SpecificUnprocessedPosts(std::list<std::pair<RsGxsGr
|
|||
GxsMsgReq msgIds;
|
||||
std::list<std::pair<RsGxsGroupId, RsGxsMessageId> >::iterator it;
|
||||
for(it = ids.begin(); it != ids.end(); ++it)
|
||||
{
|
||||
std::vector<RsGxsMessageId> &vect_msgIds = msgIds[it->first];
|
||||
vect_msgIds.push_back(it->second);
|
||||
}
|
||||
msgIds[it->first].insert(it->second);
|
||||
|
||||
RsGenExchange::getTokenService()->requestMsgInfo(token, ansType, opts, msgIds);
|
||||
GxsTokenQueue::queueRequest(token, GXSCHANNELS_UNPROCESSED_SPECIFIC);
|
||||
|
|
|
@ -208,14 +208,14 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
#ifdef DEBUG_CIRCLES
|
||||
std::cerr << " Found circle Message Change Notification" << std::endl;
|
||||
#endif
|
||||
for(std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit = msgChange->msgChangeMap.begin(); mit != msgChange->msgChangeMap.end(); ++mit)
|
||||
for(auto mit = msgChange->msgChangeMap.begin(); mit != msgChange->msgChangeMap.end(); ++mit)
|
||||
{
|
||||
#ifdef DEBUG_CIRCLES
|
||||
std::cerr << " Msgs for Group: " << mit->first << std::endl;
|
||||
#endif
|
||||
force_cache_reload(RsGxsCircleId(mit->first));
|
||||
if (notify && (c->getType() == RsGxsNotify::TYPE_RECEIVE) )
|
||||
for (std::vector<RsGxsMessageId>::const_iterator msgIdIt(mit->second.begin()), end(mit->second.end()); msgIdIt != end; ++msgIdIt)
|
||||
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());
|
||||
|
@ -2116,7 +2116,7 @@ bool p3GxsCircles::processMembershipRequests(uint32_t token)
|
|||
#ifdef DEBUG_CIRCLES
|
||||
std::cerr << " Older than last known (" << time(NULL)-info.last_subscription_TS << " seconds ago): deleting." << std::endl;
|
||||
#endif
|
||||
messages_to_delete[RsGxsGroupId(cid)].push_back(it->second[i]->meta.mMsgId) ;
|
||||
messages_to_delete[RsGxsGroupId(cid)].insert(it->second[i]->meta.mMsgId) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -498,8 +498,8 @@ bool p3GxsCommentService::createGxsVote(uint32_t &token, RsGxsVote &vote)
|
|||
opts.mReqType = GXS_REQUEST_TYPE_MSG_META;
|
||||
|
||||
GxsMsgReq msgIds;
|
||||
std::vector<RsGxsMessageId> &vect_msgIds = msgIds[parentId.first];
|
||||
vect_msgIds.push_back(parentId.second);
|
||||
std::set<RsGxsMessageId> &vect_msgIds = msgIds[parentId.first];
|
||||
vect_msgIds.insert(parentId.second);
|
||||
|
||||
uint32_t int_token;
|
||||
mExchange->getTokenService()->requestMsgInfo(int_token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, msgIds);
|
||||
|
|
|
@ -201,15 +201,12 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange*>(c);
|
||||
if (msgChange)
|
||||
{
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit;
|
||||
for (mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
|
||||
for (auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
{
|
||||
std::vector<RsGxsMessageId>::iterator mit1;
|
||||
for (mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
||||
{
|
||||
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
||||
notify->AddFeedItem(RS_FEED_ITEM_FORUM_MSG, mit->first.toStdString(), mit1->toStdString());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -558,8 +558,8 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit;
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> >::iterator mit;
|
||||
for(mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
{
|
||||
#ifdef DEBUG_IDS
|
||||
|
|
|
@ -106,9 +106,8 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit;
|
||||
for(mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
for(auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
{
|
||||
#ifdef POSTBASE_DEBUG
|
||||
std::cerr << "p3PostBase::notifyChanges() Msgs for Group: " << mit->first;
|
||||
|
@ -121,8 +120,7 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
|
||||
if (notify && msgChange->getType() == RsGxsNotify::TYPE_RECEIVE)
|
||||
{
|
||||
std::vector<RsGxsMessageId>::iterator mit1;
|
||||
for (mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
||||
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
||||
{
|
||||
notify->AddFeedItem(RS_FEED_ITEM_POSTED_MSG, mit->first.toStdString(), mit1->toStdString());
|
||||
}
|
||||
|
@ -427,7 +425,7 @@ void p3PostBase::background_loadMsgs(const uint32_t &token, bool unprocessed)
|
|||
mBgIncremental = unprocessed;
|
||||
}
|
||||
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > postMap;
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > postMap;
|
||||
|
||||
// generate vector of changes to push to the GUI.
|
||||
std::vector<RsGxsNotify *> changes;
|
||||
|
@ -483,7 +481,7 @@ void p3PostBase::background_loadMsgs(const uint32_t &token, bool unprocessed)
|
|||
#endif
|
||||
|
||||
/* but we need to notify GUI about them */
|
||||
msgChanges->msgChangeMap[mit->first].push_back((*vit)->meta.mMsgId);
|
||||
msgChanges->msgChangeMap[mit->first].insert((*vit)->meta.mMsgId);
|
||||
}
|
||||
else if (NULL != (commentItem = dynamic_cast<RsGxsCommentItem *>(*vit)))
|
||||
{
|
||||
|
@ -542,7 +540,7 @@ void p3PostBase::background_loadMsgs(const uint32_t &token, bool unprocessed)
|
|||
if (sit == mBgStatsMap.end())
|
||||
{
|
||||
// add to map of ones to update.
|
||||
postMap[groupId].push_back(threadId);
|
||||
postMap[groupId].insert(threadId);
|
||||
|
||||
mBgStatsMap[threadId] = PostStats(0,0,0);
|
||||
sit = mBgStatsMap.find(threadId);
|
||||
|
@ -700,7 +698,7 @@ void p3PostBase::background_updateVoteCounts(const uint32_t &token)
|
|||
#endif
|
||||
|
||||
stats.increment(it->second);
|
||||
msgChanges->msgChangeMap[mit->first].push_back(vit->mMsgId);
|
||||
msgChanges->msgChangeMap[mit->first].insert(vit->mMsgId);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -30,6 +30,11 @@ bitdht {
|
|||
!include("../../libbitdht/src/use_libbitdht.pri"):error("Including")
|
||||
}
|
||||
|
||||
# when rapidjson is mainstream on all distribs, we will not need the sources
|
||||
# anymore in the meantime, they are part of the RS directory so that it is
|
||||
# always possible to find them
|
||||
INCLUDEPATH *= $$system_path($$clean_path($${PWD}/../../rapidjson-1.1.0))
|
||||
|
||||
sLibs =
|
||||
mLibs = $$RS_SQL_LIB ssl crypto $$RS_THREAD_LIB $$RS_UPNP_LIB
|
||||
dLibs =
|
||||
|
|
|
@ -138,6 +138,7 @@ bool sockaddr_storage_sameip(const struct sockaddr_storage &addr, const struct s
|
|||
|
||||
// string,
|
||||
std::string sockaddr_storage_tostring(const struct sockaddr_storage &addr);
|
||||
bool sockaddr_storage_fromString(const std::string& str, sockaddr_storage &addr);
|
||||
std::string sockaddr_storage_familytostring(const struct sockaddr_storage &addr);
|
||||
std::string sockaddr_storage_iptostring(const struct sockaddr_storage &addr);
|
||||
std::string sockaddr_storage_porttostring(const struct sockaddr_storage &addr);
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#include "util/rsurl.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <cstdlib>
|
||||
|
@ -187,8 +189,7 @@ bool sockaddr_storage_copyip(struct sockaddr_storage &dst, const struct sockaddr
|
|||
uint16_t sockaddr_storage_port(const struct sockaddr_storage &addr)
|
||||
{
|
||||
#ifdef SS_DEBUG
|
||||
std::cerr << "sockaddr_storage_port()";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "sockaddr_storage_port()" << std::endl;
|
||||
#endif
|
||||
switch(addr.ss_family)
|
||||
{
|
||||
|
@ -198,8 +199,10 @@ uint16_t sockaddr_storage_port(const struct sockaddr_storage &addr)
|
|||
return sockaddr_storage_ipv6_port(addr);
|
||||
default:
|
||||
std::cerr << "sockaddr_storage_port() invalid addr.ss_family" << std::endl;
|
||||
#ifdef SS_DEBUG
|
||||
sockaddr_storage_dump(addr);
|
||||
print_stacktrace();
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
@ -488,27 +491,32 @@ bool sockaddr_storage_sameip(const struct sockaddr_storage &addr, const struct s
|
|||
|
||||
std::string sockaddr_storage_tostring(const struct sockaddr_storage &addr)
|
||||
{
|
||||
std::string output;
|
||||
output += sockaddr_storage_familytostring(addr);
|
||||
RsUrl url;
|
||||
|
||||
switch(addr.ss_family)
|
||||
{
|
||||
case AF_INET:
|
||||
output += "=";
|
||||
output += sockaddr_storage_iptostring(addr);
|
||||
output += ":";
|
||||
output += sockaddr_storage_porttostring(addr);
|
||||
url.setScheme("ipv4");
|
||||
break;
|
||||
case AF_INET6:
|
||||
output += "=[";
|
||||
output += sockaddr_storage_iptostring(addr);
|
||||
output += "]:";
|
||||
output += sockaddr_storage_porttostring(addr);
|
||||
url.setScheme("ipv6");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
return "AF_INVALID";
|
||||
}
|
||||
return output;
|
||||
|
||||
url.setHost(sockaddr_storage_iptostring(addr))
|
||||
.setPort(sockaddr_storage_port(addr));
|
||||
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
bool sockaddr_storage_fromString(const std::string& str, sockaddr_storage &addr)
|
||||
{
|
||||
RsUrl url(str);
|
||||
bool valid = sockaddr_storage_inet_pton(addr, url.host());
|
||||
if(url.hasPort()) sockaddr_storage_setport(addr, url.port());
|
||||
return valid;
|
||||
}
|
||||
|
||||
void sockaddr_storage_dump(const sockaddr_storage & addr, std::string * outputString)
|
||||
|
@ -603,9 +611,11 @@ std::string sockaddr_storage_iptostring(const struct sockaddr_storage &addr)
|
|||
break;
|
||||
default:
|
||||
output = "INVALID_IP";
|
||||
std::cerr << __PRETTY_FUNCTION__ << " Got invalid IP:" << std::endl;
|
||||
std::cerr << __PRETTY_FUNCTION__ << " Got invalid IP!" << std::endl;
|
||||
#ifdef SS_DEBUG
|
||||
sockaddr_storage_dump(addr);
|
||||
print_stacktrace();
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
return output;
|
||||
|
|
267
libretroshare/src/util/rsurl.cc
Normal file
267
libretroshare/src/util/rsurl.cc
Normal file
|
@ -0,0 +1,267 @@
|
|||
/*
|
||||
* RetroShare
|
||||
* Copyright (C) 2018 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//#include "util/rsurl.h"
|
||||
#include "rsurl.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
RsUrl::RsUrl() : mPort(0), mHasPort(false) {}
|
||||
|
||||
RsUrl::RsUrl(const std::string& urlStr) : mPort(0), mHasPort(false)
|
||||
{ fromString(urlStr); }
|
||||
|
||||
RsUrl& RsUrl::fromString(const std::string& urlStr)
|
||||
{
|
||||
size_t endI = urlStr.size()-1;
|
||||
|
||||
size_t schemeEndI = urlStr.find(schemeSeparator);
|
||||
if(schemeEndI >= endI)
|
||||
{
|
||||
mScheme = urlStr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
mScheme = urlStr.substr(0, schemeEndI);
|
||||
|
||||
size_t hostBeginI = schemeEndI + 3;
|
||||
if(hostBeginI >= endI) return *this;
|
||||
|
||||
bool hasSquareBr = (urlStr[hostBeginI] == ipv6WrapOpen[0]);
|
||||
size_t hostEndI;
|
||||
if(hasSquareBr)
|
||||
{
|
||||
if(++hostBeginI >= endI) return *this;
|
||||
hostEndI = urlStr.find(ipv6WrapClose, hostBeginI);
|
||||
mHost = urlStr.substr(hostBeginI, hostEndI - hostBeginI - 1);
|
||||
++hostEndI;
|
||||
}
|
||||
else
|
||||
{
|
||||
hostEndI = urlStr.find(pathSeparator, hostBeginI);
|
||||
hostEndI = min(hostEndI, urlStr.find(portSeparator, hostBeginI));
|
||||
hostEndI = min(hostEndI, urlStr.find(querySeparator, hostBeginI));
|
||||
hostEndI = min(hostEndI, urlStr.find(fragmentSeparator, hostBeginI));
|
||||
|
||||
mHost = urlStr.substr(hostBeginI, hostEndI - hostBeginI);
|
||||
}
|
||||
|
||||
if( hostEndI >= endI ) return *this;
|
||||
|
||||
mHasPort = (sscanf(&urlStr[hostEndI], ":%hu", &mPort) == 1);
|
||||
|
||||
size_t pathBeginI = urlStr.find(pathSeparator, hostBeginI);
|
||||
size_t pathEndI = string::npos;
|
||||
if(pathBeginI < endI)
|
||||
{
|
||||
pathEndI = urlStr.find(querySeparator, pathBeginI);
|
||||
pathEndI = min(pathEndI, urlStr.find(fragmentSeparator, pathBeginI));
|
||||
mPath = UrlDecode(urlStr.substr(pathBeginI, pathEndI - pathBeginI));
|
||||
if(pathEndI >= endI) return *this;
|
||||
}
|
||||
|
||||
size_t queryBeginI = urlStr.find(querySeparator, hostBeginI);
|
||||
size_t queryEndI = urlStr.find(fragmentSeparator, hostBeginI);
|
||||
if(queryBeginI < endI)
|
||||
{
|
||||
string qStr = urlStr.substr(queryBeginI+1, queryEndI-queryBeginI-1);
|
||||
|
||||
size_t kPos = 0;
|
||||
size_t assPos = qStr.find(queryAssign);
|
||||
do
|
||||
{
|
||||
size_t vEndPos = qStr.find(queryFieldSep, assPos);
|
||||
mQuery.insert( std::make_pair( qStr.substr(kPos, assPos-kPos),
|
||||
UrlDecode(qStr.substr(assPos+1, vEndPos-assPos-1))
|
||||
) );
|
||||
kPos = vEndPos+1;
|
||||
assPos = qStr.find(queryAssign, vEndPos);
|
||||
}
|
||||
while(assPos < endI);
|
||||
|
||||
if(queryEndI >= endI) return *this;
|
||||
}
|
||||
|
||||
size_t fragmentBeginI = urlStr.find(fragmentSeparator, hostBeginI);
|
||||
if(fragmentBeginI < endI)
|
||||
mFragment = UrlDecode(urlStr.substr(++fragmentBeginI));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::string RsUrl::toString() const
|
||||
{
|
||||
std::string urlStr(mScheme);
|
||||
urlStr += schemeSeparator;
|
||||
|
||||
if(!mHost.empty())
|
||||
{
|
||||
if(mHost.find(ipv6Separator) != string::npos &&
|
||||
mHost[0] != ipv6WrapOpen[0] )
|
||||
urlStr += ipv6WrapOpen + mHost + ipv6WrapClose;
|
||||
else urlStr += mHost;
|
||||
}
|
||||
|
||||
if(mHasPort) urlStr += portSeparator + std::to_string(mPort);
|
||||
|
||||
urlStr += UrlEncode(mPath, pathSeparator);
|
||||
|
||||
bool hasQuery = !mQuery.empty();
|
||||
if(hasQuery) urlStr += querySeparator;
|
||||
for(auto&& kv : mQuery)
|
||||
{
|
||||
urlStr += kv.first;
|
||||
urlStr += queryAssign;
|
||||
urlStr += UrlEncode(kv.second);
|
||||
urlStr += queryFieldSep;
|
||||
}
|
||||
if(hasQuery) urlStr.pop_back();
|
||||
|
||||
if(!mFragment.empty()) urlStr += fragmentSeparator + UrlEncode(mFragment);
|
||||
|
||||
return urlStr;
|
||||
}
|
||||
|
||||
const std::string& RsUrl::scheme() const { return mScheme; }
|
||||
RsUrl& RsUrl::setScheme(const std::string& scheme)
|
||||
{
|
||||
mScheme = scheme;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const std::string& RsUrl::host() const { return mHost; }
|
||||
RsUrl& RsUrl::setHost(const std::string& host)
|
||||
{
|
||||
mHost = host;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool RsUrl::hasPort() const { return mHasPort; }
|
||||
uint16_t RsUrl::port(uint16_t def) const
|
||||
{
|
||||
if(mHasPort) return mPort;
|
||||
return def;
|
||||
}
|
||||
RsUrl& RsUrl::setPort(uint16_t port)
|
||||
{
|
||||
mPort = port;
|
||||
mHasPort = true;
|
||||
return *this;
|
||||
}
|
||||
RsUrl& RsUrl::unsetPort()
|
||||
{
|
||||
mPort = 0;
|
||||
mHasPort = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const std::string& RsUrl::path() const { return mPath; }
|
||||
RsUrl& RsUrl::setPath(const std::string& path)
|
||||
{
|
||||
mPath = path;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const std::map<std::string, std::string>& RsUrl::query() const
|
||||
{ return mQuery; }
|
||||
RsUrl& RsUrl::setQuery(const std::map<std::string, std::string>& query)
|
||||
{
|
||||
mQuery = query;
|
||||
return *this;
|
||||
}
|
||||
RsUrl& RsUrl::setQueryKV(const std::string& key, const std::string& value)
|
||||
{
|
||||
mQuery.insert(std::make_pair(key, value));
|
||||
return *this;
|
||||
}
|
||||
RsUrl& RsUrl::delQueryK(const std::string& key)
|
||||
{
|
||||
mQuery.erase(key);
|
||||
return *this;
|
||||
}
|
||||
|
||||
const std::string& RsUrl::fragment() const { return mFragment; }
|
||||
RsUrl& RsUrl::setFragment(const std::string& fragment)
|
||||
{
|
||||
mFragment = fragment;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*static*/ std::string RsUrl::UrlEncode( const std::string& str,
|
||||
const std::string& ignore )
|
||||
{
|
||||
ostringstream escaped;
|
||||
escaped.fill('0');
|
||||
escaped << hex;
|
||||
|
||||
for (string::value_type c : str)
|
||||
{
|
||||
// Keep alphanumeric and other accepted characters intact
|
||||
if ( isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~'
|
||||
|| ignore.find(c) != string::npos )
|
||||
{
|
||||
escaped << c;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Any other characters are percent-encoded
|
||||
escaped << uppercase;
|
||||
escaped << '%' << setw(2) << int((unsigned char) c);
|
||||
escaped << nouppercase;
|
||||
}
|
||||
|
||||
return escaped.str();
|
||||
}
|
||||
|
||||
/*static*/ std::string RsUrl::UrlDecode(const std::string& str)
|
||||
{
|
||||
ostringstream decoded;
|
||||
|
||||
size_t len = str.size();
|
||||
size_t boundary = len-2; // % Encoded char must be at least 2 hex char
|
||||
for (size_t i = 0; i < len; ++i)
|
||||
{
|
||||
|
||||
if(str[i] == '%' && i < boundary)
|
||||
{
|
||||
decoded << static_cast<char>(stoi(str.substr(++i, 2), 0, 16));
|
||||
++i;
|
||||
}
|
||||
else decoded << str[i];
|
||||
}
|
||||
|
||||
return decoded.str();
|
||||
}
|
||||
|
||||
/*static*/ const std::string RsUrl::schemeSeparator("://");
|
||||
/*static*/ const std::string RsUrl::ipv6WrapOpen("[");
|
||||
/*static*/ const std::string RsUrl::ipv6Separator(":");
|
||||
/*static*/ const std::string RsUrl::ipv6WrapClose("]");
|
||||
/*static*/ const std::string RsUrl::portSeparator(":");
|
||||
/*static*/ const std::string RsUrl::pathSeparator("/");
|
||||
/*static*/ const std::string RsUrl::querySeparator("?");
|
||||
/*static*/ const std::string RsUrl::queryAssign("=");
|
||||
/*static*/ const std::string RsUrl::queryFieldSep("&");
|
||||
/*static*/ const std::string RsUrl::fragmentSeparator("#");
|
||||
|
102
libretroshare/src/util/rsurl.h
Normal file
102
libretroshare/src/util/rsurl.h
Normal file
|
@ -0,0 +1,102 @@
|
|||
#pragma once
|
||||
/*
|
||||
* RetroShare
|
||||
* Copyright (C) 2018 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
/**
|
||||
* Very simplistic and minimal URL helper class for RetroShare, after looking
|
||||
* for a small and self-contained C/C++ URL parsing and manipulation library,
|
||||
* haven't found nothing satisfactory except for implementation like QUrl that
|
||||
* rely on bigger library.
|
||||
* ATM this implementation is not standard compliant and doesn't aim to be.
|
||||
* Improvements to this are welcome.
|
||||
*
|
||||
* Anyway this should support most common URLs of the form
|
||||
* scheme://host[:port][/path][?query][#fragment]
|
||||
*/
|
||||
struct RsUrl
|
||||
{
|
||||
RsUrl();
|
||||
RsUrl(const std::string& urlStr);
|
||||
|
||||
RsUrl& fromString(const std::string& urlStr);
|
||||
std::string toString() const;
|
||||
|
||||
const std::string& scheme() const;
|
||||
RsUrl& setScheme(const std::string& scheme);
|
||||
|
||||
const std::string& host() const;
|
||||
RsUrl& setHost(const std::string& host);
|
||||
|
||||
bool hasPort() const;
|
||||
uint16_t port(uint16_t def = 0) const;
|
||||
RsUrl& setPort(uint16_t port);
|
||||
RsUrl& unsetPort();
|
||||
|
||||
const std::string& path() const;
|
||||
RsUrl& setPath(const std::string& path);
|
||||
|
||||
const std::map<std::string, std::string>& query() const;
|
||||
RsUrl& setQuery(const std::map<std::string, std::string>& query);
|
||||
RsUrl& setQueryKV(const std::string& key, const std::string& value);
|
||||
RsUrl& delQueryK(const std::string& key);
|
||||
|
||||
const std::string& fragment() const;
|
||||
RsUrl& setFragment(const std::string& fragment);
|
||||
|
||||
static std::string UrlEncode(const std::string& str,
|
||||
const std::string& ignoreChars = "");
|
||||
static std::string UrlDecode(const std::string& str);
|
||||
|
||||
inline bool operator<(const RsUrl& rhs) const
|
||||
{ return toString() < rhs.toString(); }
|
||||
inline bool operator>(const RsUrl& rhs) const
|
||||
{ return toString() > rhs.toString(); }
|
||||
inline bool operator<=(const RsUrl& rhs) const
|
||||
{ return toString() <= rhs.toString(); }
|
||||
inline bool operator>=(const RsUrl& rhs) const
|
||||
{ return toString() >= rhs.toString(); }
|
||||
inline bool operator==(const RsUrl& rhs) const
|
||||
{ return toString() == rhs.toString(); }
|
||||
inline bool operator!=(const RsUrl& rhs) const
|
||||
{ return toString() != rhs.toString(); }
|
||||
|
||||
static const std::string schemeSeparator;
|
||||
static const std::string ipv6WrapOpen;
|
||||
static const std::string ipv6Separator;
|
||||
static const std::string ipv6WrapClose;
|
||||
static const std::string portSeparator;
|
||||
static const std::string pathSeparator;
|
||||
static const std::string querySeparator;
|
||||
static const std::string queryAssign;
|
||||
static const std::string queryFieldSep;
|
||||
static const std::string fragmentSeparator;
|
||||
|
||||
private:
|
||||
|
||||
std::string mScheme;
|
||||
std::string mHost;
|
||||
uint16_t mPort;
|
||||
bool mHasPort;
|
||||
std::string mPath;
|
||||
std::map<std::string, std::string> mQuery;
|
||||
std::string mFragment;
|
||||
};
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue