mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-15 17:40:35 -04:00
compilation works, except gxs
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-IdCleaning@7116 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
2b10076273
commit
65ccabced7
5 changed files with 78 additions and 71 deletions
|
@ -87,6 +87,8 @@ typedef uint64_t ChatLobbyId ;
|
||||||
typedef uint64_t ChatLobbyMsgId ;
|
typedef uint64_t ChatLobbyMsgId ;
|
||||||
typedef std::string ChatLobbyNickName ;
|
typedef std::string ChatLobbyNickName ;
|
||||||
|
|
||||||
|
typedef RsPeerId DistantChatPeerId ;
|
||||||
|
|
||||||
class MessageInfo
|
class MessageInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -220,7 +222,7 @@ class ChatLobbyInfo
|
||||||
|
|
||||||
struct DistantChatInviteInfo
|
struct DistantChatInviteInfo
|
||||||
{
|
{
|
||||||
std::string hash ; // hash to contact the invite and refer to it.
|
DistantChatPeerId pid ; // pid to contact the invite and refer to it.
|
||||||
std::string encrypted_radix64_string ; // encrypted radix string used to for the chat link
|
std::string encrypted_radix64_string ; // encrypted radix string used to for the chat link
|
||||||
PGPIdType destination_pgp_id ; // pgp is of the destination of the chat link
|
PGPIdType destination_pgp_id ; // pgp is of the destination of the chat link
|
||||||
time_t time_of_validity ; // time when te invite becomes unusable
|
time_t time_of_validity ; // time when te invite becomes unusable
|
||||||
|
@ -345,11 +347,11 @@ virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const std::str
|
||||||
|
|
||||||
virtual bool createDistantChatInvite(const PGPIdType& pgp_id,time_t time_of_validity,std::string& encrypted_string) = 0 ;
|
virtual bool createDistantChatInvite(const PGPIdType& pgp_id,time_t time_of_validity,std::string& encrypted_string) = 0 ;
|
||||||
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) = 0;
|
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) = 0;
|
||||||
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t validity_time,std::string& hash,uint32_t& error_code) = 0;
|
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t validity_time,DistantChatPeerId& pid,uint32_t& error_code) = 0;
|
||||||
virtual bool initiateDistantChatConnexion(const std::string& hash,uint32_t& error_code) = 0;
|
virtual bool initiateDistantChatConnexion(const DistantChatPeerId& pid,uint32_t& error_code) = 0;
|
||||||
virtual bool getDistantChatStatus(const std::string& hash,uint32_t& status,PGPIdType& pgp_id) = 0;
|
virtual bool getDistantChatStatus(const DistantChatPeerId& pid,uint32_t& status,PGPIdType& pgp_id) = 0;
|
||||||
virtual bool closeDistantChatConnexion(const std::string& hash) = 0;
|
virtual bool closeDistantChatConnexion(const DistantChatPeerId& pid) = 0;
|
||||||
virtual bool removeDistantChatInvite(const std::string& hash) = 0 ;
|
virtual bool removeDistantChatInvite(const DistantChatPeerId& pid) = 0 ;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -379,24 +379,24 @@ bool p3Msgs::getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invite
|
||||||
{
|
{
|
||||||
return mChatSrv->getDistantChatInviteList(invites) ;
|
return mChatSrv->getDistantChatInviteList(invites) ;
|
||||||
}
|
}
|
||||||
bool p3Msgs::initiateDistantChatConnexion(const std::string& encrypted_str,time_t validity_time,std::string& hash,uint32_t& error_code)
|
bool p3Msgs::initiateDistantChatConnexion(const std::string& encrypted_str,time_t validity_time,DistantChatPeerId& pid,uint32_t& error_code)
|
||||||
{
|
{
|
||||||
return mChatSrv->initiateDistantChatConnexion(encrypted_str,validity_time,hash,error_code) ;
|
return mChatSrv->initiateDistantChatConnexion(encrypted_str,validity_time,pid,error_code) ;
|
||||||
}
|
}
|
||||||
bool p3Msgs::initiateDistantChatConnexion(const std::string& hash,uint32_t& error_code)
|
bool p3Msgs::initiateDistantChatConnexion(const DistantChatPeerId& pid,uint32_t& error_code)
|
||||||
{
|
{
|
||||||
return mChatSrv->initiateDistantChatConnexion(hash,error_code) ;
|
return mChatSrv->initiateDistantChatConnexion(pid,error_code) ;
|
||||||
}
|
}
|
||||||
bool p3Msgs::getDistantChatStatus(const std::string& hash,uint32_t& status,PGPIdType& pgp_id)
|
bool p3Msgs::getDistantChatStatus(const DistantChatPeerId& pid,uint32_t& status,PGPIdType& pgp_id)
|
||||||
{
|
{
|
||||||
return mChatSrv->getDistantChatStatus(hash,status,pgp_id) ;
|
return mChatSrv->getDistantChatStatus(pid,status,pgp_id) ;
|
||||||
}
|
}
|
||||||
bool p3Msgs::closeDistantChatConnexion(const std::string& hash)
|
bool p3Msgs::closeDistantChatConnexion(const DistantChatPeerId& pid)
|
||||||
{
|
{
|
||||||
return mChatSrv->closeDistantChatConnexion(hash) ;
|
return mChatSrv->closeDistantChatConnexion(pid) ;
|
||||||
}
|
}
|
||||||
bool p3Msgs::removeDistantChatInvite(const std::string& hash)
|
bool p3Msgs::removeDistantChatInvite(const DistantChatPeerId& pid)
|
||||||
{
|
{
|
||||||
return mChatSrv->removeDistantChatInvite(hash) ;
|
return mChatSrv->removeDistantChatInvite(pid) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -196,11 +196,11 @@ class p3Msgs: public RsMsgs
|
||||||
|
|
||||||
virtual bool createDistantChatInvite(const PGPIdType& pgp_id,time_t time_of_validity,std::string& encrypted_string) ;
|
virtual bool createDistantChatInvite(const PGPIdType& pgp_id,time_t time_of_validity,std::string& encrypted_string) ;
|
||||||
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites);
|
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites);
|
||||||
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t validity_time,std::string& hash,uint32_t& error_code) ;
|
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t validity_time,DistantChatPeerId& pid,uint32_t& error_code) ;
|
||||||
virtual bool initiateDistantChatConnexion(const std::string& hash,uint32_t& error_code) ;
|
virtual bool initiateDistantChatConnexion(const DistantChatPeerId& pid,uint32_t& error_code) ;
|
||||||
virtual bool getDistantChatStatus(const std::string& hash,uint32_t& status,PGPIdType& pgp_id) ;
|
virtual bool getDistantChatStatus(const DistantChatPeerId& pid,uint32_t& status,PGPIdType& pgp_id) ;
|
||||||
virtual bool closeDistantChatConnexion(const std::string& hash) ;
|
virtual bool closeDistantChatConnexion(const DistantChatPeerId& pid) ;
|
||||||
virtual bool removeDistantChatInvite(const std::string& hash) ;
|
virtual bool removeDistantChatInvite(const DistantChatPeerId& pid) ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -459,7 +459,7 @@ bool p3ChatService::isLobbyId(const RsPeerId& virtual_peer_id,ChatLobbyId& lobby
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::isOnline(const RsPeerId& id)
|
bool p3ChatService::isOnline(const DistantChatPeerId& pid)
|
||||||
{
|
{
|
||||||
// check if the id is a tunnel id or a peer id.
|
// check if the id is a tunnel id or a peer id.
|
||||||
|
|
||||||
|
@ -467,10 +467,10 @@ bool p3ChatService::isOnline(const RsPeerId& id)
|
||||||
PGPIdType pgp_id ;
|
PGPIdType pgp_id ;
|
||||||
|
|
||||||
std::string hash ;
|
std::string hash ;
|
||||||
if(findHashForVirtualPeerId(id,hash) && getDistantChatStatus(hash,status,pgp_id))
|
if(getDistantChatStatus(pid,status,pgp_id))
|
||||||
return true ;
|
return true ;
|
||||||
else
|
else
|
||||||
return mLinkMgr->isOnline(id) ;
|
return mLinkMgr->isOnline(pid) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::sendPrivateChat(const RsPeerId &id, const std::string &msg)
|
bool p3ChatService::sendPrivateChat(const RsPeerId &id, const std::string &msg)
|
||||||
|
@ -3292,25 +3292,12 @@ void p3ChatService::receiveTurtleData( RsTurtleGenericTunnelItem *gitem,const st
|
||||||
|
|
||||||
// Setup the virtual peer to be the origin, and pass it on.
|
// Setup the virtual peer to be the origin, and pass it on.
|
||||||
//
|
//
|
||||||
citem->PeerId(virtual_peer_id) ;
|
citem->PeerId(virtualPeerIdFromHash(hash)) ;
|
||||||
//RsServer::notify()->notifyPeerStatusChanged(hash,RS_STATUS_ONLINE) ;
|
//RsServer::notify()->notifyPeerStatusChanged(hash,RS_STATUS_ONLINE) ;
|
||||||
|
|
||||||
handleIncomingItem(citem) ; // Treats the item, and deletes it
|
handleIncomingItem(citem) ; // Treats the item, and deletes it
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::findHashForVirtualPeerId(const TurtleVirtualPeerId& vpid,std::string& hash)
|
|
||||||
{
|
|
||||||
// Looks costly, but there's very few distant chat peers at a time, so this is not.
|
|
||||||
//
|
|
||||||
for(std::map<TurtleFileHash,DistantChatPeerInfo>::const_iterator it = _distant_chat_peers.begin();it!=_distant_chat_peers.end();++it)
|
|
||||||
if(it->second.virtual_peer_id == vpid)
|
|
||||||
{
|
|
||||||
hash = it->first ;
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
return false ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void p3ChatService::sendTurtleData(RsChatItem *item)
|
void p3ChatService::sendTurtleData(RsChatItem *item)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DISTANT_CHAT
|
#ifdef DEBUG_DISTANT_CHAT
|
||||||
|
@ -3331,28 +3318,23 @@ void p3ChatService::sendTurtleData(RsChatItem *item)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t aes_key[DISTANT_CHAT_AES_KEY_SIZE] ;
|
uint8_t aes_key[DISTANT_CHAT_AES_KEY_SIZE] ;
|
||||||
RsPeerId virtual_peer_id = item->PeerId();
|
|
||||||
|
|
||||||
TurtleFileHash hash ;
|
TurtleFileHash hash = hashFromVirtualPeerId(item->PeerId());
|
||||||
if(findHashForVirtualPeerId(virtual_peer_id,hash))
|
TurtleVirtualPeerId virtual_peer_id ;
|
||||||
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
std::map<TurtleFileHash,DistantChatPeerInfo>::iterator it = _distant_chat_peers.find(hash) ;
|
std::map<TurtleFileHash,DistantChatPeerInfo>::iterator it = _distant_chat_peers.find(hash) ;
|
||||||
|
|
||||||
if(it == _distant_chat_peers.end())
|
if(it == _distant_chat_peers.end())
|
||||||
{
|
{
|
||||||
std::cerr << "(EE) item is not going into a registered tunnel. Weird. peer id = " << virtual_peer_id << std::endl;
|
std::cerr << "(EE) item is not going into a registered tunnel. Weird. peer id = " << item->PeerId() << std::endl;
|
||||||
delete[] buff ;
|
delete[] buff ;
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
it->second.last_contact = time(NULL) ;
|
it->second.last_contact = time(NULL) ;
|
||||||
memcpy(aes_key,it->second.aes_key,DISTANT_CHAT_AES_KEY_SIZE) ;
|
memcpy(aes_key,it->second.aes_key,DISTANT_CHAT_AES_KEY_SIZE) ;
|
||||||
}
|
virtual_peer_id = it->second.virtual_peer_id ;
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cerr << "(EE) p3ChatService::sendTurtleData(): virtual peer id " << virtual_peer_id << " is unknown!!" << std::endl;
|
|
||||||
delete[] buff ;
|
|
||||||
return ;
|
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_DISTANT_CHAT
|
#ifdef DEBUG_DISTANT_CHAT
|
||||||
std::cerr << "p3ChatService::sendTurtleData(): tunnel found. Encrypting data." << std::endl;
|
std::cerr << "p3ChatService::sendTurtleData(): tunnel found. Encrypting data." << std::endl;
|
||||||
|
@ -3489,7 +3471,7 @@ bool p3ChatService::createDistantChatInvite(const PGPIdType& pgp_id,time_t time_
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::initiateDistantChatConnexion(const std::string& encrypted_str,time_t time_of_validity,std::string& hash,uint32_t& error_code)
|
bool p3ChatService::initiateDistantChatConnexion(const std::string& encrypted_str,time_t time_of_validity,DistantChatPeerId& pid,uint32_t& error_code)
|
||||||
{
|
{
|
||||||
// Un-radix the string.
|
// Un-radix the string.
|
||||||
//
|
//
|
||||||
|
@ -3534,7 +3516,8 @@ bool p3ChatService::initiateDistantChatConnexion(const std::string& encrypted_st
|
||||||
#ifdef DEBUG_DISTANT_CHAT
|
#ifdef DEBUG_DISTANT_CHAT
|
||||||
std::cerr << "Signature successfuly verified!" << std::endl;
|
std::cerr << "Signature successfuly verified!" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
hash = Sha1CheckSum(data).toStdString() ;
|
TurtleFileHash hash = Sha1CheckSum(data).toStdString() ;
|
||||||
|
pid = virtualPeerIdFromHash(hash) ;
|
||||||
|
|
||||||
startClientDistantChatConnection(hash,pgp_id,data+DISTANT_CHAT_HASH_SIZE) ;
|
startClientDistantChatConnection(hash,pgp_id,data+DISTANT_CHAT_HASH_SIZE) ;
|
||||||
|
|
||||||
|
@ -3574,11 +3557,12 @@ bool p3ChatService::initiateDistantChatConnexion(const std::string& encrypted_st
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::initiateDistantChatConnexion(const std::string& hash,uint32_t& error_code)
|
bool p3ChatService::initiateDistantChatConnexion(const DistantChatPeerId& pid,uint32_t& error_code)
|
||||||
{
|
{
|
||||||
PGPIdType pgp_id ;
|
PGPIdType pgp_id ;
|
||||||
unsigned char aes_key[DISTANT_CHAT_AES_KEY_SIZE] ;
|
unsigned char aes_key[DISTANT_CHAT_AES_KEY_SIZE] ;
|
||||||
|
|
||||||
|
TurtleFileHash hash = hashFromVirtualPeerId(pid) ;
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
|
@ -3656,15 +3640,33 @@ void p3ChatService::cleanDistantChatInvites()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DistantChatPeerId p3ChatService::virtualPeerIdFromHash(const TurtleFileHash& hash)
|
||||||
|
{
|
||||||
|
if(DistantChatPeerId::SIZE_IN_BYTES < Sha1CheckSum::SIZE_IN_BYTES)
|
||||||
|
std::cerr << __PRETTY_FUNCTION__ << ": Serious inconsistency error." << std::endl;
|
||||||
|
|
||||||
|
unsigned char tmp[DistantChatPeerId::SIZE_IN_BYTES] ;
|
||||||
|
memset(tmp,0,DistantChatPeerId::SIZE_IN_BYTES) ;
|
||||||
|
memcpy(tmp,Sha1CheckSum(hash).toByteArray(),Sha1CheckSum::SIZE_IN_BYTES) ;
|
||||||
|
|
||||||
|
return DistantChatPeerId(tmp) ;
|
||||||
|
}
|
||||||
|
TurtleFileHash p3ChatService::hashFromVirtualPeerId(const DistantChatPeerId& pid)
|
||||||
|
{
|
||||||
|
if(DistantChatPeerId::SIZE_IN_BYTES < Sha1CheckSum::SIZE_IN_BYTES)
|
||||||
|
std::cerr << __PRETTY_FUNCTION__ << ": Serious inconsistency error." << std::endl;
|
||||||
|
|
||||||
|
return Sha1CheckSum(pid.toByteArray()).toStdString() ;
|
||||||
|
}
|
||||||
bool p3ChatService::getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites)
|
bool p3ChatService::getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites)
|
||||||
{
|
{
|
||||||
invites.clear() ;
|
invites.clear() ;
|
||||||
|
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
for(std::map<std::string,DistantChatInvite>::const_iterator it(_distant_chat_invites.begin());it!=_distant_chat_invites.end();++it)
|
for(std::map<TurtleFileHash,DistantChatInvite>::const_iterator it(_distant_chat_invites.begin());it!=_distant_chat_invites.end();++it)
|
||||||
{
|
{
|
||||||
DistantChatInviteInfo info ;
|
DistantChatInviteInfo info ;
|
||||||
info.hash = it->first ;
|
info.pid = virtualPeerIdFromHash(it->first) ;
|
||||||
info.encrypted_radix64_string = it->second.encrypted_radix64_string ;
|
info.encrypted_radix64_string = it->second.encrypted_radix64_string ;
|
||||||
info.time_of_validity = it->second.time_of_validity ;
|
info.time_of_validity = it->second.time_of_validity ;
|
||||||
info.destination_pgp_id = it->second.destination_pgp_id ;
|
info.destination_pgp_id = it->second.destination_pgp_id ;
|
||||||
|
@ -3675,10 +3677,11 @@ bool p3ChatService::getDistantChatInviteList(std::vector<DistantChatInviteInfo>&
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::getDistantChatStatus(const std::string& hash,uint32_t& status,PGPIdType& pgp_id)
|
bool p3ChatService::getDistantChatStatus(const DistantChatPeerId& pid,uint32_t& status,PGPIdType& pgp_id)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
|
TurtleFileHash hash = hashFromVirtualPeerId(pid) ;
|
||||||
std::map<TurtleFileHash,DistantChatPeerInfo>::const_iterator it = _distant_chat_peers.find(hash) ;
|
std::map<TurtleFileHash,DistantChatPeerInfo>::const_iterator it = _distant_chat_peers.find(hash) ;
|
||||||
|
|
||||||
if(it == _distant_chat_peers.end())
|
if(it == _distant_chat_peers.end())
|
||||||
|
@ -3693,12 +3696,14 @@ bool p3ChatService::getDistantChatStatus(const std::string& hash,uint32_t& statu
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::closeDistantChatConnexion(const std::string& hash)
|
bool p3ChatService::closeDistantChatConnexion(const DistantChatPeerId& pid)
|
||||||
{
|
{
|
||||||
// two cases:
|
// two cases:
|
||||||
// - client needs to stop asking for tunnels => remove the hash from the list of tunnelled files
|
// - client needs to stop asking for tunnels => remove the hash from the list of tunnelled files
|
||||||
// - server needs to only close the window and let the tunnel die. But the window should only open if a message arrives.
|
// - server needs to only close the window and let the tunnel die. But the window should only open if a message arrives.
|
||||||
|
|
||||||
|
TurtleFileHash hash = hashFromVirtualPeerId(pid) ;
|
||||||
|
|
||||||
bool is_client = false ;
|
bool is_client = false ;
|
||||||
RsPeerId virtual_peer_id ;
|
RsPeerId virtual_peer_id ;
|
||||||
{
|
{
|
||||||
|
@ -3749,16 +3754,11 @@ bool p3ChatService::closeDistantChatConnexion(const std::string& hash)
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3ChatService::markDistantChatAsClosed(const RsPeerId& vpid)
|
void p3ChatService::markDistantChatAsClosed(const DistantChatPeerId& pid)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
std::string hash ;
|
TurtleFileHash hash = hashFromVirtualPeerId(pid) ;
|
||||||
if(!findHashForVirtualPeerId(vpid,hash))
|
|
||||||
{
|
|
||||||
std::cerr << "Cannot mark distant chat as closed for vpid " << vpid << ": not found." << std::endl;
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
std::map<TurtleFileHash,DistantChatPeerInfo>::iterator it = _distant_chat_peers.find(hash) ;
|
std::map<TurtleFileHash,DistantChatPeerInfo>::iterator it = _distant_chat_peers.find(hash) ;
|
||||||
|
|
||||||
if(it == _distant_chat_peers.end()) // server side. Nothing to do.
|
if(it == _distant_chat_peers.end()) // server side. Nothing to do.
|
||||||
|
@ -3770,9 +3770,11 @@ void p3ChatService::markDistantChatAsClosed(const RsPeerId& vpid)
|
||||||
it->second.status = RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED ;
|
it->second.status = RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::removeDistantChatInvite(const std::string& hash)
|
bool p3ChatService::removeDistantChatInvite(const DistantChatPeerId& pid)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
|
TurtleFileHash hash= hashFromVirtualPeerId(pid) ;
|
||||||
std::map<TurtleFileHash,DistantChatInvite>::iterator it = _distant_chat_invites.find(hash) ;
|
std::map<TurtleFileHash,DistantChatInvite>::iterator it = _distant_chat_invites.find(hash) ;
|
||||||
|
|
||||||
if(it == _distant_chat_invites.end()) // server side. Nothing to do.
|
if(it == _distant_chat_invites.end()) // server side. Nothing to do.
|
||||||
|
|
|
@ -327,14 +327,14 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||||
// Creates the invite if the public key of the distant peer is available.
|
// Creates the invite if the public key of the distant peer is available.
|
||||||
// Om success, stores the invite in the map above, so that we can respond to tunnel requests.
|
// Om success, stores the invite in the map above, so that we can respond to tunnel requests.
|
||||||
//
|
//
|
||||||
bool createDistantChatInvite(const PGPIdType& pgp_id,time_t time_of_validity,TurtleFileHash& hash) ;
|
bool createDistantChatInvite(const PGPIdType& pgp_id,time_t time_of_validity,std::string& enc_b64_string) ;
|
||||||
bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) ;
|
bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) ;
|
||||||
bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t time_of_validity,std::string& hash,uint32_t& error_code) ; // from encrypted data
|
bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t time_of_validity,DistantChatPeerId& pid,uint32_t& error_code) ; // from encrypted data
|
||||||
bool initiateDistantChatConnexion(const std::string& hash,uint32_t& error_code) ; // from known hash of a decrypted link
|
bool initiateDistantChatConnexion(const DistantChatPeerId& pid,uint32_t& error_code) ; // from known hash of a decrypted link
|
||||||
bool closeDistantChatConnexion(const std::string& hash) ;
|
bool closeDistantChatConnexion(const DistantChatPeerId& pid) ;
|
||||||
bool removeDistantChatInvite(const std::string& hash) ;
|
bool removeDistantChatInvite(const DistantChatPeerId& pid) ;
|
||||||
|
|
||||||
virtual bool getDistantChatStatus(const std::string& hash,uint32_t& status,PGPIdType& pgp_id) ;
|
virtual bool getDistantChatStatus(const DistantChatPeerId& hash,uint32_t& status,PGPIdType& pgp_id) ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct DistantChatInvite
|
struct DistantChatInvite
|
||||||
|
@ -351,8 +351,8 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||||
time_t last_contact ; // used to send keep alive packets
|
time_t last_contact ; // used to send keep alive packets
|
||||||
unsigned char aes_key[16] ; // key to encrypt packets
|
unsigned char aes_key[16] ; // key to encrypt packets
|
||||||
uint32_t status ; // info: do we have a tunnel ?
|
uint32_t status ; // info: do we have a tunnel ?
|
||||||
RsPeerId virtual_peer_id; // given by the turtle router. Identifies the tunnel.
|
RsPeerId virtual_peer_id; // given by the turtle router. Identifies the tunnel.
|
||||||
PGPIdType pgp_id ; // pgp id of the peer we're talking to.
|
PGPIdType pgp_id ; // pgp id of the peer we're talking to.
|
||||||
RsTurtleGenericTunnelItem::Direction direction ; // specifiec wether we are client(managing the tunnel) or server.
|
RsTurtleGenericTunnelItem::Direction direction ; // specifiec wether we are client(managing the tunnel) or server.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -386,6 +386,9 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||||
void sendTurtleData(RsChatItem *) ;
|
void sendTurtleData(RsChatItem *) ;
|
||||||
void sendPrivateChatItem(RsChatItem *) ;
|
void sendPrivateChatItem(RsChatItem *) ;
|
||||||
|
|
||||||
|
static TurtleFileHash hashFromVirtualPeerId(const DistantChatPeerId& peerId) ; // converts IDs so that we can talk to RsPeerId from outside
|
||||||
|
static DistantChatPeerId virtualPeerIdFromHash(const TurtleFileHash& hash ) ; // ... and to a hash for p3turtle
|
||||||
|
|
||||||
p3turtle *mTurtle ;
|
p3turtle *mTurtle ;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue