diff --git a/libretroshare/src/grouter/grouterclient.h b/libretroshare/src/grouter/grouterclient.h deleted file mode 100644 index a5edf8363..000000000 --- a/libretroshare/src/grouter/grouterclient.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * libretroshare/src/services: grouterclient.h - * - * Services for RetroShare. - * - * Copyright 2013 by Cyril Soler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "csoler@users.sourceforge.net". - * - */ - -#pragma once - -// Derive from this class to be a client for the global router. Typical potential clients are: -// - the messaging system -// -class GRouterClient -{ - public: - virtual void receiveLongDistanceItem(void *data,uint32_t size) = 0 ; -}; - diff --git a/libretroshare/src/grouter/grouterclientservice.h b/libretroshare/src/grouter/grouterclientservice.h new file mode 100644 index 000000000..dfc40215d --- /dev/null +++ b/libretroshare/src/grouter/grouterclientservice.h @@ -0,0 +1,65 @@ +/* + * libretroshare/src/grouter: grouterclientservice.h + * + * Services for RetroShare. + * + * Copyright 2013 by Cyril Soler + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License Version 2 as published by the Free Software Foundation. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + * + * Please report all bugs and problems to "csoler@users.sourceforge.net". + * + */ + +// This class is the parent class for any service that will use the global router to distribute its packets. +// Typical representative clients include: +// +// p3msgservice: sends distant messages and advertise messaging keys +// +#pragma once + +#include +#include +#include + +class RsItem ; + +class GRouterClientService +{ + public: + // This method is called by the turtle router to send data that comes out of a turtle tunnel. + // The turtle router stays responsible for the memory management of data. Most of the time the + // data chunk is a serialized item to be de-serialized by the client service. + // + // Parameters: + // item : global router item. Handled by the client service. + // destination_key : key that is associated with this item. Can be useful for the client. + // + // GRouter stays owner of the item, so the client should not delete it! + // + virtual void receiveGRouterData(RsGRouterGenericDataItem * /*item*/,const GRouterKeyId& destination_key) + { + std::cerr << "!!!!!! Received Data from global router, but the client service is not handling it !!!!!!!!!!" << std::endl ; + std::cerr << " destination key_id = " << destination_key.toStdString() << std::endl; + } + + // This function is mandatory. It should do two things: + // 1 - keep a pointer to the global router, so as to be able to send data (e.g. copy pt into a local variable) + // 2 - call pt->registerTunnelService(this), so that the TR knows that service and can send back information to it. + // + virtual void connectToGlobalRouter(p3GRouter *pt) = 0 ; +}; + + diff --git a/libretroshare/src/grouter/grouteritems.cc b/libretroshare/src/grouter/grouteritems.cc index 98afad448..1f2121d98 100644 --- a/libretroshare/src/grouter/grouteritems.cc +++ b/libretroshare/src/grouter/grouteritems.cc @@ -55,12 +55,12 @@ bool RsGRouterPublishKeyItem::serialise(void *data, uint32_t& pktsize) const offset += 8 ; /* add mandatory parts first */ - ok &= setRawUInt32(data, tlvsize, &offset, diffusion_id); - ok &= setRawSha1(data, tlvsize, &offset, published_key); + ok &= setRawUInt32(data, tlvsize, &offset, diffusion_id); + ok &= published_key.serialise(data, tlvsize, offset) ; ok &= setRawUInt32(data, tlvsize, &offset, service_id); ok &= setRawUFloat32(data, tlvsize, &offset, randomized_distance); ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, description_string); - ok &= setRawPGPFingerprint(data, tlvsize, &offset, fingerprint); + ok &= fingerprint.serialise(data, tlvsize, offset) ; if (offset != tlvsize) { @@ -134,10 +134,9 @@ bool RsGRouterProofOfWorkObject::checkProofOfWork(unsigned char *mem,uint32_t si { Sha1CheckSum sum = RsDirUtil::sha1sum(mem,size) ; - for(uint32_t i=0;i<(7+PROOF_OF_WORK_REQUESTED_BYTES)/4;++i) - for(int j=0;j<(PROOF_OF_WORK_REQUESTED_BYTES%4);++j) - if(sum.fourbytes[i] & (0xff << (8*(3-j))) != 0) - return false ; + for(int i=0;idiffusion_id); // file hash - ok &= getRawSha1(data, pktsize, &offset, item->published_key); + ok &= item->published_key.deserialise(data, pktsize, offset) ; ok &= getRawUInt32(data, pktsize, &offset, &item->service_id); // file hash ok &= getRawUFloat32(data, pktsize, &offset, item->randomized_distance); // file hash ok &= GetTlvString(data, pktsize, &offset, TLV_TYPE_STR_VALUE,item->description_string); - ok &= getRawPGPFingerprint(data,pktsize,&offset,item->fingerprint) ; + ok &= item->fingerprint.deserialise(data,pktsize,offset) ; if (offset != rssize || !ok) { @@ -207,7 +206,7 @@ RsGRouterItem *RsGRouterSerialiser::deserialise_RsGRouterGenericDataItem(void *d RsGRouterGenericDataItem *item = new RsGRouterGenericDataItem() ; ok &= getRawUInt32(data, pktsize, &offset, &item->routing_id); // file hash - ok &= getRawSha1(data, pktsize, &offset, item->destination_key); + ok &= item->destination_key.deserialise(data, pktsize, offset) ; ok &= getRawUInt32(data, pktsize, &offset, &item->data_size); // file hash if( NULL == (item->data_bytes = (uint8_t*)malloc(item->data_size))) @@ -257,7 +256,7 @@ RsGRouterItem *RsGRouterSerialiser::deserialise_RsGRouterRoutingInfoItem(void *d RsGRouterRoutingInfoItem *item = new RsGRouterRoutingInfoItem() ; ok &= getRawUInt32(data, pktsize, &offset, &item->status_flags); - ok &= getRawSSLId(data, pktsize, &offset, item->origin); + ok &= item->origin.deserialise(data, pktsize, offset) ; ok &= getRawTimeT(data, pktsize, &offset, item->received_time); uint32_t s = 0 ; @@ -267,7 +266,7 @@ RsGRouterItem *RsGRouterSerialiser::deserialise_RsGRouterRoutingInfoItem(void *d { FriendTrialRecord ftr ; - ok &= getRawSSLId(data, pktsize, &offset, ftr.friend_id); + ok &= ftr.friend_id.deserialise(data, pktsize, offset) ; ok &= getRawTimeT(data, pktsize, &offset, ftr.time_stamp) ; item->tried_friends.push_back(ftr) ; @@ -276,7 +275,7 @@ RsGRouterItem *RsGRouterSerialiser::deserialise_RsGRouterRoutingInfoItem(void *d item->data_item = new RsGRouterGenericDataItem ; ok &= getRawUInt32(data, pktsize, &offset, &item->data_item->routing_id); - ok &= getRawSha1(data, pktsize, &offset, item->data_item->destination_key) ; + ok &= item->data_item->destination_key.deserialise(data, pktsize, offset) ; ok &= getRawUInt32(data, pktsize, &offset, &item->data_item->data_size) ; item->data_item->data_bytes = (uint8_t*)malloc(item->data_item->data_size) ; @@ -305,7 +304,7 @@ RsGRouterItem *RsGRouterSerialiser::deserialise_RsGRouterMatrixFriendListItem(vo item->reverse_friend_indices.resize(nb_friends) ; for(uint32_t i=0;ok && ireverse_friend_indices[i]) ; + ok &= item->reverse_friend_indices[i].deserialise(data, pktsize, offset) ; if (offset != rssize || !ok) { @@ -323,7 +322,7 @@ RsGRouterItem *RsGRouterSerialiser::deserialise_RsGRouterMatrixCluesItem(void *d RsGRouterMatrixCluesItem *item = new RsGRouterMatrixCluesItem() ; - ok &= getRawSha1(data,pktsize,&offset,item->destination_key) ; + ok &= item->destination_key.deserialise(data,pktsize,offset) ; uint32_t nb_clues = 0 ; ok &= getRawUInt32(data, pktsize, &offset, &nb_clues); @@ -395,7 +394,7 @@ bool RsGRouterGenericDataItem::serialise(void *data,uint32_t& size) const /* add mandatory parts first */ ok &= setRawUInt32(data, tlvsize, &offset, routing_id); - ok &= setRawSha1(data, tlvsize, &offset, destination_key); + ok &= destination_key.serialise(data, tlvsize, offset) ; ok &= setRawUInt32(data, tlvsize, &offset, data_size); memcpy(&((uint8_t*)data)[offset],data_bytes,data_size) ; @@ -445,24 +444,24 @@ uint32_t RsGRouterMatrixFriendListItem::serial_size() const { uint32_t s = 8 ; // header s += 4 ; // reverse_friend_indices.size() - s += 16 * reverse_friend_indices.size() ; // sha1 for published_key + s += RsFileHash::SIZE_IN_BYTES * reverse_friend_indices.size() ; // sha1 for published_key return s ; } uint32_t RsGRouterRoutingInfoItem::serial_size() const { - uint32_t s = 8 ; // header - s += 4 ; // status_flags - s += 16 ; // origin - s += 8 ; // received_time - s += 4 ; // tried_friends.size() ; + uint32_t s = 8 ; // header + s += 4 ; // status_flags + s += origin.SIZE_IN_BYTES ; // origin + s += 8 ; // received_time + s += 4 ; // tried_friends.size() ; - s += tried_friends.size() * ( 16 + 8 ) ; // FriendTrialRecord + s += tried_friends.size() * ( RsPeerId::SIZE_IN_BYTES + 8 ) ; // FriendTrialRecord - s += 4; // data_item->routing_id - s += 20; // data_item->destination_key - s += 4; // data_item->data_size - s += data_item->data_size; // data_item->data_bytes + s += 4; // data_item->routing_id + s += data_item->destination_key.SIZE_IN_BYTES; // data_item->destination_key + s += 4; // data_item->data_size + s += data_item->data_size; // data_item->data_bytes return s ; } @@ -479,7 +478,7 @@ bool RsGRouterMatrixFriendListItem::serialise(void *data,uint32_t& size) const ok &= setRawUInt32(data, tlvsize, &offset, reverse_friend_indices.size()); for(uint32_t i=0;ok && i::const_iterator it2(clues.begin());it2!=clues.end();++it2) @@ -518,37 +517,37 @@ bool RsGRouterMatrixCluesItem::serialise(void *data,uint32_t& size) const } bool RsGRouterRoutingInfoItem::serialise(void *data,uint32_t& size) const { - uint32_t tlvsize,offset=0; - bool ok = true; - - if(!serialise_header(data,size,tlvsize,offset)) - return false ; + uint32_t tlvsize,offset=0; + bool ok = true; - ok &= setRawUInt32(data, tlvsize, &offset, status_flags) ; - ok &= setRawSSLId(data, tlvsize, &offset, origin) ; - ok &= setRawTimeT(data, tlvsize, &offset, received_time) ; - ok &= setRawUInt32(data, tlvsize, &offset, tried_friends.size()) ; + if(!serialise_header(data,size,tlvsize,offset)) + return false ; - for(std::list::const_iterator it(tried_friends.begin());it!=tried_friends.end();++it) - { - ok &= setRawSSLId(data, tlvsize, &offset, (*it).friend_id) ; - ok &= setRawTimeT(data, tlvsize, &offset, (*it).time_stamp) ; - } + ok &= setRawUInt32(data, tlvsize, &offset, status_flags) ; + ok &= origin.serialise(data, tlvsize, offset) ; + ok &= setRawTimeT(data, tlvsize, &offset, received_time) ; + ok &= setRawUInt32(data, tlvsize, &offset, tried_friends.size()) ; - ok &= setRawUInt32(data, tlvsize, &offset, data_item->routing_id) ; - ok &= setRawSha1(data, tlvsize, &offset, data_item->destination_key) ; - ok &= setRawUInt32(data, tlvsize, &offset, data_item->data_size) ; + for(std::list::const_iterator it(tried_friends.begin());it!=tried_friends.end();++it) + { + ok &= (*it).friend_id.serialise(data, tlvsize, offset ) ; + ok &= setRawTimeT(data, tlvsize, &offset, (*it).time_stamp) ; + } - memcpy(&((uint8_t*)data)[offset],data_item->data_bytes,data_item->data_size) ; - offset += data_item->data_size ; + ok &= setRawUInt32(data, tlvsize, &offset, data_item->routing_id) ; + ok &= data_item->destination_key.serialise(data, tlvsize, offset) ; + ok &= setRawUInt32(data, tlvsize, &offset, data_item->data_size) ; - if (offset != tlvsize) - { - ok = false; - std::cerr << "rsfileitemserialiser::serialisedata() size error! " << std::endl; - } + memcpy(&((uint8_t*)data)[offset],data_item->data_bytes,data_item->data_size) ; + offset += data_item->data_size ; - return ok; + if (offset != tlvsize) + { + ok = false; + std::cerr << "rsfileitemserialiser::serialisedata() size error! " << std::endl; + } + + return ok; } // -----------------------------------------------------------------------------------// diff --git a/libretroshare/src/grouter/grouteritems.h b/libretroshare/src/grouter/grouteritems.h index c3caf6155..08aa511ec 100644 --- a/libretroshare/src/grouter/grouteritems.h +++ b/libretroshare/src/grouter/grouteritems.h @@ -26,7 +26,7 @@ #pragma once #include "serialiser/rsserial.h" -#include "util/rsid.h" +#include "retroshare/rstypes.h" #include "rsgrouter.h" #include "p3grouter.h" diff --git a/libretroshare/src/grouter/p3grouter.cc b/libretroshare/src/grouter/p3grouter.cc index 2bb39f177..67c6ec3ff 100644 --- a/libretroshare/src/grouter/p3grouter.cc +++ b/libretroshare/src/grouter/p3grouter.cc @@ -23,6 +23,153 @@ * */ +//////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// Decentralized routing +// ===================== +// +// Use cases: +// - Peer A asks for B's key, for which he has the signature, or the ID. +// - Peer A wants to send a private msg to peer C, for which he has the public key +// - Peer A wants to contact a channel's owner, a group owner, a forum owner, etc. +// - Peer C needs to route msg/key requests from unknown peer, to unknown peer so that the information +// eventually reach their destination. +// +// Main idea: Each peer holds a local routing table, a matrix with probabilities that each friend +// is a correct path for a given key ID. +// +// The routing tables are updated as messages go back and forth. Successful +// interactions feed the routing table with information of where to route the +// packets. +// +// The routing is kept probabilistic, meaning that the optimal route is not +// always chosen, but the randomness helps updating the routing probabilities. +// +// Services that might use the router (All services really...) +// - Identity manager (p3Identity) +// - asks identities i.e. RSA public keys (i.e. sends dentity requests through router) +// - Messenger +// - sends/receives messages to distant peers +// - Channels, forums, posted, etc. +// - send messages to the origin of the channel/forum/posted +// +// GUI +// - a debug panel should show the routing info: probabilities for all known IDs +// - routing probabilities for a given ID accordign to who's connected +// +// Decentralized routing algorithm: +// - tick() method +// * calls autoWash(), send() and receive() +// +// - message passing +// - upward: +// * Forward msg to friends according to probabilities. +// * If all equal, send to all friends (or a rando subset of them). +// * keep the local routing info in a cache that is saved (Which peer issued the msg) +// - which probability was used to chose this friend (will be useful +// to compute the routing contribution if the msg is ACK-ed) +// +// - downward: look into routing cache. If info not present, drop the item. +// Forward item into stored direction. +// +// - routing probability computation: count number of times a reliable info is obtained from +// which direction for which identity +// * the count is a floating point number, since weights can be assigned to each info +// (especially for importance sampling) +// * init: all friends have equal count of 0 (or 1, well, we'll have to make this right). +// * We use importance sampling, meaning that when peer relays a msg from ID: +// count[ID, peer] += 1.0 / importance +// +// ... where importance was the probability of chosing peer for the +// route upward. +// +// * probability of forward is proportional to count. +// +// - routing cache +// * this cache stores messages IDs (like turtle router) but is saved on disk +// * it is used to remember where to send back responses to messages, and +// with what probability the route was chosen. +// * cache items have a TTL and the cache is cleaned regularly. +// +// - routing matrix +// * the structure is fed by other services, when they receive key IDs. +// * stores for each identity the count of how many times each peer gave reliable info for that ID. +// That information should be enough to route packets in the correct direction. +// * saved to disk. +// * all contributions should have a time stamp. Regularly, the oldest contributions are removed. +// +// struct RoutingMatrixHitEntry +// { +// float weight ; +// time_t time_stamp ; +// } +// typedef std::map > RSAKeyRoutingMap ; +// +// class RoutingMatrix +// { +// public: +// // Computes the routing probabilities for this id for the given list of friends. +// // the computation accounts for the time at which the info was received and the +// // weight of each routing hit record. +// // +// bool computeRoutingProbabilities(RSAKeyIDType id, const std::vector& friends, +// std::vector& probas) const ; +// +// // remove oldest entries. +// bool autoWash() ; +// +// // Record one routing clue. The events can possibly be merged in time buckets. +// // +// bool addRoutingEvent(RSAKeyIDType id,const SSLIdType& which friend) ; +// +// private: +// std::map _known_keys ; +// }; +// +// - Routed packets: we use a common packet type for all services: +// +// We need two abstract item types: +// +// * Data packet +// - packet unique ID (sha1, or uint64_t) +// - destination ID (for Dn packets, the destination is the source!) +// - packet type: Id request, Message, etc. +// - packet service ID (Can be messenging, channels, etc). +// - packet data (void* + size_t) +// - flags (such as ACK or response required, and packet direction) +// * ACK packet. +// - packet unique ID (the id of the corresponding data) +// - flags (reason for ACK. Could be data delivered, or error, too far, etc) +// +// - Data storage packets +// * We need storage packets for the matrix states. +// * General routing options info? +// +// - estimated memory cost +// For each identity, the matrix needs +// - hits for each friend peer with time stamps. That means 8 bytes per hit. +// That is for 1000 identities, having at most 100 hits each (We keep +// the hits below a maximum. 100 seems ok.), that is 1000*100*8 < 1MB. Not much. +// +// - Main difficulties: +// * have a good re-try strategy if a msg does not arrive. +// * handle peer availability. In forward mode: easy. In backward mode: +// difficult. We should wait, and send back the packet if possible. +// * robustness +// * security: avoid flooding, and message alteration. +// +// - Questions to be solved +// * how do we talk to other services? +// - keep a list of services? +// +// - in practice, services will need to send requests, and expect responses. +// * gxs (p3identity) asks for a key, gxs (p3identity) should get the key. +// * msg service wants to send a distant msg, or msg receives a distant msg. +// +// => we need abstract packets and service ids. +// +//////////////////////////////////////////////////////////////////////////////////////////////////////////// + #include "util/rsrandom.h" #include "pqi/p3linkmgr.h" #include "serialiser/rsconfigitems.h" @@ -175,14 +322,10 @@ void p3GRouter::routePendingObjects() std::cerr << "p3GRouter::routeObjects() triage phase:" << std::endl; std::cerr << "Cached Items : " << _pending_messages.size() << std::endl; - std::list lst_tmp ; std::list lst ; - mLinkMgr->getOnlineList(lst_tmp) ; + mLinkMgr->getOnlineList(lst) ; RsPeerId own_id( mLinkMgr->getOwnId() ); - for(std::list::const_iterator it(lst_tmp.begin());it!=lst_tmp.end();++it) - lst.push_back(RsPeerId(*it)) ; - for(std::map::iterator it(_pending_messages.begin());it!=_pending_messages.end();) if((it->second.status_flags & RS_GROUTER_ROUTING_STATE_PEND) || (it->second.status_flags == RS_GROUTER_ROUTING_STATE_SENT && it->second.tried_friends.front().time_stamp+RS_GROUTER_ROUTING_WAITING_TIME < now)) { @@ -255,10 +398,10 @@ void p3GRouter::routePendingObjects() std::cerr << " Sending..." << std::endl; // send - new_item->PeerId(routed_friend.toStdString()) ; + new_item->PeerId(routed_friend) ; sendItem(new_item) ; } - else if(it->second.origin.toStdString() != mLinkMgr->getOwnId() || std::find(lst.begin(),lst.end(),it->second.origin) != lst.end()) + else if(it->second.origin != mLinkMgr->getOwnId() || std::find(lst.begin(),lst.end(),it->second.origin) != lst.end()) { // There's no correct friend to send this item to. We keep it for a while. If it's too old, // we discard it. For now, the procedure is to send back an ACK. @@ -320,7 +463,7 @@ void p3GRouter::publishKeys() item.randomized_distance = drand48() ; item.fingerprint = info.fpr; item.description_string = info.description_string ; - item.PeerId("") ; // no peer id => key is forwarded to all friends. + item.PeerId(RsPeerId()) ; // no peer id => key is forwarded to all friends. locked_forwardKey(item) ; @@ -332,14 +475,14 @@ void p3GRouter::publishKeys() void p3GRouter::locked_forwardKey(const RsGRouterPublishKeyItem& item) { - std::list connected_peers ; + std::list connected_peers ; mLinkMgr->getOnlineList(connected_peers) ; std::cerr << " Forwarding key item to all available friends..." << std::endl; // get list of connected friends, and broadcast to all of them // - for(std::list::const_iterator it(connected_peers.begin());it!=connected_peers.end();++it) + for(std::list::const_iterator it(connected_peers.begin());it!=connected_peers.end();++it) if(item.PeerId() != *it) { std::cerr << " sending to " << (*it) << std::endl; @@ -496,7 +639,7 @@ void p3GRouter::handleRecvACKItem(RsGRouterACKItem *item) break ; } - if(it->second.origin.toStdString() == mLinkMgr->getOwnId()) + if(it->second.origin == mLinkMgr->getOwnId()) { // find the client service and notify it. std::cerr << " We're owner: should notify client id" << std::endl; @@ -511,7 +654,7 @@ void p3GRouter::handleRecvACKItem(RsGRouterACKItem *item) void p3GRouter::handleRecvDataItem(RsGRouterGenericDataItem *item) { RsStackMutex mtx(grMtx) ; - std::cerr << "Received data item for key " << item->destination_key.toStdString() << std::endl; + std::cerr << "Received data item for key " << item->destination_key << std::endl; // Do we have this item in the cache already? // - if not, add in the pending items @@ -612,7 +755,7 @@ void p3GRouter::sendACK(const RsPeerId& peer, GRouterMsgPropagationId mid, uint3 item->state = ack_flags ; item->mid = mid ; - item->PeerId(peer.toStdString()) ; + item->PeerId(peer) ; sendItem(item) ; } diff --git a/libretroshare/src/grouter/p3grouter.h b/libretroshare/src/grouter/p3grouter.h index ee7d5e4e1..f386ddf92 100644 --- a/libretroshare/src/grouter/p3grouter.h +++ b/libretroshare/src/grouter/p3grouter.h @@ -31,7 +31,7 @@ #include "rsgrouter.h" #include "services/p3service.h" #include "pqi/p3cfgmgr.h" -#include "util/rsid.h" +#include "retroshare/rstypes.h" #include "groutertypes.h" #include "groutermatrix.h" diff --git a/libretroshare/src/retroshare/rstypes.h b/libretroshare/src/retroshare/rstypes.h index 221998fe3..9db36aaab 100644 --- a/libretroshare/src/retroshare/rstypes.h +++ b/libretroshare/src/retroshare/rstypes.h @@ -67,25 +67,6 @@ const uint32_t RS_CONFIG_DIRECTORY = 0x0002 ; const uint32_t RS_PGP_DIRECTORY = 0x0003 ; const uint32_t RS_DIRECTORY_COUNT = 0x0004 ; -//class Sha1CheckSum -//{ -// public: -// Sha1CheckSum() {} -// explicit Sha1CheckSum(const uint8_t *twenty_bytes_digest) ; // inits form a 20-bytes digest. -// explicit Sha1CheckSum(const std::string& fourty_bytes_string) ; // inits form a 40 bytes hexadecimal string. -// -// static Sha1CheckSum random() ; -// -// std::string toStdString() const ; -// -// bool operator==(const Sha1CheckSum& s) const ; -// bool operator<(const Sha1CheckSum& s) const ; -// -// friend std::ostream& operator<<(std::ostream& out,const Sha1CheckSum& sum) { return out << sum.toStdString() ; } -//// private: -// uint32_t fourbytes[5] ; -//}; - class TransferInfo { public: diff --git a/libretroshare/src/services/p3idservice.cc b/libretroshare/src/services/p3idservice.cc index f7b206b29..d3a00141b 100644 --- a/libretroshare/src/services/p3idservice.cc +++ b/libretroshare/src/services/p3idservice.cc @@ -737,7 +737,7 @@ std::string SSGxsIdPgp::save() const bool SSGxsIdRecognTags::load(const std::string &input) { - char pgpline[RSGXSID_MAX_SERVICE_STRING]; + //char pgpline[RSGXSID_MAX_SERVICE_STRING]; int pubTs = 0; int lastTs = 0; uint32_t flags = 0; @@ -1200,7 +1200,7 @@ bool p3IdService::cache_process_recogntaginfo(const RsGxsIdGroupItem *item, std: recogn_extract_taginfo(item, tagItems); - time_t now = time(NULL); + //time_t now = time(NULL); for(it = tagItems.begin(); it != tagItems.end(); it++) { RsRecognTag info((*it)->tag_class, (*it)->tag_type, false); @@ -2857,7 +2857,7 @@ void p3IdService::generateDummy_OwnIds() RsPgpId ownId = rsPeers->getGPGOwnId(); // generate some ownIds. - int genCount = 0; + //int genCount = 0; int i; int nIds = 2 + (RSRandom::random_u32() % 2); @@ -3196,8 +3196,8 @@ bool p3IdService::background_checkTokenRequest() uint32_t status; - uint32_t reqtype; - uint32_t anstype; + //uint32_t reqtype; + //uint32_t anstype; time_t ts; diff --git a/libretroshare/src/services/p3msgservice.cc b/libretroshare/src/services/p3msgservice.cc index 2c28a47ab..1af330494 100644 --- a/libretroshare/src/services/p3msgservice.cc +++ b/libretroshare/src/services/p3msgservice.cc @@ -94,12 +94,12 @@ p3MsgService::p3MsgService(p3LinkMgr *lm) const RsPgpId& gpg_id = rsPeers->getGPGOwnId() ; RsPeerDetails d; - rsPeers->getPeerDetails(gpg_id,d) ; + rsPeers->getGPGDetails(gpg_id,d) ; PGPFingerprintType fingerp( d.fpr ) ; // Re-hash the SSL id, to make it one way. Will be replaced by proper invitations in the future. // - GRouterKeyId key ( RsDirUtil::sha1sum( (uint8_t*)own_ssl_id.c_str(),own_ssl_id.length() ).toStdString() ) ; + GRouterKeyId key ( RsDirUtil::sha1sum( own_ssl_id.toByteArray(),own_ssl_id.SIZE_IN_BYTES )) ; static GRouterServiceId client_id = GROUTER_CLIENT_ID_MESSAGES; static std::string description = "Test string for debug purpose" ; @@ -2162,12 +2162,12 @@ void p3MsgService::enableDistantMessaging(bool b) const RsPgpId& gpg_id = rsPeers->getGPGOwnId() ; RsPeerDetails d; - rsPeers->getPeerDetails(gpg_id,d) ; + rsPeers->getGPGDetails(gpg_id,d) ; PGPFingerprintType fingerp( d.fpr ) ; // Re-hash the SSL id, to make it one way. Will be replaced by proper invitations in the future. // - GRouterKeyId key ( RsDirUtil::sha1sum( (uint8_t*)own_ssl_id.c_str(),own_ssl_id.length() ).toStdString() ) ; + GRouterKeyId key ( RsDirUtil::sha1sum( own_ssl_id.toByteArray(),own_ssl_id.SIZE_IN_BYTES ) ) ; static GRouterServiceId client_id = GROUTER_CLIENT_ID_MESSAGES; static std::string description = "Test string for debug purpose" ; diff --git a/libretroshare/src/util/rsdiscspace.cc b/libretroshare/src/util/rsdiscspace.cc index 63ba08d11..5b5e4ffba 100644 --- a/libretroshare/src/util/rsdiscspace.cc +++ b/libretroshare/src/util/rsdiscspace.cc @@ -134,7 +134,7 @@ bool RsDiscSpace::checkForDiscSpace(RsDiscSpace::DiscLocation loc) { RsStackMutex m(_mtx) ; // Locked - if(_partials_path == "" && loc == RS_PARTIALS_DIRECTORY || _download_path == "" && loc == RS_DOWNLOAD_DIRECTORY) + if( (_partials_path == "" && loc == RS_PARTIALS_DIRECTORY) || (_download_path == "" && loc == RS_DOWNLOAD_DIRECTORY)) throw std::runtime_error("Download path and partial path not properly set in RsDiscSpace. Please call RsDiscSpace::setPartialsPath() and RsDiscSpace::setDownloadPath()") ; time_t now = time(NULL) ;