2010-07-17 13:00:19 -04:00
|
|
|
/*
|
|
|
|
* libretroshare/src/dht: p3bitdht.h
|
|
|
|
*
|
|
|
|
* BitDht interface for RetroShare.
|
|
|
|
*
|
|
|
|
* Copyright 2009-2010 by Robert Fernie.
|
|
|
|
*
|
|
|
|
* 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 "retroshare@lunamutt.com".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef MRK_P3_BITDHT_H
|
|
|
|
#define MRK_P3_BITDHT_H
|
|
|
|
|
|
|
|
#include "pqi/pqiassist.h"
|
2011-12-19 21:07:00 -05:00
|
|
|
#include "pqi/p3cfgmgr.h"
|
2011-07-06 09:04:50 -04:00
|
|
|
#include "retroshare/rsdht.h"
|
2010-07-17 13:00:19 -04:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <map>
|
|
|
|
#include "pqi/pqinetwork.h"
|
|
|
|
#include "pqi/pqimonitor.h"
|
|
|
|
#include "util/rsthreads.h"
|
|
|
|
|
|
|
|
#include "udp/udpstack.h"
|
|
|
|
#include "udp/udpbitdht.h"
|
|
|
|
#include "bitdht/bdiface.h"
|
|
|
|
|
2011-07-09 20:39:15 -04:00
|
|
|
#include "dht/connectstatebox.h"
|
2011-07-06 09:04:50 -04:00
|
|
|
|
|
|
|
class DhtPeerDetails
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2011-07-18 20:06:09 -04:00
|
|
|
DhtPeerDetails();
|
|
|
|
|
2011-07-09 20:39:15 -04:00
|
|
|
uint32_t mPeerType;
|
|
|
|
|
2011-07-06 09:04:50 -04:00
|
|
|
bdId mDhtId;
|
2014-03-17 16:56:06 -04:00
|
|
|
RsPeerId mRsId;
|
2011-07-06 09:04:50 -04:00
|
|
|
|
2011-07-09 20:39:15 -04:00
|
|
|
/* direct from the DHT! */
|
|
|
|
uint32_t mDhtState; // One of RSDHT_PEERDHT_[...]
|
|
|
|
time_t mDhtUpdateTS;
|
|
|
|
|
|
|
|
/* internal state */
|
|
|
|
PeerConnectStateBox mConnectLogic;
|
|
|
|
|
|
|
|
/* Actual Connection Status */
|
|
|
|
uint32_t mPeerConnectState; // One of RSDHT_PEERCONN_
|
|
|
|
std::string mPeerConnectMsg;
|
|
|
|
uint32_t mPeerConnectMode;
|
|
|
|
bdId mPeerConnectPeerId;
|
|
|
|
bdId mPeerConnectProxyId;
|
|
|
|
struct sockaddr_in mPeerConnectAddr;
|
|
|
|
uint32_t mPeerConnectPoint;
|
|
|
|
|
|
|
|
time_t mPeerConnectUdpTS;
|
|
|
|
time_t mPeerConnectTS;
|
|
|
|
time_t mPeerConnectClosedTS;
|
|
|
|
|
2011-07-17 09:48:37 -04:00
|
|
|
bool mExclusiveProxyLock;
|
|
|
|
|
2011-07-09 20:39:15 -04:00
|
|
|
/* keeping the PeerCbMsg, as we will need it for debugging */
|
|
|
|
/* don't think this data is ever used for decisions??? */
|
|
|
|
|
|
|
|
/* Connection Request Status */
|
|
|
|
std::string mPeerReqStatusMsg;
|
|
|
|
uint32_t mPeerReqState;
|
|
|
|
uint32_t mPeerReqMode;
|
|
|
|
bdId mPeerReqProxyId;
|
|
|
|
time_t mPeerReqTS;
|
|
|
|
|
|
|
|
/* Callback Info */
|
|
|
|
std::string mPeerCbMsg;
|
|
|
|
uint32_t mPeerCbMode;
|
|
|
|
uint32_t mPeerCbPoint;
|
|
|
|
bdId mPeerCbProxyId;
|
|
|
|
bdId mPeerCbDestId;
|
|
|
|
time_t mPeerCbTS;
|
|
|
|
|
2011-07-06 09:04:50 -04:00
|
|
|
};
|
|
|
|
|
2011-07-09 20:39:15 -04:00
|
|
|
#define PEERNET_ACTION_TYPE_CONNECT 1
|
|
|
|
#define PEERNET_ACTION_TYPE_AUTHORISE 2
|
|
|
|
#define PEERNET_ACTION_TYPE_START 3
|
|
|
|
#define PEERNET_ACTION_TYPE_RESTARTREQ 4
|
|
|
|
#define PEERNET_ACTION_TYPE_KILLREQ 5
|
2011-07-14 10:56:33 -04:00
|
|
|
#define PEERNET_ACTION_TYPE_TCPATTEMPT 6
|
2011-07-09 20:39:15 -04:00
|
|
|
|
|
|
|
class PeerAction
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
uint32_t mType;
|
|
|
|
bdId mSrcId;
|
|
|
|
bdId mProxyId;
|
|
|
|
bdId mDestId;
|
|
|
|
uint32_t mMode;
|
|
|
|
uint32_t mPoint;
|
|
|
|
uint32_t mAnswer;
|
2011-07-17 09:48:37 -04:00
|
|
|
uint32_t mDelayOrBandwidth;
|
2011-07-09 20:39:15 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-12-13 11:19:37 -05:00
|
|
|
/******
|
|
|
|
* Adding the ability to install alternative Handler
|
|
|
|
* for monitoring/controlling Relay Connections outside of p3bitdht.
|
|
|
|
***/
|
|
|
|
|
|
|
|
class p3BitDhtRelayHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
int (*mInstallRelay)(const bdId *srcId, const bdId *destId, uint32_t mode, uint32_t &bandwidth);
|
|
|
|
int (*mLogFailedConnection)(const bdId *srcId, const bdId *destId, uint32_t mode, uint32_t errcode);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-07-09 20:39:15 -04:00
|
|
|
|
2011-07-06 09:04:50 -04:00
|
|
|
class UdpRelayReceiver;
|
2016-06-21 07:55:23 -04:00
|
|
|
#ifdef RS_USE_DHT_STUNNER
|
2011-07-06 09:04:50 -04:00
|
|
|
class UdpStunner;
|
2016-06-21 07:55:23 -04:00
|
|
|
#endif // RS_USE_DHT_STUNNER
|
2011-07-09 20:39:15 -04:00
|
|
|
class p3NetMgr;
|
2011-07-06 09:04:50 -04:00
|
|
|
|
2011-12-19 21:07:00 -05:00
|
|
|
class p3BitDht: public p3Config, public pqiNetAssistConnect, public RsDht
|
2010-07-17 13:00:19 -04:00
|
|
|
{
|
2015-05-26 17:17:09 -04:00
|
|
|
public:
|
|
|
|
p3BitDht(const RsPeerId& id, pqiConnectCb *cb, p3NetMgr *nm,
|
|
|
|
UdpStack *udpstack, std::string bootstrapfile, const std::string &filteredipfile);
|
2010-07-17 13:00:19 -04:00
|
|
|
|
2011-07-06 09:04:50 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
virtual ~p3BitDht();
|
2010-07-17 13:00:19 -04:00
|
|
|
|
2011-07-06 09:04:50 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
/***********************************************************************************************
|
2011-07-06 09:04:50 -04:00
|
|
|
********** External RsDHT Interface (defined in libretroshare/src/retroshare/rsdht.h) *********
|
|
|
|
************************************************************************************************/
|
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
virtual uint32_t getNetState(uint32_t type);
|
|
|
|
virtual int getDhtPeers(int lvl, std::list<RsDhtPeer> &peers);
|
|
|
|
virtual int getNetPeerList(std::list<RsPeerId> &peerIds);
|
|
|
|
virtual int getNetPeerStatus(const RsPeerId& peerId, RsDhtNetPeer &status);
|
2011-07-06 09:04:50 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
virtual int getRelayEnds(std::list<RsDhtRelayEnd> &relayEnds);
|
|
|
|
virtual int getRelayProxies(std::list<RsDhtRelayProxy> &relayProxies);
|
2011-07-06 09:04:50 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
//virtual int getNetFailedPeer(std::string peerId, PeerStatus &status);
|
2011-07-06 09:04:50 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
virtual std::string getUdpAddressString();
|
2011-07-18 20:06:09 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
virtual void getDhtRates(float &read, float &write);
|
|
|
|
virtual void getRelayRates(float &read, float &write, float &relay);
|
2011-12-19 13:56:11 -05:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
virtual bool getOwnDhtId(std::string &ownDhtId);
|
2012-12-17 14:15:04 -05:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
/***********************************************************************************************
|
2011-07-06 09:04:50 -04:00
|
|
|
********** External RsDHT Interface (defined in libretroshare/src/retroshare/rsdht.h) *********
|
|
|
|
************************************************************************************************/
|
|
|
|
|
2016-06-21 07:55:23 -04:00
|
|
|
#ifdef RS_USE_DHT_STUNNER
|
2015-05-26 17:17:09 -04:00
|
|
|
void setupConnectBits(UdpStunner *dhtStunner, UdpStunner *proxyStunner, UdpRelayReceiver *relay);
|
2016-06-21 07:55:23 -04:00
|
|
|
#else // RS_USE_DHT_STUNNER
|
|
|
|
void setupConnectBits(UdpRelayReceiver *relay);
|
|
|
|
#endif // RS_USE_DHT_STUNNER
|
2015-05-26 17:17:09 -04:00
|
|
|
void setupPeerSharer(pqiNetAssistPeerShare *sharer);
|
|
|
|
void modifyNodesPerBucket(uint16_t count);
|
2011-07-06 09:04:50 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
void start(); /* starts up the bitdht thread */
|
2010-07-31 14:14:10 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
/* pqiNetAssist - external interface functions */
|
|
|
|
virtual int tick();
|
|
|
|
virtual void enable(bool on);
|
|
|
|
virtual void shutdown(); /* blocking call */
|
|
|
|
virtual void restart();
|
2010-07-17 13:00:19 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
virtual bool getEnabled();
|
|
|
|
virtual bool getActive();
|
|
|
|
virtual bool getNetworkStats(uint32_t &netsize, uint32_t &localnetsize);
|
2010-07-17 13:00:19 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
/* pqiNetAssistConnect - external interface functions */
|
2010-07-17 13:00:19 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
/* add / remove peers */
|
|
|
|
virtual bool findPeer(const RsPeerId& id);
|
|
|
|
virtual bool dropPeer(const RsPeerId& id);
|
2010-07-17 13:00:19 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
virtual int addBadPeer(const struct sockaddr_storage &addr, uint32_t reason, uint32_t flags, uint32_t age);
|
|
|
|
virtual int addKnownPeer(const RsPeerId &pid, const struct sockaddr_storage &addr, uint32_t flags);
|
|
|
|
//virtual int addFriend(const std::string pid);
|
|
|
|
//virtual int addFriendOfFriend(const std::string pid);
|
|
|
|
//virtual int addOther(const std::string pid);
|
2011-07-18 20:06:09 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
/* feedback on success failure of Connections */
|
|
|
|
virtual void ConnectionFeedback(const RsPeerId& pid, int state);
|
2011-07-13 18:23:40 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
/* extract current peer status */
|
|
|
|
virtual bool getPeerStatus(const RsPeerId& id,
|
|
|
|
struct sockaddr_storage &laddr, struct sockaddr_storage &raddr,
|
|
|
|
uint32_t &type, uint32_t &mode);
|
2010-07-17 13:00:19 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
virtual bool getExternalInterface(struct sockaddr_storage &raddr,
|
|
|
|
uint32_t &mode);
|
2010-07-17 13:00:19 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
virtual bool isAddressBanned(const struct sockaddr_storage& raddr) ;
|
|
|
|
virtual void getListOfBannedIps(std::list<RsDhtFilteredPeer> &lst) ;
|
2011-07-21 07:28:19 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
virtual bool setAttachMode(bool on);
|
2011-07-21 07:28:19 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
/* notifyPeer/setExtInterface/Bootstrap/Stun
|
|
|
|
* hould all be removed from NetAssist?
|
|
|
|
*/
|
2010-07-31 14:14:10 -04:00
|
|
|
|
2011-07-13 18:23:40 -04:00
|
|
|
|
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
/* pqiNetAssistConnect - external interface functions */
|
2010-07-31 14:14:10 -04:00
|
|
|
|
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
/***********************************************************************************************
|
2011-07-09 20:39:15 -04:00
|
|
|
****************************** Connections (p3bitdht_peernet.cc) ******************************
|
|
|
|
************************************************************************************************/
|
2015-05-26 17:17:09 -04:00
|
|
|
/* Feedback from RS Upper Layers */
|
|
|
|
//virtual void ConnectionFeedback(std::string pid, int state);
|
2011-07-09 20:39:15 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
/* Callback functions - from bitdht */
|
|
|
|
int NodeCallback(const bdId *id, uint32_t peerflags);
|
|
|
|
int PeerCallback(const bdId *id, uint32_t status);
|
|
|
|
int ValueCallback(const bdNodeId *id, std::string key, uint32_t status);
|
|
|
|
int ConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId *destId,
|
|
|
|
uint32_t mode, uint32_t point, uint32_t param, uint32_t cbtype, uint32_t errcode);
|
|
|
|
int InfoCallback(const bdId *id, uint32_t type, uint32_t flags, std::string info);
|
2011-11-24 19:58:01 -05:00
|
|
|
|
2011-07-09 20:39:15 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
int OnlinePeerCallback_locked(const bdId *id, uint32_t status, DhtPeerDetails *dpd);
|
|
|
|
int UnreachablePeerCallback_locked(const bdId *id, uint32_t status, DhtPeerDetails *dpd);
|
|
|
|
//int tick();
|
|
|
|
int minuteTick();
|
|
|
|
int doActions();
|
|
|
|
int checkProxyAllowed(const bdId *srcId, const bdId *destId, int mode, uint32_t &bandwidth);
|
|
|
|
int checkConnectionAllowed(const bdId *peerId, int mode);
|
|
|
|
void initiateConnection(const bdId *srcId, const bdId *proxyId, const bdId *destId, uint32_t mode, uint32_t loc, uint32_t delayOrBandwidth);
|
|
|
|
int installRelayConnection(const bdId *srcId, const bdId *destId, uint32_t &bandwidth);
|
|
|
|
int removeRelayConnection(const bdId *srcId, const bdId *destId);
|
|
|
|
void monitorConnections();
|
2011-07-09 20:39:15 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
void ConnectCallout(const RsPeerId &peerId, struct sockaddr_in addr, uint32_t connectMode);
|
2011-07-14 10:56:33 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
void ConnectCalloutTCPAttempt(const RsPeerId &peerId, struct sockaddr_in addr);
|
|
|
|
void ConnectCalloutDirectOrProxy(const RsPeerId &peerId, struct sockaddr_in raddr, uint32_t connectFlags, uint32_t delay);
|
|
|
|
void ConnectCalloutRelay(const RsPeerId &peerId, struct sockaddr_in srcaddr,
|
|
|
|
struct sockaddr_in proxyaddr, struct sockaddr_in destaddr,
|
|
|
|
uint32_t connectMode, uint32_t bandwidth);
|
2011-07-14 10:56:33 -04:00
|
|
|
|
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
void Feedback_Connected(const RsPeerId& pid);
|
|
|
|
void Feedback_ConnectionFailed(const RsPeerId& pid);
|
|
|
|
void Feedback_ConnectionClosed(const RsPeerId& pid);
|
2011-07-09 20:39:15 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
void UdpConnectionFailed_locked(DhtPeerDetails *dpd);
|
|
|
|
void ReleaseProxyExclusiveMode_locked(DhtPeerDetails *dpd, bool addrChgLikely);
|
2011-07-17 09:48:37 -04:00
|
|
|
|
2011-07-13 18:23:40 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
/*** RELAY HANDLER CODE ***/
|
|
|
|
void installRelayHandler(p3BitDhtRelayHandler *);
|
|
|
|
UdpRelayReceiver *getRelayReceiver();
|
2011-12-13 11:19:37 -05:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
int RelayHandler_InstallRelayConnection(const bdId *srcId, const bdId *destId, uint32_t mode, uint32_t &bandwidth);
|
|
|
|
int RelayHandler_LogFailedProxyAttempt(const bdId *srcId, const bdId *destId, uint32_t mode, uint32_t errcode);
|
2011-12-13 11:19:37 -05:00
|
|
|
|
|
|
|
|
2011-12-19 21:07:00 -05:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
/***********************************************************************************************
|
2011-12-19 21:07:00 -05:00
|
|
|
******************** Relay Config Stuff (TEMP - MOSTLY, in p3bitdht_relay.cc) *****************
|
|
|
|
********** External RsDHT Interface (defined in libretroshare/src/retroshare/rsdht.h) *********
|
|
|
|
************************************************************************************************/
|
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
// Interface for controlling Relays & DHT Relay Mode
|
|
|
|
virtual int getRelayServerList(std::list<std::string> &ids);
|
|
|
|
virtual int addRelayServer(std::string ids);
|
|
|
|
virtual int removeRelayServer(std::string ids);
|
2011-12-19 21:07:00 -05:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
virtual uint32_t getRelayMode();
|
|
|
|
virtual int setRelayMode(uint32_t mode);
|
2011-12-19 21:07:00 -05:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
virtual int getRelayAllowance(int classIdx, uint32_t &count, uint32_t &bandwidth);
|
|
|
|
virtual int setRelayAllowance(int classIdx, uint32_t count, uint32_t bandwidth);
|
2011-12-19 21:07:00 -05:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
private:
|
2011-12-19 21:07:00 -05:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
// Relay Handling Code / Variables (Mutex Protected).
|
|
|
|
int setupRelayDefaults();
|
|
|
|
int pushRelayServers();
|
2011-12-19 21:07:00 -05:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
std::list<std::string> mRelayServerList;
|
|
|
|
uint32_t mRelayMode;
|
2011-12-19 21:07:00 -05:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
protected:
|
|
|
|
/*****************************************************************/
|
|
|
|
/*********************** p3config ******************************/
|
|
|
|
/* Key Functions to be overloaded for Full Configuration */
|
|
|
|
virtual RsSerialiser *setupSerialiser();
|
|
|
|
virtual bool saveList(bool &cleanup, std::list<RsItem *>&);
|
|
|
|
virtual void saveDone();
|
|
|
|
virtual bool loadList(std::list<RsItem *>& load);
|
|
|
|
/*****************************************************************/
|
2011-12-19 21:07:00 -05:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
// DATA RATES: Variables (Mutex Protected).
|
|
|
|
private:
|
2012-01-19 11:23:57 -05:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
void updateDataRates();
|
|
|
|
void clearDataRates();
|
2012-01-19 11:23:57 -05:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
float mRelayReadRate;
|
|
|
|
float mRelayWriteRate;
|
|
|
|
float mRelayRelayRate;
|
|
|
|
float mDhtReadRate;
|
|
|
|
float mDhtWriteRate;
|
2012-01-19 11:23:57 -05:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
time_t mLastDataRateUpdate;
|
2012-01-19 11:23:57 -05:00
|
|
|
|
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
/***********************************************************************************************
|
2011-07-09 20:39:15 -04:00
|
|
|
************************** Internal Accounting (p3bitdht_peers.cc) ****************************
|
|
|
|
************************************************************************************************/
|
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
public:
|
2011-07-09 20:39:15 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
int removePeer(const RsPeerId& pid);
|
2010-07-17 13:00:19 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
// Can be used externally too.
|
|
|
|
int calculateNodeId(const RsPeerId& pid, bdNodeId *id);
|
|
|
|
int addKnownNode(const bdId *id, uint32_t flags);
|
2011-12-13 11:19:37 -05:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
private:
|
2010-07-17 13:00:19 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
DhtPeerDetails *addInternalPeer_locked(const RsPeerId& pid, uint32_t type);
|
|
|
|
int removeInternalPeer_locked(const RsPeerId& pid);
|
|
|
|
DhtPeerDetails *findInternalDhtPeer_locked(const bdNodeId *id, uint32_t type);
|
|
|
|
DhtPeerDetails *findInternalRsPeer_locked(const RsPeerId &pid);
|
2011-07-09 20:39:15 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
bool havePeerTranslation_locked(const RsPeerId &pid);
|
|
|
|
int lookupNodeId_locked(const RsPeerId& pid, bdNodeId *id);
|
|
|
|
int lookupRsId_locked(const bdNodeId *id, RsPeerId &pid);
|
|
|
|
int storeTranslation_locked(const RsPeerId& pid);
|
|
|
|
int removeTranslation_locked(const RsPeerId& pid);
|
2010-07-17 13:00:19 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
UdpBitDht *mUdpBitDht; /* has own mutex, is static except for creation/destruction */
|
2016-06-21 07:55:23 -04:00
|
|
|
#ifdef RS_USE_DHT_STUNNER
|
2015-05-26 17:17:09 -04:00
|
|
|
UdpStunner *mDhtStunner;
|
|
|
|
UdpStunner *mProxyStunner;
|
2016-06-21 07:55:23 -04:00
|
|
|
#endif // RS_USE_DHT_STUNNER
|
2015-05-26 17:17:09 -04:00
|
|
|
UdpRelayReceiver *mRelay;
|
2010-07-17 13:00:19 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
p3NetMgr *mNetMgr;
|
2011-07-09 20:39:15 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
pqiNetAssistPeerShare *mPeerSharer;
|
2011-11-24 19:58:01 -05:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
bdDhtFunctions *mDhtFns;
|
2012-01-13 20:54:17 -05:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
RsMutex dhtMtx;
|
2011-07-09 20:39:15 -04:00
|
|
|
|
2011-12-13 11:19:37 -05:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
p3BitDhtRelayHandler *mRelayHandler;
|
2011-12-13 11:19:37 -05:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
RsPeerId mOwnRsId;
|
|
|
|
bdNodeId mOwnDhtId;
|
2011-07-13 05:12:31 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
time_t mMinuteTS;
|
2011-07-09 20:39:15 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
/* translation maps */
|
|
|
|
std::map<RsPeerId, bdNodeId> mTransToNodeId;
|
|
|
|
std::map<bdNodeId, RsPeerId> mTransToRsId;
|
2010-07-17 13:00:19 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
std::map<bdNodeId, DhtPeerDetails> mPeers;
|
|
|
|
std::map<bdNodeId, DhtPeerDetails> mFailedPeers;
|
2011-07-09 20:39:15 -04:00
|
|
|
|
2015-05-26 17:17:09 -04:00
|
|
|
/* Connection Action Queue */
|
|
|
|
std::list<PeerAction> mActions;
|
2011-07-09 20:39:15 -04:00
|
|
|
|
2010-07-17 13:00:19 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* MRK_P3_BITDHT_H */
|
|
|
|
|