2011-07-09 05:36:37 -04:00
|
|
|
/*
|
|
|
|
* libretroshare/src/pqi: p3peermgr.h
|
|
|
|
*
|
|
|
|
* 3P/PQI network interface for RetroShare.
|
|
|
|
*
|
|
|
|
* Copyright 2007-2011 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_PQI_PEER_MANAGER_HEADER
|
|
|
|
#define MRK_PQI_PEER_MANAGER_HEADER
|
|
|
|
|
2012-12-01 14:22:22 -05:00
|
|
|
#include <retroshare/rspeers.h>
|
2011-07-09 05:36:37 -04:00
|
|
|
#include "pqi/pqimonitor.h"
|
|
|
|
#include "pqi/pqiipset.h"
|
|
|
|
#include "pqi/pqiassist.h"
|
|
|
|
|
|
|
|
#include "pqi/p3cfgmgr.h"
|
|
|
|
|
|
|
|
#include "util/rsthreads.h"
|
|
|
|
|
2013-09-28 04:09:59 -04:00
|
|
|
/* RS_VIS_STATE -> specified in rspeers.h
|
|
|
|
*/
|
2011-07-09 05:36:37 -04:00
|
|
|
|
|
|
|
/* Startup Modes (confirmed later) */
|
2013-09-03 09:35:39 -04:00
|
|
|
const uint32_t RS_NET_MODE_TRYMODE = 0xff00;
|
2011-07-09 05:36:37 -04:00
|
|
|
|
2013-09-03 09:35:39 -04:00
|
|
|
const uint32_t RS_NET_MODE_TRY_EXT = 0x0100;
|
|
|
|
const uint32_t RS_NET_MODE_TRY_UPNP = 0x0200;
|
|
|
|
const uint32_t RS_NET_MODE_TRY_UDP = 0x0400;
|
2013-09-08 22:10:49 -04:00
|
|
|
const uint32_t RS_NET_MODE_TRY_LOOPBACK = 0x0800;
|
2011-07-09 05:36:37 -04:00
|
|
|
|
|
|
|
/* Actual State */
|
2013-09-03 09:35:39 -04:00
|
|
|
const uint32_t RS_NET_MODE_ACTUAL = 0x00ff;
|
2011-07-09 05:36:37 -04:00
|
|
|
|
|
|
|
const uint32_t RS_NET_MODE_UNKNOWN = 0x0000;
|
|
|
|
const uint32_t RS_NET_MODE_EXT = 0x0001;
|
|
|
|
const uint32_t RS_NET_MODE_UPNP = 0x0002;
|
|
|
|
const uint32_t RS_NET_MODE_UDP = 0x0004;
|
2013-09-03 09:35:39 -04:00
|
|
|
const uint32_t RS_NET_MODE_HIDDEN = 0x0008;
|
|
|
|
const uint32_t RS_NET_MODE_UNREACHABLE = 0x0010;
|
2011-07-09 05:36:37 -04:00
|
|
|
|
|
|
|
|
|
|
|
/* flags of peerStatus */
|
|
|
|
const uint32_t RS_NET_FLAGS_USE_DISC = 0x0001;
|
|
|
|
const uint32_t RS_NET_FLAGS_USE_DHT = 0x0002;
|
|
|
|
const uint32_t RS_NET_FLAGS_ONLINE = 0x0004;
|
|
|
|
const uint32_t RS_NET_FLAGS_EXTERNAL_ADDR = 0x0008;
|
|
|
|
const uint32_t RS_NET_FLAGS_STABLE_UDP = 0x0010;
|
|
|
|
const uint32_t RS_NET_FLAGS_TRUSTS_ME = 0x0020;
|
|
|
|
|
|
|
|
class peerState
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
peerState(); /* init */
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
RsPeerId id;
|
|
|
|
RsPgpId gpg_id;
|
2011-07-09 05:36:37 -04:00
|
|
|
|
2013-09-03 09:35:39 -04:00
|
|
|
uint32_t netMode; /* EXT / UPNP / UDP / HIDDEN / INVALID */
|
2013-09-28 04:09:59 -04:00
|
|
|
/* visState */
|
|
|
|
uint16_t vs_disc;
|
|
|
|
uint16_t vs_dht;
|
2013-09-03 09:35:39 -04:00
|
|
|
|
2013-09-13 10:35:19 -04:00
|
|
|
struct sockaddr_storage localaddr;
|
|
|
|
struct sockaddr_storage serveraddr;
|
2011-07-09 14:39:34 -04:00
|
|
|
std::string dyndns;
|
2011-07-09 05:36:37 -04:00
|
|
|
|
2011-07-09 14:39:34 -04:00
|
|
|
time_t lastcontact;
|
2011-07-09 05:36:37 -04:00
|
|
|
|
|
|
|
/* list of addresses from various sources */
|
|
|
|
pqiIpAddrSet ipAddrs;
|
|
|
|
|
2013-09-03 09:35:39 -04:00
|
|
|
bool hiddenNode; /* all IP addresses / dyndns must be blank */
|
|
|
|
std::string hiddenDomain;
|
|
|
|
uint16_t hiddenPort;
|
2015-09-07 05:22:15 -04:00
|
|
|
uint32_t hiddenType;
|
2013-09-03 09:35:39 -04:00
|
|
|
|
2011-07-09 05:36:37 -04:00
|
|
|
std::string location;
|
2011-07-09 14:39:34 -04:00
|
|
|
std::string name;
|
2011-07-09 05:36:37 -04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class RsPeerGroupItem;
|
|
|
|
class RsGroupInfo;
|
|
|
|
|
|
|
|
std::string textPeerState(peerState &state);
|
|
|
|
|
2011-07-09 14:39:34 -04:00
|
|
|
class p3LinkMgr;
|
|
|
|
class p3NetMgr;
|
2011-07-09 05:36:37 -04:00
|
|
|
|
2011-07-13 10:22:25 -04:00
|
|
|
class p3LinkMgrIMPL;
|
|
|
|
class p3NetMgrIMPL;
|
2011-07-09 14:39:34 -04:00
|
|
|
|
2011-07-13 10:22:25 -04:00
|
|
|
class p3PeerMgr
|
2011-07-09 05:36:37 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2011-07-13 10:22:25 -04:00
|
|
|
p3PeerMgr() { return; }
|
|
|
|
virtual ~p3PeerMgr() { return; }
|
2011-07-09 05:36:37 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id, uint32_t netMode = RS_NET_MODE_UDP,
|
2013-09-28 04:09:59 -04:00
|
|
|
uint16_t vsDisc = RS_VS_DISC_FULL, uint16_t vsDht = RS_VS_DHT_FULL,
|
2015-02-18 14:07:58 -05:00
|
|
|
time_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_NODE_PERM_DEFAULT)) = 0;
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId) = 0;
|
2011-07-09 14:39:34 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool isFriend(const RsPeerId& ssl_id) = 0;
|
2011-07-09 14:39:34 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool getAssociatedPeers(const RsPgpId &gpg_id, std::list<RsPeerId> &ids) = 0;
|
|
|
|
virtual bool removeAllFriendLocations(const RsPgpId &gpgid) = 0;
|
2011-07-09 05:36:37 -04:00
|
|
|
|
|
|
|
|
2011-07-13 10:22:25 -04:00
|
|
|
/******************** Groups **********************/
|
|
|
|
/* This is solely used by p3peers - makes sense */
|
|
|
|
|
|
|
|
virtual bool addGroup(RsGroupInfo &groupInfo) = 0;
|
|
|
|
virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
|
|
|
|
virtual bool removeGroup(const std::string &groupId) = 0;
|
|
|
|
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
|
|
|
|
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0;
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId> &peerIds, bool assign) = 0;
|
2011-07-13 10:22:25 -04:00
|
|
|
|
2015-05-17 06:00:00 -04:00
|
|
|
virtual bool resetOwnExternalAddressList() = 0 ;
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id) =0;
|
|
|
|
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) =0;
|
|
|
|
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags) =0;
|
2011-07-13 10:22:25 -04:00
|
|
|
|
|
|
|
/**************** Set Net Info ****************/
|
|
|
|
/*
|
|
|
|
* These functions are used by:
|
|
|
|
* 1) p3linkmgr
|
|
|
|
* 2) p3peers - reasonable
|
|
|
|
* 3) p3disc - reasonable
|
|
|
|
*/
|
2011-07-09 14:39:34 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool setLocalAddress(const RsPeerId &id, const struct sockaddr_storage &addr) = 0;
|
|
|
|
virtual bool setExtAddress(const RsPeerId &id, const struct sockaddr_storage &addr) = 0;
|
|
|
|
virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns) = 0;
|
2015-06-01 18:03:07 -04:00
|
|
|
virtual bool addCandidateForOwnExternalAddress(const RsPeerId& from, const struct sockaddr_storage &addr) = 0;
|
2011-07-10 20:52:12 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool setNetworkMode(const RsPeerId &id, uint32_t netMode) = 0;
|
|
|
|
virtual bool setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht) = 0;
|
2011-07-09 05:36:37 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool setLocation(const RsPeerId &pid, const std::string &location) = 0;
|
|
|
|
virtual bool setHiddenDomainPort(const RsPeerId &id, const std::string &domain_addr, const uint16_t domain_port) = 0;
|
2011-07-09 05:36:37 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool updateCurrentAddress(const RsPeerId& id, const pqiIpAddress &addr) = 0;
|
|
|
|
virtual bool updateLastContact(const RsPeerId& id) = 0;
|
|
|
|
virtual bool updateAddressList(const RsPeerId& id, const pqiIpAddrSet &addrs) = 0;
|
2011-07-09 05:36:37 -04:00
|
|
|
|
2011-08-02 15:05:27 -04:00
|
|
|
|
|
|
|
// THIS MUST ONLY BE CALLED BY NETMGR!!!!
|
2013-09-13 10:35:19 -04:00
|
|
|
virtual bool UpdateOwnAddress(const struct sockaddr_storage &local_addr, const struct sockaddr_storage &ext_addr) = 0;
|
2011-08-02 15:05:27 -04:00
|
|
|
|
2011-07-13 10:22:25 -04:00
|
|
|
/**************** Net Status Info ****************/
|
|
|
|
/*
|
|
|
|
* MUST RATIONALISE THE DATA FROM THESE FUNCTIONS
|
|
|
|
* These functions are used by:
|
|
|
|
* 1) p3face-config ... to remove!
|
|
|
|
* 2) p3peers - reasonable
|
|
|
|
* 3) p3disc - reasonable
|
|
|
|
*/
|
2011-07-09 05:36:37 -04:00
|
|
|
|
2011-07-13 10:22:25 -04:00
|
|
|
virtual bool getOwnNetStatus(peerState &state) = 0;
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool getFriendNetStatus(const RsPeerId &id, peerState &state) = 0;
|
|
|
|
virtual bool getOthersNetStatus(const RsPeerId &id, peerState &state) = 0;
|
2011-07-09 05:36:37 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool getPeerName(const RsPeerId &ssl_id, std::string &name) = 0;
|
|
|
|
virtual bool getGpgId(const RsPeerId &sslId, RsPgpId &gpgId) = 0;
|
|
|
|
virtual uint32_t getConnectionType(const RsPeerId &sslId) = 0;
|
2011-08-07 17:11:00 -04:00
|
|
|
|
2015-09-07 05:22:15 -04:00
|
|
|
virtual bool setProxyServerAddress(const uint32_t type, const struct sockaddr_storage &proxy_addr) = 0;
|
|
|
|
virtual bool getProxyServerAddress(const uint32_t type, struct sockaddr_storage &proxy_addr) = 0;
|
|
|
|
virtual bool getProxyServerStatus(const uint32_t type, uint32_t& status) = 0;
|
2013-09-11 03:00:33 -04:00
|
|
|
virtual bool isHidden() = 0;
|
2015-09-07 05:51:24 -04:00
|
|
|
virtual bool isHidden(const uint32_t type) = 0;
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool isHiddenPeer(const RsPeerId &ssl_id) = 0;
|
2015-09-07 05:51:24 -04:00
|
|
|
virtual bool isHiddenPeer(const RsPeerId &ssl_id, const uint32_t type) = 0;
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool getProxyAddress(const RsPeerId &ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port) = 0;
|
2013-09-03 09:35:39 -04:00
|
|
|
|
|
|
|
|
2012-02-24 20:48:56 -05:00
|
|
|
virtual int getFriendCount(bool ssl, bool online) = 0;
|
2011-07-09 05:36:37 -04:00
|
|
|
|
2011-07-13 10:22:25 -04:00
|
|
|
/************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/
|
2011-07-09 05:36:37 -04:00
|
|
|
|
2011-07-13 10:22:25 -04:00
|
|
|
// Single Use Function... shouldn't be here. used by p3serverconfig.cc
|
|
|
|
virtual bool haveOnceConnected() = 0;
|
2011-07-09 05:36:37 -04:00
|
|
|
|
|
|
|
|
2011-07-13 10:22:25 -04:00
|
|
|
/*************************************************************************************************/
|
|
|
|
/*************************************************************************************************/
|
|
|
|
/*************************************************************************************************/
|
|
|
|
/*************************************************************************************************/
|
2011-07-09 05:36:37 -04:00
|
|
|
|
2011-07-11 14:48:56 -04:00
|
|
|
|
2011-07-13 10:22:25 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class p3PeerMgrIMPL: public p3PeerMgr, public p3Config
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
/************************************************************************************************/
|
|
|
|
/* EXTERNAL INTERFACE */
|
|
|
|
/************************************************************************************************/
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool addFriend(const RsPeerId&ssl_id, const RsPgpId&gpg_id, uint32_t netMode = RS_NET_MODE_UDP,
|
2013-09-28 04:09:59 -04:00
|
|
|
uint16_t vsDisc = RS_VS_DISC_FULL, uint16_t vsDht = RS_VS_DHT_FULL,
|
2015-02-18 14:07:58 -05:00
|
|
|
time_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_NODE_PERM_DEFAULT));
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId);
|
|
|
|
virtual bool removeFriend(const RsPgpId &pgp_id);
|
2011-07-13 10:22:25 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool isFriend(const RsPeerId &ssl_id);
|
2011-07-13 10:22:25 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool getAssociatedPeers(const RsPgpId &gpg_id, std::list<RsPeerId> &ids);
|
|
|
|
virtual bool removeAllFriendLocations(const RsPgpId &gpgid);
|
2011-08-07 17:11:00 -04:00
|
|
|
|
2011-07-09 05:36:37 -04:00
|
|
|
|
|
|
|
/******************** Groups **********************/
|
2011-07-13 10:22:25 -04:00
|
|
|
/* This is solely used by p3peers - makes sense */
|
|
|
|
|
|
|
|
virtual bool addGroup(RsGroupInfo &groupInfo);
|
|
|
|
virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo);
|
|
|
|
virtual bool removeGroup(const std::string &groupId);
|
|
|
|
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo);
|
|
|
|
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList);
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId> &peerIds, bool assign);
|
2011-07-13 10:22:25 -04:00
|
|
|
|
2015-05-17 06:00:00 -04:00
|
|
|
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id) ;
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) ;
|
|
|
|
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags) ;
|
2011-07-13 10:22:25 -04:00
|
|
|
|
|
|
|
/**************** Set Net Info ****************/
|
|
|
|
/*
|
|
|
|
* These functions are used by:
|
|
|
|
* 1) p3linkmgr
|
|
|
|
* 2) p3peers - reasonable
|
|
|
|
* 3) p3disc - reasonable
|
|
|
|
*/
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool setLocalAddress(const RsPeerId &id, const struct sockaddr_storage &addr);
|
|
|
|
virtual bool setExtAddress(const RsPeerId &id, const struct sockaddr_storage &addr);
|
|
|
|
virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns);
|
2015-06-01 18:03:07 -04:00
|
|
|
virtual bool addCandidateForOwnExternalAddress(const RsPeerId& from, const struct sockaddr_storage &addr) ;
|
2011-07-09 05:36:37 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool setNetworkMode(const RsPeerId &id, uint32_t netMode);
|
|
|
|
virtual bool setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht);
|
2011-07-13 10:22:25 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool setLocation(const RsPeerId &pid, const std::string &location);
|
|
|
|
virtual bool setHiddenDomainPort(const RsPeerId &id, const std::string &domain_addr, const uint16_t domain_port);
|
2013-09-03 09:35:39 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool updateCurrentAddress(const RsPeerId& id, const pqiIpAddress &addr);
|
|
|
|
virtual bool updateLastContact(const RsPeerId& id);
|
|
|
|
virtual bool updateAddressList(const RsPeerId& id, const pqiIpAddrSet &addrs);
|
2011-07-13 10:22:25 -04:00
|
|
|
|
2015-05-17 06:00:00 -04:00
|
|
|
virtual bool resetOwnExternalAddressList() ;
|
2011-08-02 15:05:27 -04:00
|
|
|
|
|
|
|
// THIS MUST ONLY BE CALLED BY NETMGR!!!!
|
2013-09-13 10:35:19 -04:00
|
|
|
virtual bool UpdateOwnAddress(const struct sockaddr_storage &local_addr, const struct sockaddr_storage &ext_addr);
|
2011-07-13 10:22:25 -04:00
|
|
|
/**************** Net Status Info ****************/
|
|
|
|
/*
|
|
|
|
* MUST RATIONALISE THE DATA FROM THESE FUNCTIONS
|
|
|
|
* These functions are used by:
|
|
|
|
* 1) p3face-config ... to remove!
|
|
|
|
* 2) p3peers - reasonable
|
|
|
|
* 3) p3disc - reasonable
|
|
|
|
*/
|
|
|
|
|
|
|
|
virtual bool getOwnNetStatus(peerState &state);
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool getFriendNetStatus(const RsPeerId &id, peerState &state);
|
|
|
|
virtual bool getOthersNetStatus(const RsPeerId &id, peerState &state);
|
2011-07-13 10:22:25 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool getPeerName(const RsPeerId& ssl_id, std::string& name);
|
|
|
|
virtual bool getGpgId(const RsPeerId& sslId, RsPgpId& gpgId);
|
|
|
|
virtual uint32_t getConnectionType(const RsPeerId& sslId);
|
2011-08-07 17:11:00 -04:00
|
|
|
|
2015-09-07 05:22:15 -04:00
|
|
|
virtual bool setProxyServerAddress(const uint32_t type, const struct sockaddr_storage &proxy_addr);
|
|
|
|
virtual bool getProxyServerAddress(const uint32_t type, struct sockaddr_storage &proxy_addr);
|
|
|
|
virtual bool getProxyServerStatus(const uint32_t type, uint32_t &proxy_status);
|
2013-09-11 03:00:33 -04:00
|
|
|
virtual bool isHidden();
|
2015-09-07 05:51:24 -04:00
|
|
|
virtual bool isHidden(const uint32_t type);
|
|
|
|
virtual bool isHiddenPeer(const RsPeerId &ssl_id);
|
|
|
|
virtual bool isHiddenPeer(const RsPeerId &ssl_id, const uint32_t type);
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool getProxyAddress(const RsPeerId& ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port);
|
2015-09-07 05:22:15 -04:00
|
|
|
virtual uint32_t hiddenDomainToHiddenType(const std::string &domain);
|
2013-09-03 09:35:39 -04:00
|
|
|
|
2012-02-24 20:48:56 -05:00
|
|
|
virtual int getFriendCount(bool ssl, bool online);
|
2011-07-13 10:22:25 -04:00
|
|
|
|
|
|
|
/************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/
|
|
|
|
|
|
|
|
// Single Use Function... shouldn't be here. used by p3serverconfig.cc
|
|
|
|
virtual bool haveOnceConnected();
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************************************/
|
|
|
|
/* Extra IMPL Functions (used by p3LinkMgr, p3NetMgr + Setup) */
|
|
|
|
/************************************************************************************************/
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
p3PeerMgrIMPL( const RsPeerId& ssl_own_id,
|
|
|
|
const RsPgpId& gpg_own_id,
|
2012-12-26 13:12:19 -05:00
|
|
|
const std::string& gpg_own_name,
|
|
|
|
const std::string& ssl_own_location) ;
|
2011-07-13 10:22:25 -04:00
|
|
|
|
2012-02-14 17:55:14 -05:00
|
|
|
void setManagers(p3LinkMgrIMPL *linkMgr, p3NetMgrIMPL *netMgr);
|
2011-07-13 10:22:25 -04:00
|
|
|
|
2014-01-17 21:32:55 -05:00
|
|
|
bool forceHiddenNode();
|
2013-09-08 22:10:49 -04:00
|
|
|
bool setupHiddenNode(const std::string &hiddenAddress, const uint16_t hiddenPort);
|
|
|
|
|
2011-07-13 10:22:25 -04:00
|
|
|
void tick();
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
const RsPeerId& getOwnId();
|
2013-08-08 19:00:27 -04:00
|
|
|
bool setOwnNetworkMode(uint32_t netMode);
|
2013-09-28 04:09:59 -04:00
|
|
|
bool setOwnVisState(uint16_t vs_disc, uint16_t vs_dht);
|
2011-07-13 10:22:25 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
int getConnectAddresses(const RsPeerId &id,
|
2013-09-13 10:35:19 -04:00
|
|
|
struct sockaddr_storage &lAddr, struct sockaddr_storage &eAddr,
|
2011-07-13 10:22:25 -04:00
|
|
|
pqiIpAddrSet &histAddrs, std::string &dyndns);
|
2011-07-09 05:36:37 -04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/* Internal Functions */
|
2011-08-07 17:11:00 -04:00
|
|
|
|
|
|
|
bool removeUnusedLocations();
|
2015-05-25 10:02:45 -04:00
|
|
|
bool removeBannedIps();
|
2011-08-07 17:11:00 -04:00
|
|
|
|
2011-07-13 10:22:25 -04:00
|
|
|
void printPeerLists(std::ostream &out);
|
2011-07-09 05:36:37 -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-07-09 14:39:34 -04:00
|
|
|
/* other important managers */
|
|
|
|
|
2011-07-13 10:22:25 -04:00
|
|
|
p3LinkMgrIMPL *mLinkMgr;
|
|
|
|
p3NetMgrIMPL *mNetMgr;
|
2011-07-09 14:39:34 -04:00
|
|
|
|
2011-07-09 05:36:37 -04:00
|
|
|
private:
|
|
|
|
RsMutex mPeerMtx; /* protects below */
|
|
|
|
|
|
|
|
bool mStatusChanged;
|
|
|
|
|
|
|
|
std::list<pqiMonitor *> clients;
|
|
|
|
|
|
|
|
peerState mOwnState;
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
std::map<RsPeerId, peerState> mFriendList; // <SSLid , peerState>
|
|
|
|
std::map<RsPeerId, peerState> mOthersList;
|
2011-07-09 05:36:37 -04:00
|
|
|
|
|
|
|
std::list<RsPeerGroupItem *> groupList;
|
|
|
|
uint32_t lastGroupId;
|
|
|
|
|
|
|
|
std::list<RsItem *> saveCleanupList; /* TEMPORARY LIST WHEN SAVING */
|
2012-12-01 14:22:22 -05:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
std::map<RsPgpId, ServicePermissionFlags> mFriendsPermissionFlags ; // permission flags for each gpg key
|
2013-09-03 09:35:39 -04:00
|
|
|
|
2015-09-07 05:22:15 -04:00
|
|
|
struct sockaddr_storage mProxyServerAddressTor;
|
|
|
|
struct sockaddr_storage mProxyServerAddressI2P;
|
|
|
|
uint32_t mProxyServerStatusTor ;
|
|
|
|
uint32_t mProxyServerStatusI2P ;
|
2015-06-06 09:50:11 -04:00
|
|
|
|
2011-07-09 05:36:37 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MRK_PQI_PEER_MANAGER_HEADER
|