2018-05-28 22:28:51 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* libretroshare/src/retroshare: rsdht.h *
|
|
|
|
* *
|
|
|
|
* libretroshare: retroshare core library *
|
|
|
|
* *
|
|
|
|
* Copyright 2011-2011 by Robert Fernie <retroshare@lunamutt.com> *
|
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Lesser General Public License as *
|
|
|
|
* published by the Free Software Foundation, either version 3 of the *
|
|
|
|
* License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU Lesser General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License *
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
*******************************************************************************/
|
2011-07-06 13:04:50 +00:00
|
|
|
#ifndef RETROSHARE_DHT_GUI_INTERFACE_H
|
|
|
|
#define RETROSHARE_DHT_GUI_INTERFACE_H
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <string>
|
|
|
|
#include <list>
|
2014-03-17 20:56:06 +00:00
|
|
|
#include <retroshare/rstypes.h>
|
2015-05-27 11:53:08 +00:00
|
|
|
#include "util/rsnet.h"
|
2011-07-06 13:04:50 +00:00
|
|
|
|
|
|
|
/* The Main Interface Class - for information about your Peers */
|
|
|
|
class RsDht;
|
|
|
|
extern RsDht *rsDht;
|
|
|
|
|
|
|
|
//std::ostream &operator<<(std::ostream &out, const RsPhotoShowDetails &detail);
|
|
|
|
//std::ostream &operator<<(std::ostream &out, const RsPhotoDetails &detail);
|
|
|
|
|
2011-07-09 18:39:34 +00:00
|
|
|
#define RSDHT_NETSTART_NETWORKMODE 0x0001
|
|
|
|
#define RSDHT_NETSTART_NATTYPE 0x0002
|
|
|
|
#define RSDHT_NETSTART_NATHOLE 0x0003
|
|
|
|
#define RSDHT_NETSTART_CONNECTMODES 0x0004
|
|
|
|
#define RSDHT_NETSTART_NETSTATE 0x0005
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define RSDHT_PEERTYPE_ANY 0x0000
|
|
|
|
#define RSDHT_PEERTYPE_OTHER 0x0001
|
|
|
|
#define RSDHT_PEERTYPE_FOF 0x0002
|
|
|
|
#define RSDHT_PEERTYPE_FRIEND 0x0003
|
|
|
|
|
|
|
|
#define RSDHT_PEERDHT_NOT_ACTIVE 0x0000
|
|
|
|
#define RSDHT_PEERDHT_SEARCHING 0x0001
|
|
|
|
#define RSDHT_PEERDHT_FAILURE 0x0002
|
|
|
|
#define RSDHT_PEERDHT_OFFLINE 0x0003
|
|
|
|
#define RSDHT_PEERDHT_UNREACHABLE 0x0004
|
|
|
|
#define RSDHT_PEERDHT_ONLINE 0x0005
|
|
|
|
|
|
|
|
#define RSDHT_PEERCONN_DISCONNECTED 1
|
|
|
|
#define RSDHT_PEERCONN_UDP_STARTED 2
|
|
|
|
#define RSDHT_PEERCONN_CONNECTED 3
|
|
|
|
|
|
|
|
#define RSDHT_PEERREQ_STOPPED 1
|
|
|
|
#define RSDHT_PEERREQ_RUNNING 2
|
|
|
|
|
2013-08-22 07:26:13 +00:00
|
|
|
#define RSDHT_TOU_MODE_NONE 0
|
2011-07-09 18:39:34 +00:00
|
|
|
#define RSDHT_TOU_MODE_DIRECT 1
|
|
|
|
#define RSDHT_TOU_MODE_PROXY 2
|
|
|
|
#define RSDHT_TOU_MODE_RELAY 3
|
|
|
|
|
|
|
|
|
2011-12-19 18:56:11 +00:00
|
|
|
#define RSDHT_RELAY_NUM_CLASS 4
|
|
|
|
|
|
|
|
#define RSDHT_RELAY_CLASS_ALL 0
|
|
|
|
#define RSDHT_RELAY_CLASS_GENERAL 1
|
|
|
|
#define RSDHT_RELAY_CLASS_FOF 2
|
|
|
|
#define RSDHT_RELAY_CLASS_FRIENDS 3
|
|
|
|
|
2011-07-06 13:04:50 +00:00
|
|
|
|
2011-12-20 02:07:00 +00:00
|
|
|
#define RSDHT_RELAY_MODE_MASK 0x00f0
|
|
|
|
|
|
|
|
#define RSDHT_RELAY_ENABLED 0x0001
|
|
|
|
|
|
|
|
#define RSDHT_RELAY_MODE_OFF 0x0010
|
|
|
|
#define RSDHT_RELAY_MODE_ON 0x0020
|
|
|
|
#define RSDHT_RELAY_MODE_SERVER 0x0040
|
|
|
|
|
|
|
|
|
2011-07-06 13:04:50 +00:00
|
|
|
class RsDhtPeer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RsDhtPeer();
|
|
|
|
|
|
|
|
int mBucket;
|
|
|
|
std::string mDhtId;
|
|
|
|
std::string mAddr;
|
2018-10-07 01:34:05 +02:00
|
|
|
rstime_t mLastSendTime;
|
|
|
|
rstime_t mLastRecvTime;
|
|
|
|
rstime_t mFoundTime;
|
2011-07-06 13:04:50 +00:00
|
|
|
uint32_t mPeerFlags;
|
|
|
|
uint32_t mExtraFlags;
|
|
|
|
};
|
|
|
|
|
|
|
|
class RsDhtNetPeer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RsDhtNetPeer();
|
|
|
|
|
|
|
|
std::string mDhtId;
|
2014-03-17 20:56:06 +00:00
|
|
|
RsPeerId mRsId;
|
2011-07-06 13:04:50 +00:00
|
|
|
|
2011-07-19 00:06:09 +00:00
|
|
|
uint32_t mPeerType;
|
2011-07-09 18:39:34 +00:00
|
|
|
uint32_t mDhtState;
|
2011-07-10 18:19:46 +00:00
|
|
|
|
2011-12-19 18:56:11 +00:00
|
|
|
std::string mConnectState; // connectLogic.
|
2011-07-10 18:19:46 +00:00
|
|
|
|
2011-12-19 18:56:11 +00:00
|
|
|
uint32_t mPeerConnectState; // connect Status
|
|
|
|
uint32_t mPeerConnectMode; // connect mode
|
2011-07-17 13:48:37 +00:00
|
|
|
bool mExclusiveProxyLock;
|
|
|
|
|
2011-07-10 18:19:46 +00:00
|
|
|
std::string mPeerConnectProxyId;
|
|
|
|
|
2011-12-19 18:56:11 +00:00
|
|
|
uint32_t mPeerReqState; // Req Status.
|
|
|
|
std::string mCbPeerMsg; // Peer Cb Mgs.
|
2011-07-10 18:19:46 +00:00
|
|
|
|
2011-07-06 13:04:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class RsDhtRelayEnd
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
RsDhtRelayEnd();
|
|
|
|
std::string mLocalAddr;
|
|
|
|
std::string mProxyAddr;
|
|
|
|
std::string mRemoteAddr;
|
2018-10-07 01:34:05 +02:00
|
|
|
rstime_t mCreateTS;
|
2011-07-06 13:04:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class RsDhtRelayProxy
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RsDhtRelayProxy();
|
|
|
|
|
|
|
|
std::string mSrcAddr;
|
|
|
|
std::string mDestAddr;
|
|
|
|
|
|
|
|
double mBandwidth;
|
|
|
|
int mRelayClass;
|
2018-10-07 01:34:05 +02:00
|
|
|
rstime_t mLastTS;
|
|
|
|
rstime_t mCreateTS;
|
2011-07-06 13:04:50 +00:00
|
|
|
|
|
|
|
//uint32_t mDataSize;
|
2018-10-07 01:34:05 +02:00
|
|
|
//rstime_t mLastBandwidthTS;
|
2011-07-06 13:04:50 +00:00
|
|
|
|
|
|
|
};
|
2015-05-26 21:17:09 +00:00
|
|
|
class RsDhtFilteredPeer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct sockaddr_in mAddr;
|
|
|
|
uint32_t mFilterFlags; /* reasons why we are filtering */
|
2018-10-07 01:34:05 +02:00
|
|
|
rstime_t mFilterTS;
|
|
|
|
rstime_t mLastSeen;
|
2015-05-26 21:17:09 +00:00
|
|
|
};
|
2011-07-06 13:04:50 +00:00
|
|
|
|
|
|
|
class RsDht
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
RsDht() { return; }
|
|
|
|
virtual ~RsDht() { return; }
|
|
|
|
|
|
|
|
virtual uint32_t getNetState(uint32_t type) = 0;
|
|
|
|
virtual int getDhtPeers(int lvl, std::list<RsDhtPeer> &peers) = 0;
|
2014-03-17 20:56:06 +00:00
|
|
|
virtual int getNetPeerList(std::list<RsPeerId> &peerIds) = 0;
|
|
|
|
virtual int getNetPeerStatus(const RsPeerId& peerId, RsDhtNetPeer &status) = 0;
|
2011-07-06 13:04:50 +00:00
|
|
|
|
|
|
|
virtual int getRelayEnds(std::list<RsDhtRelayEnd> &relayEnds) = 0;
|
|
|
|
virtual int getRelayProxies(std::list<RsDhtRelayProxy> &relayProxies) = 0;
|
|
|
|
|
|
|
|
//virtual int getNetFailedPeer(std::string peerId, PeerStatus &status);
|
|
|
|
|
2011-07-19 00:06:09 +00:00
|
|
|
virtual std::string getUdpAddressString() = 0;
|
|
|
|
|
2012-01-19 16:23:57 +00:00
|
|
|
virtual void getDhtRates(float &read, float &write) = 0;
|
|
|
|
virtual void getRelayRates(float &read, float &write, float &relay) = 0;
|
2011-12-19 18:56:11 +00:00
|
|
|
|
|
|
|
// Interface for controlling Relays & DHT Relay Mode
|
2011-12-20 02:07:00 +00:00
|
|
|
virtual int getRelayServerList(std::list<std::string> &ids) = 0;
|
|
|
|
virtual int addRelayServer(std::string ids) = 0;
|
|
|
|
virtual int removeRelayServer(std::string ids) = 0;
|
|
|
|
|
2011-12-19 18:56:11 +00:00
|
|
|
virtual uint32_t getRelayMode() = 0;
|
|
|
|
virtual int setRelayMode(uint32_t mode) = 0;
|
|
|
|
|
|
|
|
virtual int getRelayAllowance(int classIdx, uint32_t &count, uint32_t &bandwidth) = 0;
|
|
|
|
virtual int setRelayAllowance(int classIdx, uint32_t count, uint32_t bandwidth) = 0;
|
|
|
|
|
2012-12-17 19:15:04 +00:00
|
|
|
// So we can provide to clients.
|
|
|
|
virtual bool getOwnDhtId(std::string &ownDhtId) = 0;
|
|
|
|
|
2015-05-25 14:02:45 +00:00
|
|
|
virtual bool isAddressBanned(const struct sockaddr_storage& raddr) =0;
|
2015-05-26 21:17:09 +00:00
|
|
|
virtual void getListOfBannedIps(std::list<RsDhtFilteredPeer>& lst) =0;
|
2011-12-19 18:56:11 +00:00
|
|
|
|
2011-07-06 13:04:50 +00:00
|
|
|
#if 0
|
|
|
|
virtual std::string getPeerStatusString();
|
|
|
|
virtual std::string getDhtStatusString();
|
|
|
|
|
|
|
|
virtual int get_dht_queries(std::map<bdNodeId, bdQueryStatus> &queries);
|
|
|
|
virtual int get_query_status(std::string id, bdQuerySummary &query);
|
|
|
|
|
|
|
|
virtual int get_peer_status(std::string peerId, PeerStatus &status);
|
|
|
|
|
|
|
|
virtual int get_net_failedpeers(std::list<std::string> &peerIds);
|
|
|
|
virtual int get_failedpeer_status(std::string peerId, PeerStatus &status);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|