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