mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 22:25:04 -04:00
merged upstream/master
This commit is contained in:
commit
cecd9a3368
136 changed files with 5050 additions and 2182 deletions
|
@ -1273,6 +1273,58 @@ bool RsGenExchange::getMsgRelatedMeta(const uint32_t &token, GxsMsgRelatedMetaMa
|
|||
return ok;
|
||||
}
|
||||
|
||||
bool RsGenExchange::getSerializedGroupData(const uint32_t &token, RsGxsGroupId& id,unsigned char *& data,uint32_t& size)
|
||||
{
|
||||
RS_STACK_MUTEX(mGenMtx) ;
|
||||
|
||||
std::list<RsNxsGrp*> nxsGrps;
|
||||
|
||||
if(!mDataAccess->getGroupData(token, nxsGrps))
|
||||
return false ;
|
||||
|
||||
if(nxsGrps.size() != 1)
|
||||
{
|
||||
std::cerr << "(EE) getSerializedGroupData() got multiple groups in single request. This is unexpected." << std::endl;
|
||||
|
||||
for(std::list<RsNxsGrp*>::const_iterator it(nxsGrps.begin());it!=nxsGrps.end();++it)
|
||||
delete *it ;
|
||||
|
||||
return false ;
|
||||
}
|
||||
RsNxsGrp *nxs_grp = *(nxsGrps.begin());
|
||||
|
||||
size = nxs_grp->serial_size() ;
|
||||
id = nxs_grp->metaData->mGroupId ;
|
||||
|
||||
if(size > 1024*1024 || NULL==(data = (unsigned char *)rs_malloc(size)))
|
||||
{
|
||||
std::cerr << "(EE) getSerializedGroupData() cannot allocate mem chunk of size " << size << ". Too big, or no room." << std::endl;
|
||||
delete nxs_grp ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
return nxs_grp->serialise(data,size) ;
|
||||
}
|
||||
|
||||
bool RsGenExchange::deserializeGroupData(unsigned char *data,uint32_t size)
|
||||
{
|
||||
RS_STACK_MUTEX(mGenMtx) ;
|
||||
|
||||
RsItem *item = RsNxsSerialiser(mServType).deserialise(data, &size);
|
||||
|
||||
RsNxsGrp *nxs_grp = dynamic_cast<RsNxsGrp*>(item) ;
|
||||
|
||||
if(item == NULL)
|
||||
{
|
||||
std::cerr << "(EE) RsGenExchange::deserializeGroupData(): cannot deserialise this data. Something's wrong." << std::endl;
|
||||
delete item ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
mReceivedGrps.push_back( GxsPendingItem<RsNxsGrp*, RsGxsGroupId>(nxs_grp, nxs_grp->grpId,time(NULL)) );
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool RsGenExchange::getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem *>& grpItem)
|
||||
{
|
||||
|
|
|
@ -288,6 +288,20 @@ protected:
|
|||
*/
|
||||
bool getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem*>& grpItem);
|
||||
|
||||
/*!
|
||||
* \brief getSerializedGroupData
|
||||
* Retrieves the complete group data serialized into a chunk of memory. This can be useful to
|
||||
* transfer a full group from one machine to another.
|
||||
*
|
||||
* \param token token previously obtained from cache request
|
||||
* \param data memory chunk allocated (using malloc)
|
||||
* \param size size of the memory chunk.
|
||||
* \return
|
||||
*/
|
||||
|
||||
bool getSerializedGroupData(const uint32_t &token, RsGxsGroupId &id, unsigned char *& data, uint32_t& size);
|
||||
bool deserializeGroupData(unsigned char *data, uint32_t size);
|
||||
|
||||
template<class GrpType>
|
||||
bool getGroupDataT(const uint32_t &token, std::vector<GrpType*>& grpItem)
|
||||
{
|
||||
|
|
|
@ -33,8 +33,8 @@
|
|||
|
||||
#include "rsitems/rsgxsitems.h"
|
||||
|
||||
class RsGroupMetaData;
|
||||
class RsMsgMetaData;
|
||||
struct RsGroupMetaData;
|
||||
struct RsMsgMetaData;
|
||||
|
||||
static const uint32_t RS_GXS_GRP_META_DATA_VERSION_ID_0001 = 0x0000 ; // change this, and keep old values if the content changes
|
||||
static const uint32_t RS_GXS_GRP_META_DATA_VERSION_ID_0002 = 0xaf01 ; // current API
|
||||
|
|
|
@ -75,6 +75,12 @@ bool RsGxsDataAccess::requestGroupInfo(uint32_t &token, uint32_t ansType, const
|
|||
gir->mGroupIds = groupIds;
|
||||
req = gir;
|
||||
}
|
||||
else if(reqType & GXS_REQUEST_TYPE_GROUP_SERIALIZED_DATA)
|
||||
{
|
||||
GroupSerializedDataReq* gir = new GroupSerializedDataReq();
|
||||
gir->mGroupIds = groupIds;
|
||||
req = gir;
|
||||
}
|
||||
|
||||
if(req == NULL)
|
||||
{
|
||||
|
@ -103,34 +109,25 @@ bool RsGxsDataAccess::requestGroupInfo(uint32_t &token, uint32_t ansType, const
|
|||
uint32_t reqType = opts.mReqType;
|
||||
|
||||
if(reqType & GXS_REQUEST_TYPE_GROUP_META)
|
||||
{
|
||||
GroupMetaReq* gmr = new GroupMetaReq();
|
||||
req = gmr;
|
||||
}
|
||||
req = new GroupMetaReq();
|
||||
else if(reqType & GXS_REQUEST_TYPE_GROUP_DATA)
|
||||
{
|
||||
GroupDataReq* gdr = new GroupDataReq();
|
||||
req = gdr;
|
||||
}
|
||||
req = new GroupDataReq();
|
||||
else if(reqType & GXS_REQUEST_TYPE_GROUP_IDS)
|
||||
{
|
||||
GroupIdReq* gir = new GroupIdReq();
|
||||
req = gir;
|
||||
}
|
||||
|
||||
if(req == NULL)
|
||||
req = new GroupIdReq();
|
||||
else if(reqType & GXS_REQUEST_TYPE_GROUP_SERIALIZED_DATA)
|
||||
req = new GroupSerializedDataReq();
|
||||
else
|
||||
{
|
||||
std::cerr << "RsGxsDataAccess::requestGroupInfo() request type not recognised, type "
|
||||
<< reqType << std::endl;
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
generateToken(token);
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << "RsGxsDataAccess::requestGroupInfo() gets Token: " << token << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
generateToken(token);
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << "RsGxsDataAccess::requestGroupInfo() gets Token: " << token << std::endl;
|
||||
#endif
|
||||
|
||||
setReq(req, token, ansType, opts);
|
||||
storeRequest(req);
|
||||
|
||||
|
@ -430,7 +427,16 @@ bool RsGxsDataAccess::getGroupData(const uint32_t& token, std::list<RsNxsGrp*>&
|
|||
else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||
{
|
||||
GroupDataReq* gmreq = dynamic_cast<GroupDataReq*>(req);
|
||||
if(gmreq)
|
||||
GroupSerializedDataReq* gsreq = dynamic_cast<GroupSerializedDataReq*>(req);
|
||||
|
||||
if(gsreq)
|
||||
{
|
||||
grpData.swap(gsreq->mGroupData);
|
||||
gsreq->mGroupData.clear();
|
||||
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
}
|
||||
else if(gmreq)
|
||||
{
|
||||
grpData.swap(gmreq->mGroupData);
|
||||
gmreq->mGroupData.clear();
|
||||
|
@ -804,6 +810,7 @@ void RsGxsDataAccess::processRequests()
|
|||
MsgIdReq* mir;
|
||||
MsgRelatedInfoReq* mri;
|
||||
GroupStatisticRequest* gsr;
|
||||
GroupSerializedDataReq* grr;
|
||||
ServiceStatisticRequest* ssr;
|
||||
|
||||
#ifdef DATA_DEBUG
|
||||
|
@ -851,6 +858,11 @@ void RsGxsDataAccess::processRequests()
|
|||
{
|
||||
ok = getServiceStatistic(ssr);
|
||||
}
|
||||
else if((grr = dynamic_cast<GroupSerializedDataReq*>(req)) != NULL)
|
||||
{
|
||||
ok = getGroupSerializedData(grr);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
std::cerr << "RsGxsDataAccess::processRequests() Failed to process request, token: "
|
||||
|
@ -929,7 +941,30 @@ bool RsGxsDataAccess::getServiceStatistic(const uint32_t &token, GxsServiceStati
|
|||
return true;
|
||||
}
|
||||
|
||||
bool RsGxsDataAccess::getGroupSerializedData(GroupSerializedDataReq* req)
|
||||
{
|
||||
std::map<RsGxsGroupId, RsNxsGrp*> grpData;
|
||||
std::list<RsGxsGroupId> grpIdsOut;
|
||||
|
||||
getGroupList(req->mGroupIds, req->Options, grpIdsOut);
|
||||
|
||||
if(grpIdsOut.empty())
|
||||
return true;
|
||||
|
||||
|
||||
for(std::list<RsGxsGroupId>::iterator lit = grpIdsOut.begin();lit != grpIdsOut.end();++lit)
|
||||
grpData[*lit] = NULL;
|
||||
|
||||
bool ok = mDataStore->retrieveNxsGrps(grpData, true, true);
|
||||
req->mGroupData.clear();
|
||||
|
||||
std::map<RsGxsGroupId, RsNxsGrp*>::iterator mit = grpData.begin();
|
||||
|
||||
for(; mit != grpData.end(); ++mit)
|
||||
req->mGroupData.push_back(mit->second) ;
|
||||
|
||||
return ok;
|
||||
}
|
||||
bool RsGxsDataAccess::getGroupData(GroupDataReq* req)
|
||||
{
|
||||
std::map<RsGxsGroupId, RsNxsGrp*> grpData;
|
||||
|
|
|
@ -418,6 +418,13 @@ private:
|
|||
*/
|
||||
bool getGroupStatistic(GroupStatisticRequest* req);
|
||||
|
||||
/*!
|
||||
*
|
||||
* Attempts to retrieve group data in serialized format
|
||||
* @param req Request object to satisfy
|
||||
*/
|
||||
bool getGroupSerializedData(GroupSerializedDataReq* req);
|
||||
|
||||
/*!
|
||||
*
|
||||
* Attempts to service statistic
|
||||
|
|
|
@ -328,6 +328,23 @@ RsGxsNetService::RsGxsNetService(uint16_t servType, RsGeneralDataService *gds,
|
|||
mUpdateCounter = 0;
|
||||
}
|
||||
|
||||
void RsGxsNetService::getItemNames(std::map<uint8_t,std::string>& names) const
|
||||
{
|
||||
names.clear();
|
||||
|
||||
names[RS_PKT_SUBTYPE_NXS_SYNC_GRP_REQ_ITEM ] = "Group Sync Request" ;
|
||||
names[RS_PKT_SUBTYPE_NXS_SYNC_GRP_ITEM ] = "Group Sync" ;
|
||||
names[RS_PKT_SUBTYPE_NXS_SYNC_GRP_STATS_ITEM ] = "Group Stats" ;
|
||||
names[RS_PKT_SUBTYPE_NXS_GRP_ITEM ] = "Group Data" ;
|
||||
names[RS_PKT_SUBTYPE_NXS_ENCRYPTED_DATA_ITEM ] = "Encrypted data" ;
|
||||
names[RS_PKT_SUBTYPE_NXS_SESSION_KEY_ITEM ] = "Session Key" ;
|
||||
names[RS_PKT_SUBTYPE_NXS_SYNC_MSG_ITEM ] = "Message Sync" ;
|
||||
names[RS_PKT_SUBTYPE_NXS_SYNC_MSG_REQ_ITEM ] = "Message Sync Request" ;
|
||||
names[RS_PKT_SUBTYPE_NXS_MSG_ITEM ] = "Message Data" ;
|
||||
names[RS_PKT_SUBTYPE_NXS_TRANSAC_ITEM ] = "Transaction" ;
|
||||
names[RS_PKT_SUBTYPE_NXS_GRP_PUBLISH_KEY_ITEM ] = "Publish key" ;
|
||||
}
|
||||
|
||||
RsGxsNetService::~RsGxsNetService()
|
||||
{
|
||||
RS_STACK_MUTEX(mNxsMutex) ;
|
||||
|
@ -1972,7 +1989,7 @@ void RsGxsNetService::updateServerSyncTS()
|
|||
#endif
|
||||
|
||||
// I keep the creation, but the data is not used yet.
|
||||
#warning disabled this, but do we need it?
|
||||
#warning csoler 2016-12-12: Disabled this, but do we need it?
|
||||
// RsGxsServerMsgUpdate& msui(mServerMsgUpdateMap[grpId]) ;
|
||||
|
||||
// (cyril) I'm removing this, because the msgUpdateTS is updated when new messages are received by calling locked_stampMsgServerUpdateTS().
|
||||
|
@ -3000,7 +3017,7 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
|
|||
}
|
||||
// FIXTESTS global variable rsReputations not available in unittests!
|
||||
|
||||
#warning Update the code below to correctly send/recv dependign on reputation
|
||||
#warning csoler 2016-12-23: Update the code below to correctly send/recv dependign on reputation
|
||||
if(!grpSyncItem->authorId.isNull() && mReputations->overallReputationLevel(grpSyncItem->authorId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE)
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG_0
|
||||
|
|
|
@ -99,6 +99,7 @@ public:
|
|||
|
||||
virtual RsServiceInfo getServiceInfo() { return mServiceInfo; }
|
||||
|
||||
virtual void getItemNames(std::map<uint8_t,std::string>& names) const ;
|
||||
public:
|
||||
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ bool AuthorPending::getAuthorRep(GixsReputation& rep, const RsGxsId& authorId, c
|
|||
rep.id = authorId ;
|
||||
rep.reputation_level = mRep->overallReputationLevel(authorId);
|
||||
|
||||
#warning can it happen that reputations do not have the info yet?
|
||||
#warning csoler 2017-01-10: Can it happen that reputations do not have the info yet?
|
||||
return true ;
|
||||
#ifdef TO_BE_REMOVED
|
||||
{
|
||||
|
|
|
@ -61,6 +61,12 @@ public:
|
|||
std::list<RsGxsGroupId> mGroupIds;
|
||||
std::list<RsGxsGroupId> mGroupIdResult;
|
||||
};
|
||||
class GroupSerializedDataReq : public GxsRequest
|
||||
{
|
||||
public:
|
||||
std::list<RsGxsGroupId> mGroupIds;
|
||||
std::list<RsNxsGrp*> mGroupData;
|
||||
};
|
||||
|
||||
class GroupDataReq : public GxsRequest
|
||||
{
|
||||
|
|
|
@ -1195,7 +1195,7 @@ bool p3GxsTunnelService::locked_sendClearTunnelData(RsGxsTunnelDHPublicKeyItem *
|
|||
if(gitem->data_bytes == NULL)
|
||||
{
|
||||
delete gitem ;
|
||||
return NULL ;
|
||||
return false ;
|
||||
}
|
||||
// by convention, we use a IV of 0 for unencrypted data.
|
||||
memset(gitem->data_bytes,0,8) ;
|
||||
|
|
|
@ -279,7 +279,12 @@ win32 {
|
|||
|
||||
CONFIG += upnp_miniupnpc
|
||||
|
||||
LIBS += -lsqlcipher
|
||||
no_sqlcipher {
|
||||
PKGCONFIG *= sqlite3
|
||||
LIBS += -lsqlite3
|
||||
} else {
|
||||
LIBS += -lsqlcipher
|
||||
}
|
||||
|
||||
DEPENDPATH += . $$INC_DIR
|
||||
INCLUDEPATH += . $$INC_DIR
|
||||
|
|
|
@ -50,9 +50,14 @@ RsPluginManager::RsPluginManager(const RsFileHash &hash)
|
|||
_allow_all_plugins = false ;
|
||||
}
|
||||
|
||||
bool RsPluginManager::loadConfiguration(RsFileHash &loadHash)
|
||||
{
|
||||
return p3Config::loadConfiguration(loadHash);
|
||||
}
|
||||
|
||||
void RsPluginManager::loadConfiguration()
|
||||
{
|
||||
RsFileHash dummyHash ;
|
||||
RsFileHash dummyHash;
|
||||
p3Config::loadConfiguration(dummyHash);
|
||||
}
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ class RsPluginManager: public RsPluginHandler, public p3Config
|
|||
// -------------------- Own members -------------------------//
|
||||
//
|
||||
virtual void addConfigurations(p3ConfigMgr *cfgMgr) ;
|
||||
virtual bool loadConfiguration(RsFileHash &loadHash) ;
|
||||
virtual void loadConfiguration() ;
|
||||
|
||||
/*!
|
||||
|
|
|
@ -92,7 +92,7 @@ dhtPeerEntry::dhtPeerEntry()
|
|||
return;
|
||||
}
|
||||
|
||||
p3DhtMgr::p3DhtMgr(std::string id, pqiConnectCb *cb)
|
||||
p3DhtMgr::p3DhtMgr(RsPeerId id, pqiConnectCb *cb)
|
||||
:pqiNetAssistConnect(id, cb), dhtMtx("p3DhtMgr"), mStunRequired(true)
|
||||
{
|
||||
/* setup own entry */
|
||||
|
@ -237,13 +237,13 @@ bool p3DhtMgr::setExternalInterface(
|
|||
|
||||
|
||||
/* add / remove peers */
|
||||
bool p3DhtMgr::findPeer(std::string id)
|
||||
bool p3DhtMgr::findPeer(const RsPeerId& id)
|
||||
{
|
||||
RsStackMutex stack(dhtMtx); /***** LOCK MUTEX *****/
|
||||
|
||||
mDhtModifications = true;
|
||||
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
it = peers.find(id);
|
||||
if (it != peers.end())
|
||||
{
|
||||
|
@ -281,14 +281,14 @@ bool p3DhtMgr::findPeer(std::string id)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3DhtMgr::dropPeer(std::string id)
|
||||
bool p3DhtMgr::dropPeer(const RsPeerId& id)
|
||||
{
|
||||
RsStackMutex stack(dhtMtx); /***** LOCK MUTEX *****/
|
||||
|
||||
mDhtModifications = true;
|
||||
|
||||
/* once we are connected ... don't worry about them anymore */
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
it = peers.find(id);
|
||||
if (it == peers.end())
|
||||
{
|
||||
|
@ -302,14 +302,14 @@ bool p3DhtMgr::dropPeer(std::string id)
|
|||
}
|
||||
|
||||
/* post DHT key saying we should connect */
|
||||
bool p3DhtMgr::notifyPeer(std::string id)
|
||||
bool p3DhtMgr::notifyPeer(const RsPeerId& id)
|
||||
{
|
||||
RsStackMutex stack(dhtMtx); /***** LOCK MUTEX *****/
|
||||
#ifdef DHT_DEBUG
|
||||
std::cerr << "p3DhtMgr::notifyPeer() " << id << std::endl;
|
||||
std::cerr << "p3DhtMgr::notifyPeer() " << id.toStdString() << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
it = peers.find(id);
|
||||
if (it == peers.end())
|
||||
{
|
||||
|
@ -333,7 +333,7 @@ bool p3DhtMgr::notifyPeer(std::string id)
|
|||
#ifdef DHT_LOGS
|
||||
{
|
||||
/* Log */
|
||||
rslog(RSL_WARNING, p3dhtzone, "p3DhtMgr::notifyPeer() Id: " + id + " TO SOON - DROPPING");
|
||||
rslog(RSL_WARNING, p3dhtzone, "p3DhtMgr::notifyPeer() Id: " + id.toStdString() + " TO SOON - DROPPING");
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -352,7 +352,7 @@ bool p3DhtMgr::notifyPeer(std::string id)
|
|||
#ifdef DHT_LOGS
|
||||
{
|
||||
/* Log */
|
||||
rslog(RSL_WARNING, p3dhtzone, "p3DhtMgr::notifyPeer() Id: " + id + " PEER NOT FOUND - Trigger Search");
|
||||
rslog(RSL_WARNING, p3dhtzone, "p3DhtMgr::notifyPeer() Id: " + id.toStdString() + " PEER NOT FOUND - Trigger Search");
|
||||
}
|
||||
#endif
|
||||
it->second.lastTS = 0;
|
||||
|
@ -364,14 +364,14 @@ bool p3DhtMgr::notifyPeer(std::string id)
|
|||
}
|
||||
|
||||
/* extract current peer status */
|
||||
bool p3DhtMgr::getPeerStatus(std::string id,
|
||||
struct sockaddr_in &laddr,
|
||||
struct sockaddr_in &raddr,
|
||||
bool p3DhtMgr::getPeerStatus(const RsPeerId &id,
|
||||
struct sockaddr_in &laddr,
|
||||
struct sockaddr_in &raddr,
|
||||
uint32_t &type, uint32_t &state)
|
||||
{
|
||||
RsStackMutex stack(dhtMtx); /* LOCK MUTEX */
|
||||
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
it = peers.find(id);
|
||||
|
||||
/* ignore OFF peers */
|
||||
|
@ -776,7 +776,7 @@ int p3DhtMgr::checkPeerDHTKeys()
|
|||
dhtMtx.lock(); /* LOCK MUTEX */
|
||||
|
||||
/* iterate through and find min time and suitable candidate */
|
||||
std::map<std::string, dhtPeerEntry>::iterator it,pit;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it,pit;
|
||||
time_t now = time(NULL);
|
||||
uint32_t period = 0;
|
||||
uint32_t repeatPeriod = 6000;
|
||||
|
@ -802,7 +802,7 @@ int p3DhtMgr::checkPeerDHTKeys()
|
|||
period = DHT_CHECK_PERIOD;
|
||||
}
|
||||
#ifdef DHT_DEBUG
|
||||
std::cerr << "p3DhtMgr::checkPeerDHTKeys() Peer: " << it->second.id;
|
||||
std::cerr << "p3DhtMgr::checkPeerDHTKeys() Peer: " << it->second.id.toStdString();
|
||||
std::cerr << " Period: " << period;
|
||||
std::cerr << " Delta: " << delta;
|
||||
std::cerr << std::endl;
|
||||
|
@ -865,7 +865,7 @@ int p3DhtMgr::checkNotifyDHT()
|
|||
RsStackMutex stack(dhtMtx); /***** LOCK MUTEX *****/
|
||||
|
||||
/* iterate through and find min time and suitable candidate */
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
time_t now = time(NULL);
|
||||
int repeatPeriod = DHT_DEFAULT_PERIOD;
|
||||
|
||||
|
@ -1015,7 +1015,7 @@ int p3DhtMgr::checkStunState()
|
|||
if (mDhtState == DHT_STATE_CHECK_PEERS)
|
||||
{
|
||||
/* check that they have all be searched for */
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
for(it = peers.begin(); it != peers.end(); it++)
|
||||
{
|
||||
if (it->second.state == DHT_PEER_INIT)
|
||||
|
@ -1287,7 +1287,7 @@ int p3DhtMgr::status(std::ostream &out)
|
|||
out << "OWN DETAILS END----------------------------------------" << std::endl;
|
||||
|
||||
/* now peers states */
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
out << "PEER DETAILS ------------------------------------------" << std::endl;
|
||||
for(it = peers.begin(); it != peers.end(); it++)
|
||||
{
|
||||
|
@ -1622,15 +1622,13 @@ bool p3DhtMgr::dhtResultNotify(std::string idhash)
|
|||
std::cerr << "p3DhtMgr::dhtResultNotify() from idhash: ";
|
||||
std::cerr << RsUtil::BinToHex(idhash) << std::endl;
|
||||
#endif
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
time_t now = time(NULL);
|
||||
|
||||
/* if notify - we must match on the second hash */
|
||||
for(it = peers.begin(); (it != peers.end()) && ((it->second).hash2 != idhash); it++) ;
|
||||
|
||||
/* update data */
|
||||
std::string peerid;
|
||||
|
||||
/* ignore OFF peers */
|
||||
if ((it != peers.end()) && (it->second.state != DHT_PEER_OFF))
|
||||
{
|
||||
|
@ -1677,7 +1675,7 @@ bool p3DhtMgr::dhtResultSearch(std::string idhash,
|
|||
std::cerr << "p3DhtMgr::dhtResultSearch() for idhash: ";
|
||||
std::cerr << RsUtil::BinToHex(idhash) << std::endl;
|
||||
#endif
|
||||
std::map<std::string, dhtPeerEntry>::iterator it;
|
||||
std::map<RsPeerId, dhtPeerEntry>::iterator it;
|
||||
bool doCb = false;
|
||||
bool doStun = false;
|
||||
uint32_t stunFlags = 0;
|
||||
|
@ -1780,7 +1778,7 @@ bool p3DhtMgr::dhtResultSearch(std::string idhash,
|
|||
void printDhtPeerEntry(dhtPeerEntry *ent, std::ostream &out)
|
||||
{
|
||||
|
||||
out << "DhtEntry: ID: " << ent->id;
|
||||
out << "DhtEntry: ID: " << ent->id.toStdString();
|
||||
out << " State: " << ent->state;
|
||||
out << " lastTS: " << ent->lastTS;
|
||||
out << " notifyPending: " << ent->notifyPending;
|
||||
|
|
|
@ -78,7 +78,7 @@ class dhtPeerEntry
|
|||
public:
|
||||
dhtPeerEntry();
|
||||
|
||||
std::string id;
|
||||
RsPeerId id;
|
||||
uint32_t state;
|
||||
time_t lastTS;
|
||||
|
||||
|
@ -97,7 +97,7 @@ class p3DhtMgr: public pqiNetAssistConnect, public RsThread
|
|||
/*
|
||||
*/
|
||||
public:
|
||||
p3DhtMgr(std::string id, pqiConnectCb *cb);
|
||||
p3DhtMgr(RsPeerId id, pqiConnectCb *cb);
|
||||
|
||||
/********** External DHT Interface ************************
|
||||
* These Functions are the external interface
|
||||
|
@ -121,15 +121,15 @@ virtual bool setExternalInterface(struct sockaddr_in laddr,
|
|||
struct sockaddr_in raddr, uint32_t type);
|
||||
|
||||
/* add / remove peers */
|
||||
virtual bool findPeer(std::string id);
|
||||
virtual bool dropPeer(std::string id);
|
||||
virtual bool findPeer(const RsPeerId& id);
|
||||
virtual bool dropPeer(const RsPeerId& id);
|
||||
|
||||
/* post DHT key saying we should connect (callback when done) */
|
||||
virtual bool notifyPeer(std::string id);
|
||||
virtual bool notifyPeer(const RsPeerId& id);
|
||||
|
||||
/* extract current peer status */
|
||||
virtual bool getPeerStatus(std::string id,
|
||||
struct sockaddr_in &laddr, struct sockaddr_in &raddr,
|
||||
virtual bool getPeerStatus(const RsPeerId& id,
|
||||
struct sockaddr_in &laddr, struct sockaddr_in &raddr,
|
||||
uint32_t &type, uint32_t &mode);
|
||||
|
||||
/* stun */
|
||||
|
@ -154,17 +154,17 @@ virtual bool dhtResultBootstrap(std::string idhash);
|
|||
protected:
|
||||
|
||||
/* can block briefly (called only from thread) */
|
||||
virtual bool dhtPublish(std::string id,
|
||||
virtual bool dhtPublish(std::string idhash,
|
||||
struct sockaddr_in &laddr,
|
||||
struct sockaddr_in &raddr,
|
||||
uint32_t type, std::string sign);
|
||||
|
||||
virtual bool dhtNotify(std::string peerid, std::string ownId,
|
||||
virtual bool dhtNotify(std::string idhash, std::string ownIdHash,
|
||||
std::string sign);
|
||||
|
||||
virtual bool dhtSearch(std::string id, uint32_t mode);
|
||||
virtual bool dhtSearch(std::string idhash, uint32_t mode);
|
||||
|
||||
virtual bool dhtBootstrap(std::string storehash, std::string ownIdHash,
|
||||
virtual bool dhtBootstrap(std::string idhash, std::string ownIdHash,
|
||||
std::string sign); /* to publish bootstrap */
|
||||
|
||||
|
||||
|
@ -232,7 +232,7 @@ std::string randomBootstrapId();
|
|||
|
||||
dhtPeerEntry ownEntry;
|
||||
time_t ownNotifyTS;
|
||||
std::map<std::string, dhtPeerEntry> peers;
|
||||
std::map<RsPeerId, dhtPeerEntry> peers;
|
||||
|
||||
std::list<std::string> stunIds;
|
||||
bool mStunRequired;
|
||||
|
|
|
@ -397,7 +397,7 @@ private:
|
|||
std::map<RsPeerId,sockaddr_storage> mReportedOwnAddresses ;
|
||||
|
||||
std::map<RsNodeGroupId,RsGroupInfo> groupList;
|
||||
uint32_t lastGroupId;
|
||||
//uint32_t lastGroupId;
|
||||
|
||||
std::list<RsItem *> saveCleanupList; /* TEMPORARY LIST WHEN SAVING */
|
||||
|
||||
|
|
|
@ -30,7 +30,9 @@
|
|||
#include "rsitems/rsitem.h"
|
||||
#include "serialiser/rsserial.h"
|
||||
#include "serialiser/rsbaseserial.h"
|
||||
#include "serialiser/rsnxsitems.h"
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
#include "pqi/pqiservice.h"
|
||||
|
||||
/*******************************/
|
||||
// #define SERVICECONTROL_DEBUG 1
|
||||
|
@ -139,7 +141,7 @@ public:
|
|||
std::cerr << __PRETTY_FUNCTION__ << ": error while deserialising! Item will be dropped." << std::endl;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= getRawUInt32(data, rssize, &offset, &item->mServiceId);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->mServiceName);
|
||||
|
@ -249,6 +251,13 @@ const RsPeerId& p3ServiceControl::getOwnId()
|
|||
return mOwnPeerId;
|
||||
}
|
||||
|
||||
bool p3ServiceControl::getServiceItemNames(uint32_t serviceId,std::map<uint8_t,std::string>& names)
|
||||
{
|
||||
if(mServiceServer != NULL)
|
||||
return mServiceServer->getServiceItemNames(serviceId,names) ;
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
/* Interface for Services */
|
||||
bool p3ServiceControl::registerService(const RsServiceInfo &info, bool defaultOn)
|
||||
|
@ -538,7 +547,7 @@ bool p3ServiceControl::updateServicePermissions(uint32_t serviceId, const RsServ
|
|||
{
|
||||
for(pit = onlinePeers.begin(); pit != onlinePeers.end(); ++pit)
|
||||
{
|
||||
if (it->second.peerHasPermission(*pit) !=
|
||||
if (it->second.peerHasPermission(*pit) !=
|
||||
permissions.peerHasPermission(*pit))
|
||||
{
|
||||
mUpdatedSet.insert(*pit);
|
||||
|
@ -598,7 +607,7 @@ bool p3ServiceControl::checkFilter(uint32_t serviceId, const RsPeerId &peerId)
|
|||
#endif
|
||||
|
||||
// must allow ServiceInfo through, or we have nothing!
|
||||
#define FULLID_SERVICEINFO ((((uint32_t) RS_PKT_VERSION_SERVICE) << 24) + ((RS_SERVICE_TYPE_SERVICEINFO) << 8))
|
||||
#define FULLID_SERVICEINFO ((((uint32_t) RS_PKT_VERSION_SERVICE) << 24) + ((RS_SERVICE_TYPE_SERVICEINFO) << 8))
|
||||
|
||||
//if (serviceId == RS_SERVICE_TYPE_SERVICEINFO)
|
||||
if (serviceId == FULLID_SERVICEINFO)
|
||||
|
@ -692,21 +701,21 @@ bool ServiceInfoCompatible(const RsServiceInfo &info1, const RsServiceInfo &info
|
|||
}
|
||||
|
||||
// ensure that info1 meets minimum requirements for info2
|
||||
if (!versionOkay(info1.mVersionMajor, info1.mVersionMinor,
|
||||
if (!versionOkay(info1.mVersionMajor, info1.mVersionMinor,
|
||||
info2.mMinVersionMajor, info2.mMinVersionMinor))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// ensure that info2 meets minimum requirements for info1
|
||||
if (!versionOkay(info2.mVersionMajor, info2.mVersionMinor,
|
||||
if (!versionOkay(info2.mVersionMajor, info2.mVersionMinor,
|
||||
info1.mMinVersionMajor, info1.mMinVersionMinor))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool p3ServiceControl::updateFilterByPeer(const RsPeerId &peerId)
|
||||
{
|
||||
|
@ -791,8 +800,8 @@ bool p3ServiceControl::updateFilterByPeer_locked(const RsPeerId &peerId)
|
|||
std::cerr << "p3ServiceControl::updateFilterByPeer_locked() Empty ... Clearing";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
// empty, remove...
|
||||
|
||||
// empty, remove...
|
||||
recordFilterChanges_locked(peerId, originalFilter, peerFilter);
|
||||
if (fit != mPeerFilterMap.end())
|
||||
{
|
||||
|
@ -883,7 +892,7 @@ bool p3ServiceControl::updateFilterByPeer_locked(const RsPeerId &peerId)
|
|||
std::cerr << "p3ServiceControl::updateFilterByPeer_locked() Empty(2) ... Clearing";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
if (fit != mPeerFilterMap.end())
|
||||
{
|
||||
mPeerFilterMap.erase(fit);
|
||||
|
@ -901,7 +910,7 @@ bool p3ServiceControl::updateFilterByPeer_locked(const RsPeerId &peerId)
|
|||
return true;
|
||||
}
|
||||
|
||||
void p3ServiceControl::recordFilterChanges_locked(const RsPeerId &peerId,
|
||||
void p3ServiceControl::recordFilterChanges_locked(const RsPeerId &peerId,
|
||||
ServicePeerFilter &originalFilter, ServicePeerFilter &updatedFilter)
|
||||
{
|
||||
#ifdef SERVICECONTROL_DEBUG
|
||||
|
@ -1203,7 +1212,7 @@ bool p3ServiceControl::loadList(std::list<RsItem *>& loadList)
|
|||
|
||||
if(item != NULL)
|
||||
mServicePermissionMap[item->mServiceId] = *item ;
|
||||
|
||||
|
||||
delete *it ;
|
||||
}
|
||||
|
||||
|
@ -1397,49 +1406,49 @@ void p3ServiceControl::notifyServices()
|
|||
std::cerr << "p3ServiceControl::notifyServices(): Noone Monitoring ... skipping";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
std::list<pqiServicePeer> peers;
|
||||
std::set<RsPeerId>::const_iterator pit;
|
||||
for(pit = it->second.mAdded.begin();
|
||||
for(pit = it->second.mAdded.begin();
|
||||
pit != it->second.mAdded.end(); ++pit)
|
||||
{
|
||||
pqiServicePeer peer;
|
||||
peer.id = *pit;
|
||||
peer.actions = RS_SERVICE_PEER_CONNECTED;
|
||||
|
||||
|
||||
peers.push_back(peer);
|
||||
|
||||
|
||||
#ifdef SERVICECONTROL_DEBUG
|
||||
std::cerr << "p3ServiceControl::notifyServices(): Peer: " << *pit << " CONNECTED";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
for(pit = it->second.mRemoved.begin();
|
||||
|
||||
for(pit = it->second.mRemoved.begin();
|
||||
pit != it->second.mRemoved.end(); ++pit)
|
||||
{
|
||||
pqiServicePeer peer;
|
||||
peer.id = *pit;
|
||||
peer.actions = RS_SERVICE_PEER_DISCONNECTED;
|
||||
|
||||
|
||||
peers.push_back(peer);
|
||||
|
||||
|
||||
#ifdef SERVICECONTROL_DEBUG
|
||||
std::cerr << "p3ServiceControl::notifyServices(): Peer: " << *pit << " DISCONNECTED";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
for(; sit != eit; ++sit)
|
||||
{
|
||||
#ifdef SERVICECONTROL_DEBUG
|
||||
std::cerr << "p3ServiceControl::notifyServices(): Sending to Monitoring Service";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
sit->second->statusChange(peers);
|
||||
}
|
||||
}
|
||||
|
@ -1501,17 +1510,17 @@ void RsServicePermissions::resetPermission(const RsPeerId& peerId)
|
|||
}
|
||||
|
||||
RsServiceInfo::RsServiceInfo(
|
||||
const uint16_t service_type,
|
||||
const std::string service_name,
|
||||
const uint16_t service_type,
|
||||
const std::string service_name,
|
||||
const uint16_t version_major,
|
||||
const uint16_t version_minor,
|
||||
const uint16_t min_version_major,
|
||||
const uint16_t min_version_minor)
|
||||
:mServiceName(service_name),
|
||||
mServiceType((((uint32_t) RS_PKT_VERSION_SERVICE) << 24) + (((uint32_t) service_type) << 8)),
|
||||
mVersionMajor(version_major),
|
||||
:mServiceName(service_name),
|
||||
mServiceType((((uint32_t) RS_PKT_VERSION_SERVICE) << 24) + (((uint32_t) service_type) << 8)),
|
||||
mVersionMajor(version_major),
|
||||
mVersionMinor(version_minor),
|
||||
mMinVersionMajor(min_version_major),
|
||||
mMinVersionMajor(min_version_major),
|
||||
mMinVersionMinor(min_version_minor)
|
||||
{
|
||||
return;
|
||||
|
@ -1519,7 +1528,7 @@ RsServiceInfo::RsServiceInfo(
|
|||
|
||||
|
||||
RsServiceInfo::RsServiceInfo()
|
||||
:mServiceName("unknown"),
|
||||
:mServiceName("unknown"),
|
||||
mServiceType(0),
|
||||
mVersionMajor(0),
|
||||
mVersionMinor(0),
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
#include "pqi/pqiservicemonitor.h"
|
||||
#include "pqi/p3linkmgr.h"
|
||||
|
||||
class p3ServiceServer ;
|
||||
|
||||
class ServiceNotifications
|
||||
{
|
||||
public:
|
||||
|
@ -101,6 +103,9 @@ virtual bool updateServicePermissions(uint32_t serviceId, const RsServicePermiss
|
|||
virtual void getPeersConnected(const uint32_t serviceId, std::set<RsPeerId> &peerSet);
|
||||
virtual bool isPeerConnected(const uint32_t serviceId, const RsPeerId &peerId);
|
||||
|
||||
// Gets the list of items used by that service
|
||||
virtual bool getServiceItemNames(uint32_t serviceId,std::map<uint8_t,std::string>& names) ;
|
||||
|
||||
/**
|
||||
* Registration for all Services.
|
||||
*/
|
||||
|
@ -132,6 +137,8 @@ virtual bool updateServicesProvided(const RsPeerId &peerId, const RsPeerServiceI
|
|||
// pqiMonitor.
|
||||
virtual void statusChange(const std::list<pqipeer> &plist);
|
||||
|
||||
virtual void setServiceServer(p3ServiceServer *p) { mServiceServer = p ; }
|
||||
|
||||
protected:
|
||||
// configuration.
|
||||
virtual bool saveList(bool &cleanup, std::list<RsItem *>&);
|
||||
|
@ -196,6 +203,7 @@ bool peerHasPermissionForService_locked(const RsPeerId &peerId, uint32_t service
|
|||
// Below here is saved in Configuration.
|
||||
std::map<uint32_t, RsServicePermissions> mServicePermissionMap;
|
||||
|
||||
p3ServiceServer *mServiceServer ;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -61,14 +61,20 @@ void pqiConnectCbDummy::peerStatus(const RsPeerId& id, const pqiIpAddrSet &ad
|
|||
std::cerr << out << std::endl;
|
||||
}
|
||||
|
||||
void pqiConnectCbDummy::peerConnectRequest(const RsPeerId& id,
|
||||
const struct sockaddr_storage &raddr, uint32_t source)
|
||||
void pqiConnectCbDummy::peerConnectRequest(const RsPeerId &id, const sockaddr_storage &raddr
|
||||
, const sockaddr_storage &proxyaddr, const sockaddr_storage &srcaddr
|
||||
, uint32_t source, uint32_t flags, uint32_t delay, uint32_t bandwidth)
|
||||
{
|
||||
std::cerr << "pqiConnectCbDummy::peerConnectRequest()";
|
||||
std::cerr << " id: " << id;
|
||||
std::cerr << " raddr: " << sockaddr_storage_tostring(raddr);
|
||||
std::cerr << " proxyaddr: " << sockaddr_storage_tostring(proxyaddr);
|
||||
std::cerr << " srcaddr: " << sockaddr_storage_tostring(srcaddr);
|
||||
std::cerr << " source: " << source;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << " flags: " << flags;
|
||||
std::cerr << " delay: " << delay;
|
||||
std::cerr << " bandwidth: " << bandwidth;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
void pqiMonitor::disconnectPeer(const RsPeerId &/*peer*/)
|
||||
|
|
|
@ -179,8 +179,9 @@ virtual ~pqiConnectCbDummy();
|
|||
virtual void peerStatus(const RsPeerId& id, const pqiIpAddrSet &addrs,
|
||||
uint32_t type, uint32_t mode, uint32_t source);
|
||||
|
||||
virtual void peerConnectRequest(const RsPeerId& id,
|
||||
const struct sockaddr_storage &raddr, uint32_t source);
|
||||
virtual void peerConnectRequest(const RsPeerId& id, const struct sockaddr_storage &raddr,
|
||||
const struct sockaddr_storage &proxyaddr, const struct sockaddr_storage &srcaddr,
|
||||
uint32_t source, uint32_t flags, uint32_t delay, uint32_t bandwidth);
|
||||
|
||||
//virtual void stunStatus(std::string id, const struct sockaddr_storage &raddr, uint32_t type, uint32_t flags);
|
||||
};
|
||||
|
|
|
@ -40,7 +40,7 @@ static struct RsLog::logInfo pqipersonzoneInfo = {RsLog::Default, "pqiperson"};
|
|||
|
||||
pqiperson::pqiperson(const RsPeerId& id, pqipersongrp *pg) :
|
||||
PQInterface(id), mNotifyMtx("pqiperson-notify"), mPersonMtx("pqiperson"),
|
||||
active(false), activepqi(NULL), inConnectAttempt(false), waittimes(0),
|
||||
active(false), activepqi(NULL), inConnectAttempt(false),// waittimes(0),
|
||||
pqipg(pg) {} // TODO: must check id!
|
||||
|
||||
pqiperson::~pqiperson()
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#define MRK_PQI_PERSON_HEADER
|
||||
|
||||
|
||||
#include <string>
|
||||
#include "pqi/pqi.h"
|
||||
#include "util/rsnet.h"
|
||||
|
||||
|
@ -66,7 +67,7 @@ public:
|
|||
virtual int reset() { pqistreamer::reset(); return ni->reset(); }
|
||||
virtual int disconnect() { return reset() ; }
|
||||
virtual bool connect_parameter(uint32_t type, uint32_t value) { return ni->connect_parameter(type, value);}
|
||||
virtual bool connect_parameter(uint32_t type, std::string value) { return ni->connect_parameter(type, value);}
|
||||
virtual bool connect_parameter(uint32_t type, const std::string &value) { return ni->connect_parameter(type, value);}
|
||||
virtual bool connect_additional_address(uint32_t type, const struct sockaddr_storage &addr) { return ni->connect_additional_address(type, addr); }
|
||||
virtual int getConnectAddress(struct sockaddr_storage &raddr){ return ni->getConnectAddress(raddr); }
|
||||
|
||||
|
@ -171,7 +172,7 @@ private:
|
|||
bool active;
|
||||
pqiconnect *activepqi;
|
||||
bool inConnectAttempt;
|
||||
int waittimes;
|
||||
//int waittimes;
|
||||
time_t lastHeartbeatReceived; // use to track connection failure
|
||||
pqipersongrp *pqipg; /* parent for callback */
|
||||
};
|
||||
|
|
|
@ -79,11 +79,26 @@ int p3ServiceServer::addService(pqiService *ts, bool defaultOn)
|
|||
services[info.mServiceType] = ts;
|
||||
|
||||
// This doesn't need to be in Mutex.
|
||||
mServiceControl->registerService(info, defaultOn);
|
||||
mServiceControl->registerService(info,defaultOn);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool p3ServiceServer::getServiceItemNames(uint32_t service_type,std::map<uint8_t,std::string>& names)
|
||||
{
|
||||
RsStackMutex stack(srvMtx); /********* LOCKED *********/
|
||||
|
||||
std::map<uint32_t, pqiService *>::iterator it=services.find(service_type) ;
|
||||
|
||||
if(it != services.end())
|
||||
{
|
||||
it->second->getItemNames(names) ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
int p3ServiceServer::removeService(pqiService *ts)
|
||||
{
|
||||
RsStackMutex stack(srvMtx); /********* LOCKED *********/
|
||||
|
|
|
@ -60,24 +60,26 @@ class p3ServiceServerIface;
|
|||
|
||||
class pqiService
|
||||
{
|
||||
protected:
|
||||
protected:
|
||||
|
||||
pqiService() // our type of packets.
|
||||
:mServiceServer(NULL) { return; }
|
||||
:mServiceServer(NULL) { return; }
|
||||
|
||||
virtual ~pqiService() { return; }
|
||||
virtual ~pqiService() { return; }
|
||||
|
||||
public:
|
||||
void setServiceServer(p3ServiceServerIface *server);
|
||||
//
|
||||
virtual bool recv(RsRawItem *) = 0;
|
||||
virtual bool send(RsRawItem *item);
|
||||
public:
|
||||
void setServiceServer(p3ServiceServerIface *server);
|
||||
//
|
||||
virtual bool recv(RsRawItem *) = 0;
|
||||
virtual bool send(RsRawItem *item);
|
||||
|
||||
virtual RsServiceInfo getServiceInfo() = 0;
|
||||
virtual RsServiceInfo getServiceInfo() = 0;
|
||||
|
||||
virtual int tick() { return 0; }
|
||||
virtual int tick() { return 0; }
|
||||
|
||||
private:
|
||||
virtual void getItemNames(std::map<uint8_t,std::string>& /*names*/) const {} // This does nothing by default. Service should derive it in order to give info for the UI
|
||||
|
||||
private:
|
||||
p3ServiceServerIface *mServiceServer; // const, no need for mutex.
|
||||
};
|
||||
|
||||
|
@ -97,10 +99,10 @@ public:
|
|||
virtual ~p3ServiceServerIface() {}
|
||||
|
||||
|
||||
virtual bool recvItem(RsRawItem *) = 0;
|
||||
virtual bool sendItem(RsRawItem *) = 0;
|
||||
|
||||
virtual bool recvItem(RsRawItem *) = 0;
|
||||
virtual bool sendItem(RsRawItem *) = 0;
|
||||
|
||||
virtual bool getServiceItemNames(uint32_t service_type,std::map<uint8_t,std::string>& names) =0;
|
||||
};
|
||||
|
||||
class p3ServiceServer : public p3ServiceServerIface
|
||||
|
@ -108,13 +110,15 @@ class p3ServiceServer : public p3ServiceServerIface
|
|||
public:
|
||||
p3ServiceServer(pqiPublisher *pub, p3ServiceControl *ctrl);
|
||||
|
||||
int addService(pqiService *, bool defaultOn);
|
||||
int removeService(pqiService *);
|
||||
int addService(pqiService *, bool defaultOn);
|
||||
int removeService(pqiService *);
|
||||
|
||||
bool recvItem(RsRawItem *);
|
||||
bool sendItem(RsRawItem *);
|
||||
bool recvItem(RsRawItem *);
|
||||
bool sendItem(RsRawItem *);
|
||||
|
||||
int tick();
|
||||
bool getServiceItemNames(uint32_t service_type, std::map<uint8_t,std::string>& names) ;
|
||||
|
||||
int tick();
|
||||
public:
|
||||
|
||||
private:
|
||||
|
@ -122,7 +126,7 @@ private:
|
|||
pqiPublisher *mPublisher; // constant no need for mutex.
|
||||
p3ServiceControl *mServiceControl;
|
||||
|
||||
RsMutex srvMtx;
|
||||
RsMutex srvMtx;
|
||||
std::map<uint32_t, pqiService *> services;
|
||||
|
||||
};
|
||||
|
|
|
@ -1009,7 +1009,7 @@ int pqissl::Basic_Connection_Complete()
|
|||
|
||||
return -1;
|
||||
}
|
||||
else if ((err == ECONNREFUSED))
|
||||
else if (err == ECONNREFUSED)
|
||||
{
|
||||
rslog(RSL_WARNING, pqisslzone, "pqissl::Basic_Connection_Complete() ECONNREFUSED: cert: " + PeerId().toStdString());
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ static const uint32_t PQI_SSLUDP_DEF_CONN_PERIOD = 300; /* 5 minutes? */
|
|||
/********** PQI SSL UDP STUFF **************************************/
|
||||
|
||||
pqissludp::pqissludp(PQInterface *parent, p3LinkMgr *lm) :
|
||||
pqissl(NULL, parent, lm), tou_bio(NULL), listen_checktime(0),
|
||||
pqissl(NULL, parent, lm), tou_bio(NULL),// listen_checktime(0),
|
||||
mConnectPeriod(PQI_SSLUDP_DEF_CONN_PERIOD), mConnectFlags(0),
|
||||
mConnectBandwidth(0)
|
||||
{
|
||||
|
|
|
@ -95,7 +95,7 @@ private:
|
|||
|
||||
BIO *tou_bio; // specific to ssludp.
|
||||
|
||||
long listen_checktime;
|
||||
//long listen_checktime;
|
||||
|
||||
uint32_t mConnectPeriod;
|
||||
uint32_t mConnectFlags;
|
||||
|
|
|
@ -627,7 +627,7 @@ bool getX509id(X509 *x509, RsPeerId& xid)
|
|||
* more randomness
|
||||
*/
|
||||
|
||||
#warning this is cryptographically horrible. We should do a hash of the public key here!!!
|
||||
#warning csoler 2017-02-19: This is cryptographically horrible. We should do a hash of the public key here!!!
|
||||
|
||||
xid = RsPeerId(&signdata[signlen - CERTSIGNLEN]) ;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ typedef std::pair<RsGxsGroupId, RsGxsMessageId> RsGxsGrpMsgIdPair;
|
|||
typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsGxsMessageId> > MsgRelatedIdResult;
|
||||
typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgReq;
|
||||
|
||||
class RsMsgMetaData;
|
||||
struct RsMsgMetaData;
|
||||
|
||||
typedef std::map<RsGxsGroupId, std::vector<RsMsgMetaData> > MsgMetaResult;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "retroshare/rsgxsifacetypes.h"
|
||||
#include "retroshare/rstokenservice.h"
|
||||
|
||||
class RsMsgMetaData ;
|
||||
struct RsMsgMetaData ;
|
||||
|
||||
typedef std::map<RsGxsGroupId, std::vector<RsMsgMetaData> > GxsMsgMetaMap;
|
||||
typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsMsgMetaData> > GxsMsgRelatedMetaMap;
|
||||
|
|
|
@ -305,6 +305,9 @@ public:
|
|||
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) = 0 ;
|
||||
virtual bool isARegularContact(const RsGxsId& id) = 0 ;
|
||||
|
||||
virtual bool serialiseIdentityToMemory(const RsGxsId& id,std::string& radix_string)=0;
|
||||
virtual bool deserialiseIdentityFromMemory(const std::string& radix_string)=0;
|
||||
|
||||
/*!
|
||||
* \brief overallReputationLevel
|
||||
* Returns the overall reputation level of the supplied identity. See rsreputations.h
|
||||
|
@ -319,6 +322,7 @@ public:
|
|||
*/
|
||||
|
||||
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup> &groups) = 0;
|
||||
virtual bool getGroupSerializedData(const uint32_t &token, std::map<RsGxsId,std::string>& serialized_groups)=0;
|
||||
//virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsIdOpinion> &opinions) = 0;
|
||||
|
||||
};
|
||||
|
|
|
@ -109,6 +109,7 @@ virtual ~RsServiceControl() { return; }
|
|||
|
||||
virtual bool getOwnServices(RsPeerServiceInfo &info) = 0;
|
||||
virtual std::string getServiceName(uint32_t service_id) = 0;
|
||||
virtual bool getServiceItemNames(uint32_t service_id,std::map<uint8_t,std::string>& names) = 0;
|
||||
|
||||
virtual bool getServicesAllowed(const RsPeerId &peerId, RsPeerServiceInfo &info) = 0;
|
||||
virtual bool getServicesProvided(const RsPeerId &peerId, RsPeerServiceInfo &info) = 0;
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
|
||||
#define GXS_REQUEST_TYPE_GROUP_STATS 0x01600000
|
||||
#define GXS_REQUEST_TYPE_SERVICE_STATS 0x03200000
|
||||
#define GXS_REQUEST_TYPE_GROUP_SERIALIZED_DATA 0x04000000
|
||||
|
||||
|
||||
// TODO CLEANUP: RS_TOKREQOPT_MSG_* should be an inner enum of RsTokReqOptions
|
||||
|
|
|
@ -1037,6 +1037,9 @@ bool p3Peers::setProxyServer(const uint32_t type, const std::string &addr_str, c
|
|||
std::cerr << "(EE) attempt to set proxy server address to something not allowed: " << addr_str << ":" << port << std::endl;
|
||||
return false ;
|
||||
}
|
||||
|
||||
std::cerr << "Settign proxy server address to " << addr_str << ":" << port << std::endl;
|
||||
|
||||
struct sockaddr_storage addr;
|
||||
struct sockaddr_in *addrv4p = (struct sockaddr_in *) &addr;
|
||||
addrv4p->sin_family = AF_INET;
|
||||
|
|
|
@ -1243,6 +1243,8 @@ int RsServer::StartupRetroShare()
|
|||
pqih = new pqisslpersongrp(serviceCtrl, flags, mPeerMgr);
|
||||
//pqih = new pqipersongrpDummy(none, flags);
|
||||
|
||||
serviceCtrl->setServiceServer(pqih) ;
|
||||
|
||||
/****** New Ft Server **** !!! */
|
||||
ftServer *ftserver = new ftServer(mPeerMgr, serviceCtrl);
|
||||
ftserver->setConfigDirectory(rsAccounts->PathAccountDirectory());
|
||||
|
|
|
@ -67,8 +67,8 @@
|
|||
*/
|
||||
RsBanList *rsBanList = NULL ;
|
||||
|
||||
p3BanList::p3BanList(p3ServiceControl *sc, p3NetMgr *nm)
|
||||
:p3Service(), mBanMtx("p3BanList"), mServiceCtrl(sc), mNetMgr(nm)
|
||||
p3BanList::p3BanList(p3ServiceControl *sc, p3NetMgr */*nm*/)
|
||||
:p3Service(), mBanMtx("p3BanList"), mServiceCtrl(sc)//, mNetMgr(nm)
|
||||
{
|
||||
addSerialType(new RsBanListSerialiser());
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ private:
|
|||
std::map<struct sockaddr_storage, BanListPeer> mWhiteListedRanges;
|
||||
|
||||
p3ServiceControl *mServiceCtrl;
|
||||
p3NetMgr *mNetMgr;
|
||||
//p3NetMgr *mNetMgr;
|
||||
time_t mLastDhtInfoRequest ;
|
||||
|
||||
bool mIPFilteringEnabled ;
|
||||
|
|
|
@ -1036,7 +1036,7 @@ bool p3GxsReputation::setOwnOpinion(const RsGxsId& gxsid, const RsReputations::O
|
|||
|
||||
if (rit == mReputations.end())
|
||||
{
|
||||
#warning we should set the owner node id here.
|
||||
#warning csoler 2017-01-05: We should set the owner node id here.
|
||||
mReputations[gxsid] = Reputation(gxsid);
|
||||
rit = mReputations.find(gxsid);
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ private:
|
|||
time_t mLastIdentityFlagsUpdate ;
|
||||
bool mReputationsUpdated;
|
||||
|
||||
float mAutoBanIdentitiesLimit ;
|
||||
//float mAutoBanIdentitiesLimit ;
|
||||
bool mAutoSetPositiveOptionToContacts;
|
||||
|
||||
p3LinkMgr *mLinkMgr;
|
||||
|
|
|
@ -70,6 +70,8 @@ static const time_t MAX_KEEP_KEYS_SIGNED_KNOWN = 30 * 86400 ; // signed ident
|
|||
|
||||
static const uint32_t MAX_DELAY_BEFORE_CLEANING= 1800 ; // clean old keys every 30 mins
|
||||
|
||||
static const uint32_t MAX_SERIALISED_IDENTITY_AGE = 600 ; // after 10 mins, a serialised identity record must be renewed.
|
||||
|
||||
RsIdentity *rsIdentity = NULL;
|
||||
|
||||
/******
|
||||
|
@ -97,13 +99,12 @@ RsIdentity *rsIdentity = NULL;
|
|||
#define BG_REPUTATION 3
|
||||
|
||||
|
||||
#define GXSIDREQ_CACHELOAD 0x0001
|
||||
#define GXSIDREQ_CACHEOWNIDS 0x0002
|
||||
|
||||
#define GXSIDREQ_PGPHASH 0x0010
|
||||
#define GXSIDREQ_RECOGN 0x0020
|
||||
|
||||
#define GXSIDREQ_OPINION 0x0030
|
||||
#define GXSIDREQ_CACHELOAD 0x0001
|
||||
#define GXSIDREQ_CACHEOWNIDS 0x0002
|
||||
#define GXSIDREQ_PGPHASH 0x0010
|
||||
#define GXSIDREQ_RECOGN 0x0020
|
||||
#define GXSIDREQ_OPINION 0x0030
|
||||
#define GXSIDREQ_SERIALIZE_TO_MEMORY 0x0040
|
||||
|
||||
#define GXSIDREQ_CACHETEST 0x1000
|
||||
|
||||
|
@ -697,6 +698,84 @@ bool p3IdService::getOwnIds(std::list<RsGxsId> &ownIds)
|
|||
return true ;
|
||||
}
|
||||
|
||||
bool p3IdService::serialiseIdentityToMemory(const RsGxsId& id,std::string& radix_string)
|
||||
{
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
// look into cache. If available, return the data. If not, request it.
|
||||
|
||||
std::map<RsGxsId,SerialisedIdentityStruct>::const_iterator it = mSerialisedIdentities.find(id);
|
||||
|
||||
if(it != mSerialisedIdentities.end())
|
||||
{
|
||||
Radix64::encode(it->second.mMem,it->second.mSize,radix_string) ;
|
||||
|
||||
if(it->second.mLastUsageTS + MAX_SERIALISED_IDENTITY_AGE > time(NULL))
|
||||
return true ;
|
||||
|
||||
std::cerr << "Identity " << id << " will be re-serialised, because the last record is too old." << std::endl;
|
||||
}
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
uint32_t token = 0;
|
||||
std::list<RsGxsGroupId> groupIds;
|
||||
|
||||
groupIds.push_back(RsGxsGroupId(id)) ;
|
||||
|
||||
RsGenExchange::getTokenService()->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds);
|
||||
GxsTokenQueue::queueRequest(token, GXSIDREQ_SERIALIZE_TO_MEMORY);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void p3IdService::handle_get_serialized_grp(uint32_t token)
|
||||
{
|
||||
// store the serialized data in cache.
|
||||
|
||||
unsigned char *mem = NULL;
|
||||
uint32_t size;
|
||||
RsGxsGroupId id ;
|
||||
|
||||
if(!RsGenExchange::getSerializedGroupData(token,id, mem,size))
|
||||
{
|
||||
std::cerr << "(EE) call to RsGenExchage::getSerializedGroupData() failed." << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
std::cerr << "Received serialised group from RsGenExchange." << std::endl;
|
||||
|
||||
std::map<RsGxsId,SerialisedIdentityStruct>::const_iterator it = mSerialisedIdentities.find(RsGxsId(id));
|
||||
|
||||
if(it != mSerialisedIdentities.end())
|
||||
free(it->second.mMem) ;
|
||||
|
||||
SerialisedIdentityStruct s ;
|
||||
s.mMem = mem ;
|
||||
s.mSize = size ;
|
||||
s.mLastUsageTS = time(NULL) ;
|
||||
|
||||
mSerialisedIdentities[RsGxsId(id)] = s ;
|
||||
}
|
||||
|
||||
bool p3IdService::deserialiseIdentityFromMemory(const std::string& radix_string)
|
||||
{
|
||||
std::vector<uint8_t> mem = Radix64::decode(radix_string) ;
|
||||
|
||||
if(mem.empty())
|
||||
{
|
||||
std::cerr << "Cannot decode radix string \"" << radix_string << "\"" << std::endl;
|
||||
return false ;
|
||||
}
|
||||
|
||||
if(!RsGenExchange::deserializeGroupData(mem.data(),mem.size()))
|
||||
{
|
||||
std::cerr << "Cannot load identity from radix string \"" << radix_string << "\"" << std::endl;
|
||||
return false ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool p3IdService::createIdentity(uint32_t& token, RsIdentityParameters ¶ms)
|
||||
{
|
||||
|
@ -709,7 +788,7 @@ bool p3IdService::createIdentity(uint32_t& token, RsIdentityParameters ¶ms)
|
|||
|
||||
if (params.isPgpLinked)
|
||||
{
|
||||
#warning Backward compatibility issue to fix here in v0.7.0
|
||||
#warning csoler 2017-02-07: Backward compatibility issue to fix here in v0.7.0
|
||||
|
||||
// This is a hack, because a bad decision led to having RSGXSID_GROUPFLAG_REALID be equal to GXS_SERV::FLAG_PRIVACY_PRIVATE.
|
||||
// In order to keep backward compatibility, we'll also add the new value
|
||||
|
@ -1395,6 +1474,28 @@ bool p3IdService::getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup>
|
|||
return ok;
|
||||
}
|
||||
|
||||
bool p3IdService::getGroupSerializedData(const uint32_t &token, std::map<RsGxsId,std::string>& serialized_groups)
|
||||
{
|
||||
unsigned char *mem = NULL;
|
||||
uint32_t size;
|
||||
RsGxsGroupId id ;
|
||||
|
||||
serialized_groups.clear() ;
|
||||
|
||||
if(!RsGenExchange::getSerializedGroupData(token,id, mem,size))
|
||||
{
|
||||
std::cerr << "(EE) call to RsGenExchage::getSerializedGroupData() failed." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string radix ;
|
||||
|
||||
Radix64::encode(mem,size,radix) ;
|
||||
|
||||
serialized_groups[RsGxsId(id)] = radix ;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/********************************************************************************/
|
||||
/********************************************************************************/
|
||||
|
@ -4117,6 +4218,9 @@ void p3IdService::handleResponse(uint32_t token, uint32_t req_type)
|
|||
case GXSIDREQ_OPINION:
|
||||
opinion_handlerequest(token);
|
||||
break;
|
||||
case GXSIDREQ_SERIALIZE_TO_MEMORY:
|
||||
handle_get_serialized_grp(token) ;
|
||||
|
||||
default:
|
||||
/* error */
|
||||
std::cerr << "p3IdService::handleResponse() Unknown Request Type: " << req_type;
|
||||
|
|
|
@ -212,6 +212,13 @@ private:
|
|||
void init(const RsGxsIdGroupItem *item, const RsTlvPublicRSAKey& in_pub_key, const RsTlvPrivateRSAKey& in_priv_key,const std::list<RsRecognTag> &tagList);
|
||||
};
|
||||
|
||||
struct SerialisedIdentityStruct
|
||||
{
|
||||
unsigned char *mMem ;
|
||||
uint32_t mSize ;
|
||||
time_t mLastUsageTS;
|
||||
};
|
||||
|
||||
// Not sure exactly what should be inherited here?
|
||||
// Chris - please correct as necessary.
|
||||
|
||||
|
@ -238,6 +245,8 @@ public:
|
|||
|
||||
// These are exposed via RsIdentity.
|
||||
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup> &groups);
|
||||
virtual bool getGroupSerializedData(const uint32_t &token, std::map<RsGxsId,std::string>& serialized_groups);
|
||||
|
||||
//virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsIdOpinion> &opinions);
|
||||
|
||||
// These are local - and not exposed via RsIdentity.
|
||||
|
@ -302,6 +311,8 @@ public:
|
|||
virtual bool requestKey(const RsGxsId &id, const std::list<RsPeerId> &peers, const RsIdentityUsage &use_info);
|
||||
virtual bool requestPrivateKey(const RsGxsId &id);
|
||||
|
||||
virtual bool serialiseIdentityToMemory(const RsGxsId& id,std::string& radix_string);
|
||||
virtual bool deserialiseIdentityFromMemory(const std::string& radix_string);
|
||||
|
||||
/**************** RsGixsReputation Implementation ****************/
|
||||
|
||||
|
@ -394,6 +405,12 @@ private:
|
|||
bool mBgSchedule_Active;
|
||||
uint32_t mBgSchedule_Mode;
|
||||
|
||||
/***********************************8
|
||||
* Fonction to receive and handle group serialisation to memory
|
||||
*/
|
||||
|
||||
virtual void handle_get_serialized_grp(uint32_t token);
|
||||
|
||||
/************************************************************************
|
||||
* pgphash processing.
|
||||
*
|
||||
|
@ -524,6 +541,8 @@ private:
|
|||
std::map<RsGxsId, std::list<RsPeerId> > mIdsNotPresent;
|
||||
std::map<RsGxsId,keyTSInfo> mKeysTS ;
|
||||
|
||||
std::map<RsGxsId,SerialisedIdentityStruct> mSerialisedIdentities ;
|
||||
|
||||
// keep a list of regular contacts. This is useful to sort IDs, and allow some services to priviledged ids only.
|
||||
std::set<RsGxsId> mContacts;
|
||||
RsNetworkExchangeService* mNes;
|
||||
|
|
|
@ -93,9 +93,9 @@ again:
|
|||
idx = (idx + 1) % 4;
|
||||
}
|
||||
|
||||
idx = idx;
|
||||
//idx = idx;
|
||||
|
||||
return buf;
|
||||
return buf ;
|
||||
}
|
||||
|
||||
/****************
|
||||
|
@ -147,7 +147,7 @@ again:
|
|||
|
||||
private:
|
||||
static inline char *bintoasc() { static char bta[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; return bta ; }
|
||||
static inline char *asctobin() { static char s[256]; return s ; } /* runtime radix64_initd */
|
||||
static inline uint8_t *asctobin() { static uint8_t s[256]; return s ; } /* runtime radix64_initd */
|
||||
static int& is_radix64_initd() { static int is_inited = false ; return is_inited ; }
|
||||
|
||||
/* hey, guess what: this is a read-only table.
|
||||
|
|
|
@ -81,15 +81,18 @@ bool rsGetHostByName(const std::string& hostname, in_addr& returned_addr)
|
|||
addrinfo *info = NULL;
|
||||
int res = getaddrinfo(hostname.c_str(),NULL,NULL,&info) ;
|
||||
|
||||
bool ok = true;
|
||||
if(res > 0 || info == NULL || info->ai_addr == NULL)
|
||||
{
|
||||
std::cerr << "(EE) getaddrinfo returned error " << res << " on string \"" << hostname << "\"" << std::endl;
|
||||
returned_addr.s_addr = 0 ;
|
||||
ok = false;
|
||||
}
|
||||
else
|
||||
returned_addr.s_addr = ((sockaddr_in*)info->ai_addr)->sin_addr.s_addr ;
|
||||
|
||||
freeaddrinfo(info) ;
|
||||
if(info)
|
||||
freeaddrinfo(info) ;
|
||||
|
||||
#ifdef DEPRECATED_TO_REMOVE
|
||||
#if defined(WINDOWS_SYS) || defined(__APPLE__) || defined(__HAIKU__)
|
||||
|
@ -123,7 +126,7 @@ bool rsGetHostByName(const std::string& hostname, in_addr& returned_addr)
|
|||
returned_addr.s_addr = *(unsigned long*) (result->h_addr);
|
||||
#endif
|
||||
|
||||
return true ;
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool isValidNet(const struct in_addr *addr)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue