2007-12-11 20:43:17 -05:00
|
|
|
/*
|
|
|
|
* libretroshare/src/services: p3disc.h
|
|
|
|
*
|
|
|
|
* Services for RetroShare.
|
|
|
|
*
|
|
|
|
* Copyright 2004-2008 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_AUTODISC_H
|
|
|
|
#define MRK_PQI_AUTODISC_H
|
|
|
|
|
|
|
|
// The AutoDiscovery Class
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <list>
|
|
|
|
|
|
|
|
// system specific network headers
|
|
|
|
#include "pqi/pqinetwork.h"
|
|
|
|
|
|
|
|
#include "pqi/pqi.h"
|
|
|
|
|
2008-01-25 02:49:28 -05:00
|
|
|
class p3ConnectMgr;
|
|
|
|
class p3AuthMgr;
|
2007-12-11 20:43:17 -05:00
|
|
|
|
2008-02-03 01:29:02 -05:00
|
|
|
#include "pqi/pqimonitor.h"
|
2007-12-11 20:43:17 -05:00
|
|
|
#include "serialiser/rsdiscitems.h"
|
|
|
|
#include "services/p3service.h"
|
|
|
|
|
|
|
|
class autoserver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
autoserver()
|
2008-02-03 01:29:02 -05:00
|
|
|
:ts(0), discFlags(0) { return;}
|
2007-12-11 20:43:17 -05:00
|
|
|
|
2008-01-25 02:49:28 -05:00
|
|
|
std::string id;
|
2008-02-03 01:29:02 -05:00
|
|
|
struct sockaddr_in localAddr;
|
|
|
|
struct sockaddr_in remoteAddr;
|
2007-12-11 20:43:17 -05:00
|
|
|
|
2008-02-03 01:29:02 -05:00
|
|
|
time_t ts;
|
|
|
|
uint32_t discFlags;
|
2007-12-11 20:43:17 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class autoneighbour: public autoserver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
autoneighbour()
|
2008-02-03 01:29:02 -05:00
|
|
|
:autoserver(), authoritative(false) {}
|
|
|
|
|
|
|
|
bool authoritative;
|
|
|
|
bool validAddrs;
|
2007-12-11 20:43:17 -05:00
|
|
|
|
2008-02-03 01:29:02 -05:00
|
|
|
std::map<std::string, autoserver> neighbour_of;
|
2007-12-11 20:43:17 -05:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2008-02-03 01:29:02 -05:00
|
|
|
class p3AuthMgr;
|
|
|
|
class p3ConnectMgr;
|
|
|
|
|
2007-12-11 20:43:17 -05:00
|
|
|
|
2008-02-03 01:29:02 -05:00
|
|
|
class p3disc: public p3Service, public pqiMonitor
|
2007-12-11 20:43:17 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
2008-02-03 01:29:02 -05:00
|
|
|
p3disc(p3AuthMgr *am, p3ConnectMgr *cm);
|
|
|
|
|
|
|
|
/************* from pqiMonitor *******************/
|
|
|
|
virtual void statusChange(const std::list<pqipeer> &plist);
|
|
|
|
/************* from pqiMonitor *******************/
|
2007-12-11 20:43:17 -05:00
|
|
|
|
2008-02-03 01:29:02 -05:00
|
|
|
int tick();
|
2007-12-11 20:43:17 -05:00
|
|
|
|
2008-03-04 16:31:11 -05:00
|
|
|
/* GUI requires access */
|
|
|
|
bool potentialproxies(std::string id, std::list<std::string> &proxyIds);
|
2009-06-28 16:57:02 -04:00
|
|
|
void getversions(std::map<std::string, std::string> &versions);
|
2008-03-04 16:31:11 -05:00
|
|
|
|
2008-02-03 01:29:02 -05:00
|
|
|
private:
|
2007-12-11 20:43:17 -05:00
|
|
|
|
|
|
|
|
2008-02-03 01:29:02 -05:00
|
|
|
void respondToPeer(std::string id);
|
2007-12-11 20:43:17 -05:00
|
|
|
|
2008-02-03 01:29:02 -05:00
|
|
|
/* Network Output */
|
|
|
|
void sendOwnDetails(std::string to);
|
2009-06-28 16:57:02 -04:00
|
|
|
void sendOwnVersion(std::string to);
|
2008-02-03 01:29:02 -05:00
|
|
|
void sendPeerDetails(std::string to, std::string about);
|
2009-05-25 07:38:47 -04:00
|
|
|
void sendPeerIssuer(std::string to, std::string about);
|
2007-12-11 20:43:17 -05:00
|
|
|
|
2008-02-03 01:29:02 -05:00
|
|
|
/* Network Input */
|
|
|
|
int handleIncoming();
|
2009-06-23 17:36:02 -04:00
|
|
|
void recvPeerOwnMsg(RsDiscOwnItem *item);
|
2008-02-03 01:29:02 -05:00
|
|
|
void recvPeerFriendMsg(RsDiscReply *item);
|
2009-05-25 07:38:47 -04:00
|
|
|
void recvPeerIssuerMsg(RsDiscIssuer *item);
|
2009-06-28 16:57:02 -04:00
|
|
|
void recvPeerVersionMsg(RsDiscVersion *item);
|
2007-12-11 20:43:17 -05:00
|
|
|
|
2008-02-03 01:29:02 -05:00
|
|
|
/* handle network shape */
|
|
|
|
int addDiscoveryData(std::string fromId, std::string aboutId,
|
2009-06-28 16:57:02 -04:00
|
|
|
struct sockaddr_in laddr, struct sockaddr_in raddr,
|
2008-02-03 01:29:02 -05:00
|
|
|
uint32_t flags, time_t ts);
|
2007-12-11 20:43:17 -05:00
|
|
|
|
2008-02-03 01:29:02 -05:00
|
|
|
int idServers();
|
2007-12-11 20:43:17 -05:00
|
|
|
|
|
|
|
|
2008-02-03 01:29:02 -05:00
|
|
|
private:
|
2007-12-11 20:43:17 -05:00
|
|
|
|
2008-02-03 01:29:02 -05:00
|
|
|
p3AuthMgr *mAuthMgr;
|
|
|
|
p3ConnectMgr *mConnMgr;
|
2007-12-11 20:43:17 -05:00
|
|
|
|
2008-02-04 16:40:34 -05:00
|
|
|
|
|
|
|
/* data */
|
|
|
|
RsMutex mDiscMtx;
|
|
|
|
|
2008-02-03 01:29:02 -05:00
|
|
|
bool mRemoteDisc;
|
|
|
|
bool mLocalDisc;
|
2007-12-11 20:43:17 -05:00
|
|
|
|
2008-02-03 01:29:02 -05:00
|
|
|
std::map<std::string, autoneighbour> neighbours;
|
2009-06-28 16:57:02 -04:00
|
|
|
std::map<std::string, std::string> versions;
|
2008-02-03 01:29:02 -05:00
|
|
|
};
|
2007-12-11 20:43:17 -05:00
|
|
|
|
|
|
|
|
2008-01-25 02:49:28 -05:00
|
|
|
|
2007-12-11 20:43:17 -05:00
|
|
|
|
|
|
|
#endif // MRK_PQI_AUTODISC_H
|