mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 07:29:33 -05:00
Commit of the new UDP Connection methods and
the rewrite of the retroshare core networking stack. This check-in commits the changes to the services code. Modifications to match the switch to p3connmgr.h and p3authmgr.h git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@311 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
059d43244a
commit
37d6a4b968
@ -7,7 +7,8 @@ RS_TOP_DIR = ..
|
|||||||
include $(RS_TOP_DIR)/scripts/config.mk
|
include $(RS_TOP_DIR)/scripts/config.mk
|
||||||
###############################################################
|
###############################################################
|
||||||
|
|
||||||
RSOBJ = p3service.o p3disc.o p3chatservice.o p3msgservice.o p3gamelauncher.o
|
RSOBJ = p3service.o p3chatservice.o p3msgservice.o p3gamelauncher.o
|
||||||
|
#p3disc.o
|
||||||
|
|
||||||
#TESTOBJ =
|
#TESTOBJ =
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@
|
|||||||
|
|
||||||
const int p3chatzone = 1745;
|
const int p3chatzone = 1745;
|
||||||
|
|
||||||
p3ChatService::p3ChatService()
|
p3ChatService::p3ChatService(p3ConnectMgr *cm)
|
||||||
:p3Service(RS_SERVICE_TYPE_CHAT)
|
:p3Service(RS_SERVICE_TYPE_CHAT), mConnMgr(cm)
|
||||||
{
|
{
|
||||||
addSerialType(new RsChatSerialiser());
|
addSerialType(new RsChatSerialiser());
|
||||||
}
|
}
|
||||||
@ -70,19 +70,22 @@ int p3ChatService::status()
|
|||||||
int p3ChatService::sendChat(std::string msg)
|
int p3ChatService::sendChat(std::string msg)
|
||||||
{
|
{
|
||||||
/* go through all the peers */
|
/* go through all the peers */
|
||||||
sslroot *sslr = getSSLRoot();
|
|
||||||
|
|
||||||
std::list<cert *>::iterator it;
|
std::list<std::string> ids;
|
||||||
std::list<cert *> &certs = sslr -> getCertList();
|
std::list<std::string>::iterator it;
|
||||||
|
mConnMgr->getOnlineList(ids);
|
||||||
|
|
||||||
for(it = certs.begin(); it != certs.end(); it++)
|
/* add in own id -> so get reflection */
|
||||||
|
ids.push_back(mConnMgr->getOwnId());
|
||||||
|
|
||||||
|
for(it = ids.begin(); it != ids.end(); it++)
|
||||||
{
|
{
|
||||||
pqioutput(PQL_DEBUG_BASIC, p3chatzone,
|
pqioutput(PQL_DEBUG_BASIC, p3chatzone,
|
||||||
"p3ChatService::sendChat()");
|
"p3ChatService::sendChat()");
|
||||||
|
|
||||||
RsChatItem *ci = new RsChatItem();
|
RsChatItem *ci = new RsChatItem();
|
||||||
|
|
||||||
ci->PeerId((*it)->PeerId());
|
ci->PeerId(*it);
|
||||||
ci->chatFlags = 0;
|
ci->chatFlags = 0;
|
||||||
ci->sendTime = time(NULL);
|
ci->sendTime = time(NULL);
|
||||||
ci->message = msg;
|
ci->message = msg;
|
||||||
|
@ -37,12 +37,13 @@
|
|||||||
|
|
||||||
#include "serialiser/rsmsgitems.h"
|
#include "serialiser/rsmsgitems.h"
|
||||||
#include "services/p3service.h"
|
#include "services/p3service.h"
|
||||||
|
#include "pqi/p3connmgr.h"
|
||||||
|
|
||||||
|
|
||||||
class p3ChatService: public p3Service
|
class p3ChatService: public p3Service
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
p3ChatService();
|
p3ChatService(p3ConnectMgr *cm);
|
||||||
|
|
||||||
/* overloaded */
|
/* overloaded */
|
||||||
virtual int tick();
|
virtual int tick();
|
||||||
@ -52,6 +53,9 @@ int sendChat(std::string msg);
|
|||||||
int sendPrivateChat(std::string msg, std::string id);
|
int sendPrivateChat(std::string msg, std::string id);
|
||||||
|
|
||||||
std::list<RsChatItem *> getChatQueue();
|
std::list<RsChatItem *> getChatQueue();
|
||||||
|
|
||||||
|
private:
|
||||||
|
p3ConnectMgr *mConnMgr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SERVICE_CHAT_HEADER
|
#endif // SERVICE_CHAT_HEADER
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
|
|
||||||
#include "services/p3disc.h"
|
#include "services/p3disc.h"
|
||||||
|
|
||||||
// for active local cert stuff.
|
#include "pqi/p3authmgr.h"
|
||||||
#include "pqi/pqissl.h"
|
#include "pqi/p3connmgr.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -51,8 +51,8 @@ static unsigned long determineCertAvailabilityFlags(cert *c);
|
|||||||
// Operating System specific includes.
|
// Operating System specific includes.
|
||||||
#include "pqi/pqinetwork.h"
|
#include "pqi/pqinetwork.h"
|
||||||
|
|
||||||
p3disc::p3disc(sslroot *r)
|
p3disc::p3disc(p3AuthMgr *am, p3ConnectMgr *cm)
|
||||||
:p3Service(RS_SERVICE_TYPE_DISC), sroot(r)
|
:p3Service(RS_SERVICE_TYPE_DISC), mAuthMgr(am), mConnMgr(cm)
|
||||||
{
|
{
|
||||||
addSerialType(new RsDiscSerialiser());
|
addSerialType(new RsDiscSerialiser());
|
||||||
|
|
||||||
|
@ -36,19 +36,8 @@
|
|||||||
|
|
||||||
#include "pqi/pqi.h"
|
#include "pqi/pqi.h"
|
||||||
|
|
||||||
/**************** PQI_USE_XPGP ******************/
|
class p3ConnectMgr;
|
||||||
#if defined(PQI_USE_XPGP)
|
class p3AuthMgr;
|
||||||
|
|
||||||
#include "pqi/xpgpcert.h"
|
|
||||||
|
|
||||||
#else /* X509 Certificates */
|
|
||||||
/**************** PQI_USE_XPGP ******************/
|
|
||||||
|
|
||||||
#include "pqi/sslcert.h"
|
|
||||||
|
|
||||||
#endif /* X509 Certificates */
|
|
||||||
/**************** PQI_USE_XPGP ******************/
|
|
||||||
|
|
||||||
|
|
||||||
#include "serialiser/rsdiscitems.h"
|
#include "serialiser/rsdiscitems.h"
|
||||||
#include "services/p3service.h"
|
#include "services/p3service.h"
|
||||||
@ -60,8 +49,8 @@ class autoserver
|
|||||||
:id(NULL), ca(NULL), connect(false), c_ts(0),
|
:id(NULL), ca(NULL), connect(false), c_ts(0),
|
||||||
listen(false), l_ts(0), discFlags(0) { return;}
|
listen(false), l_ts(0), discFlags(0) { return;}
|
||||||
|
|
||||||
Person *id;
|
std::string id;
|
||||||
Person *ca;
|
std::string ca;
|
||||||
bool connect;
|
bool connect;
|
||||||
unsigned int c_ts; // this is connect_tf converted to timestamp, 0 invalid.
|
unsigned int c_ts; // this is connect_tf converted to timestamp, 0 invalid.
|
||||||
|
|
||||||
@ -94,7 +83,7 @@ class p3disc: public p3Service
|
|||||||
bool remote_disc;
|
bool remote_disc;
|
||||||
//sslroot *sslbase;
|
//sslroot *sslbase;
|
||||||
|
|
||||||
p3disc(sslroot *r);
|
p3disc(p3AuthMgr *am, p3ConnectMgr *cm);
|
||||||
virtual ~p3disc();
|
virtual ~p3disc();
|
||||||
|
|
||||||
// Overloaded from p3Service functions.
|
// Overloaded from p3Service functions.
|
||||||
@ -155,15 +144,18 @@ std::list<cert *> potentialproxy(cert *target);
|
|||||||
int collectCerts();
|
int collectCerts();
|
||||||
int distillData();
|
int distillData();
|
||||||
|
|
||||||
|
#if 0
|
||||||
//cert *checkDuplicateX509(X509 *x509);
|
//cert *checkDuplicateX509(X509 *x509);
|
||||||
std::list<cert *> &getDiscovered();
|
std::list<cert *> &getDiscovered();
|
||||||
|
|
||||||
// Main Storage
|
// Main Storage
|
||||||
std::list<autoneighbour *> neighbours;
|
|
||||||
std::list<cert *> ad_init;
|
std::list<cert *> ad_init;
|
||||||
|
|
||||||
std::list<cert *> discovered;
|
std::list<cert *> discovered;
|
||||||
sslroot *sroot;
|
#endif
|
||||||
|
std::list<autoneighbour *> neighbours;
|
||||||
|
|
||||||
|
p3AuthMgr *mAuthMgr;
|
||||||
|
p3ConnectMgr *mConnMgr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MRK_PQI_AUTODISC_H
|
#endif // MRK_PQI_AUTODISC_H
|
||||||
|
@ -27,30 +27,15 @@
|
|||||||
#include "pqi/pqibin.h"
|
#include "pqi/pqibin.h"
|
||||||
#include "pqi/pqiarchive.h"
|
#include "pqi/pqiarchive.h"
|
||||||
#include "pqi/pqidebug.h"
|
#include "pqi/pqidebug.h"
|
||||||
|
#include "pqi/p3connmgr.h"
|
||||||
|
|
||||||
#include "services/p3msgservice.h"
|
#include "services/p3msgservice.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
|
|
||||||
/**************** PQI_USE_XPGP ******************/
|
|
||||||
#if defined(PQI_USE_XPGP)
|
|
||||||
|
|
||||||
#include "pqi/xpgpcert.h"
|
|
||||||
|
|
||||||
#else /* X509 Certificates */
|
|
||||||
/**************** PQI_USE_XPGP ******************/
|
|
||||||
|
|
||||||
#include "pqi/sslcert.h"
|
|
||||||
|
|
||||||
#endif /* X509 Certificates */
|
|
||||||
/**************** PQI_USE_XPGP ******************/
|
|
||||||
|
|
||||||
|
|
||||||
const int msgservicezone = 54319;
|
const int msgservicezone = 54319;
|
||||||
|
|
||||||
|
|
||||||
/* Another little hack ..... unique message Ids
|
/* Another little hack ..... unique message Ids
|
||||||
* will be handled in this class.....
|
* will be handled in this class.....
|
||||||
* These are unique within this run of the server,
|
* These are unique within this run of the server,
|
||||||
@ -68,11 +53,10 @@ unsigned int getNewUniqueMsgId()
|
|||||||
return msgUniqueId++;
|
return msgUniqueId++;
|
||||||
}
|
}
|
||||||
|
|
||||||
p3MsgService::p3MsgService()
|
p3MsgService::p3MsgService(p3ConnectMgr *cm)
|
||||||
:p3Service(RS_SERVICE_TYPE_MSG),
|
:p3Service(RS_SERVICE_TYPE_MSG), mConnMgr(cm),
|
||||||
msgChanged(1), msgMajorChanged(1)
|
msgChanged(1), msgMajorChanged(1)
|
||||||
{
|
{
|
||||||
sslr = getSSLRoot();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -110,7 +94,7 @@ int p3MsgService::incomingMsgs()
|
|||||||
mi -> recvTime = time(NULL);
|
mi -> recvTime = time(NULL);
|
||||||
std::string mesg;
|
std::string mesg;
|
||||||
|
|
||||||
if (mi -> PeerId() == sslr->getOwnCert()->PeerId())
|
if (mi -> PeerId() == mConnMgr->getOwnId())
|
||||||
{
|
{
|
||||||
/* from the loopback device */
|
/* from the loopback device */
|
||||||
mi -> msgFlags = RS_MSG_FLAGS_OUTGOING;
|
mi -> msgFlags = RS_MSG_FLAGS_OUTGOING;
|
||||||
@ -219,18 +203,23 @@ int p3MsgService::checkOutgoingMessages()
|
|||||||
* if online, send
|
* if online, send
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const std::string ownId = mConnMgr->getOwnId();
|
||||||
|
|
||||||
std::list<RsMsgItem *>::iterator it;
|
std::list<RsMsgItem *>::iterator it;
|
||||||
for(it = msgOutgoing.begin(); it != msgOutgoing.end();)
|
for(it = msgOutgoing.begin(); it != msgOutgoing.end();)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* find the certificate */
|
/* find the certificate */
|
||||||
certsign sign;
|
std::string pid = (*it)->PeerId();
|
||||||
convert_to_certsign((*it)->PeerId(), sign);
|
peerConnectState pstate;
|
||||||
cert *peer = sslr -> findcertsign(sign);
|
if (!mConnMgr->getFriendNetStatus(pid, pstate))
|
||||||
|
{
|
||||||
|
delete(*it);
|
||||||
|
it = msgOutgoing.erase(it);
|
||||||
|
}
|
||||||
/* if online, send it */
|
/* if online, send it */
|
||||||
if ((peer -> Status() & PERSON_STATUS_CONNECTED)
|
else if ((pstate.state & RS_PEER_S_ONLINE)
|
||||||
|| (peer == sslr->getOwnCert()))
|
|| (pid == ownId))
|
||||||
{
|
{
|
||||||
/* send msg */
|
/* send msg */
|
||||||
pqioutput(PQL_ALERT, msgservicezone,
|
pqioutput(PQL_ALERT, msgservicezone,
|
||||||
@ -359,7 +348,7 @@ void p3MsgService::loadWelcomeMsg()
|
|||||||
/* Load Welcome Message */
|
/* Load Welcome Message */
|
||||||
RsMsgItem *msg = new RsMsgItem();
|
RsMsgItem *msg = new RsMsgItem();
|
||||||
|
|
||||||
msg -> PeerId(sslr->getOwnCert()->PeerId());
|
msg -> PeerId(mConnMgr->getOwnId());
|
||||||
|
|
||||||
msg -> sendTime = 0;
|
msg -> sendTime = 0;
|
||||||
|
|
||||||
|
@ -37,13 +37,12 @@
|
|||||||
#include "serialiser/rsmsgitems.h"
|
#include "serialiser/rsmsgitems.h"
|
||||||
|
|
||||||
#include "rsiface/rsiface.h"
|
#include "rsiface/rsiface.h"
|
||||||
class pqimonitor;
|
class p3ConnectMgr;
|
||||||
class sslroot;
|
|
||||||
|
|
||||||
class p3MsgService: public p3Service
|
class p3MsgService: public p3Service
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
p3MsgService();
|
p3MsgService(p3ConnectMgr *cm);
|
||||||
|
|
||||||
void loadWelcomeMsg(); /* startup message */
|
void loadWelcomeMsg(); /* startup message */
|
||||||
|
|
||||||
@ -71,14 +70,14 @@ int incomingMsgs();
|
|||||||
std::list<RsMsgItem *> imsg;
|
std::list<RsMsgItem *> imsg;
|
||||||
std::list<RsMsgItem *> msgOutgoing; /* ones that haven't made it out yet! */
|
std::list<RsMsgItem *> msgOutgoing; /* ones that haven't made it out yet! */
|
||||||
|
|
||||||
|
p3ConnectMgr *mConnMgr;
|
||||||
|
|
||||||
// bool state flags.
|
// bool state flags.
|
||||||
public:
|
public:
|
||||||
Indicator msgChanged;
|
Indicator msgChanged;
|
||||||
Indicator msgMajorChanged;
|
Indicator msgMajorChanged;
|
||||||
|
|
||||||
sslroot *sslr;
|
|
||||||
std::string config_dir;
|
std::string config_dir;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MESSAGE_SERVICE_HEADER
|
#endif // MESSAGE_SERVICE_HEADER
|
||||||
|
Loading…
Reference in New Issue
Block a user