Merged branch v0.5-GenericTunneling into trunk (Rev. 6284 to 6410).

- adds turtle router as a generic tunneling service
- made ftServer a client of the service. Now turtle file items are handled in ftServer
- added new client: p3MsgService to send/recv pgp-encrypted distant messages
- added new client: p3ChatService to perform private (AES-encrypted) distant chat through tunnels.
- The GUI is disabled for now, since it needs some polishing before being fully usable.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6411 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-06-06 19:58:30 +00:00
commit dc2521cf71
62 changed files with 5031 additions and 1989 deletions

View file

@ -58,6 +58,7 @@
#define RS_MSG_USER_REQUEST 0x0400 /* user request */
#define RS_MSG_FRIEND_RECOMMENDATION 0x0800 /* friend recommendation */
#define RS_MSG_SYSTEM (RS_MSG_USER_REQUEST | RS_MSG_FRIEND_RECOMMENDATION)
#define RS_MSG_ENCRYPTED 0x1000 /* message is encrypted */
#define RS_CHAT_LOBBY_EVENT_PEER_LEFT 0x01
#define RS_CHAT_LOBBY_EVENT_PEER_STATUS 0x02
@ -99,6 +100,7 @@ class MessageInfo
std::wstring attach_title;
std::wstring attach_comment;
std::list<FileInfo> files;
std::map<std::string,std::string> encryption_keys ; // for concerned ids only the public pgp key id to encrypt the message with.
int size; /* total of files */
int count; /* file count */
@ -144,6 +146,16 @@ public:
#define RS_CHAT_PRIVATE 0x0002
#define RS_CHAT_AVATAR_AVAILABLE 0x0004
#define RS_DISTANT_CHAT_STATUS_UNKNOWN 0x0000
#define RS_DISTANT_CHAT_STATUS_TUNNEL_DN 0x0001
#define RS_DISTANT_CHAT_STATUS_TUNNEL_OK 0x0002
#define RS_DISTANT_CHAT_STATUS_CAN_TALK 0x0003
#define RS_DISTANT_CHAT_ERROR_NO_ERROR 0x0000
#define RS_DISTANT_CHAT_ERROR_DECRYPTION_FAILED 0x0001
#define RS_DISTANT_CHAT_ERROR_SIGNATURE_MISMATCH 0x0002
#define RS_DISTANT_CHAT_ERROR_UNKNOWN_KEY 0x0003
class ChatInfo
{
public:
@ -195,6 +207,14 @@ class ChatLobbyInfo
time_t last_activity ; // last recorded activity. Useful for removing dead lobbies.
};
struct DistantChatInviteInfo
{
std::string hash ; // hash to contact the invite and refer to it.
std::string encrypted_radix64_string ; // encrypted radix string used to for the chat link
std::string destination_pgp_id ; // pgp is of the destination of the chat link
time_t time_of_validity ; // time when te invite becomes unusable
};
std::ostream &operator<<(std::ostream &out, const MessageInfo &info);
std::ostream &operator<<(std::ostream &out, const ChatInfo &info);
@ -203,6 +223,14 @@ bool operator==(const ChatInfo&, const ChatInfo&);
class RsMsgs;
extern RsMsgs *rsMsgs;
struct DistantOfflineMessengingInvite
{
std::string issuer_pgp_id ;
std::string hash ;
time_t time_of_validity ;
};
class RsMsgs
{
public:
@ -211,11 +239,13 @@ class RsMsgs
virtual ~RsMsgs() { return; }
/****************************************/
/* Message Items */
/* Message Items */
/****************************************/
virtual bool getMessageSummaries(std::list<MsgInfoSummary> &msgList) = 0;
virtual bool getMessage(const std::string &mId, MessageInfo &msg) = 0;
virtual void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox) = 0;
virtual bool decryptMessage(const std::string& mId) = 0 ;
virtual bool MessageSend(MessageInfo &info) = 0;
virtual bool SystemMessage(const std::wstring &title, const std::wstring &message, uint32_t systemFlag) = 0;
@ -241,8 +271,14 @@ virtual bool setMessageTag(const std::string &msgId, uint32_t tagId, bool set) =
virtual bool resetMessageStandardTagTypes(MsgTagType& tags) = 0;
/* private distant messages */
virtual bool createDistantOfflineMessengingInvite(time_t validity_time_stamp, std::string& hash)=0 ;
virtual bool getDistantOfflineMessengingInvites(std::vector<DistantOfflineMessengingInvite>& invites) = 0 ;
/****************************************/
/* Chat */
/****************************************/
/* Chat */
virtual bool sendPublicChat(const std::wstring& msg) = 0;
virtual bool sendPrivateChat(const std::string& id, const std::wstring& msg) = 0;
virtual int getPublicChatQueueCount() = 0;
@ -265,6 +301,10 @@ virtual void getAvatarData(const std::string& pid,unsigned char *& data,int& siz
virtual void setOwnAvatarData(const unsigned char *data,int size) = 0 ;
virtual void getOwnAvatarData(unsigned char *& data,int& size) = 0 ;
/****************************************/
/* Chat lobbies */
/****************************************/
virtual bool joinVisibleChatLobby(const ChatLobbyId& lobby_id) = 0 ;
virtual bool isLobbyId(const std::string& virtual_peer_id,ChatLobbyId& lobby_id) = 0;
virtual bool getVirtualPeerId(const ChatLobbyId& lobby_id,std::string& vpid) = 0;
@ -282,6 +322,13 @@ virtual bool getDefaultNickNameForChatLobby(std::string& nick) = 0 ;
virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const std::string& lobby_topic,const std::list<std::string>& invited_friends,uint32_t lobby_privacy_type) = 0 ;
/****************************************/
/* Distant chat */
/****************************************/
virtual bool createDistantChatInvite(const std::string& pgp_id,time_t time_of_validity,std::string& encrypted_string) = 0 ;
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) = 0;
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,std::string& hash,uint32_t& error_code) = 0;
virtual bool getDistantChatStatus(const std::string& hash,uint32_t& status,std::string& pgp_id) = 0;
};

View file

@ -34,6 +34,7 @@
#include <vector>
class LinearizedExpression ;
class RsTurtleClientService ;
class RsTurtle;
extern RsTurtle *rsTurtle ;
@ -83,8 +84,6 @@ class TurtleTrafficStatisticsInfo
class RsTurtle
{
public:
enum FileSharingStrategy { SHARE_ENTIRE_NETWORK, SHARE_FRIENDS_ONLY } ;
RsTurtle() {}
virtual ~RsTurtle() {}
@ -103,23 +102,27 @@ class RsTurtle
virtual TurtleRequestId turtleSearch(const std::string& match_string) = 0 ;
virtual TurtleRequestId turtleSearch(const LinearizedExpression& expr) = 0 ;
// Sets the file sharing strategy. It concerns all local files. It would
// be better to handle this for each file, of course.
void setFileSharingStrategy(FileSharingStrategy f) { _sharing_strategy = f ; }
// Initiates tunnel handling for the given file hash. tunnels. Launches
// an exception if an error occurs during the initialization process. The
// turtle router itself does not initiate downloads, it only maintains
// tunnels for the given hash. The download should be driven by the file
// transfer module by calling ftServer::FileRequest().
//
virtual void monitorFileTunnels(const std::string& name,const std::string& file_hash,uint64_t size) = 0 ;
virtual void monitorTunnels(const std::string& file_hash,RsTurtleClientService *client_service) = 0 ;
// Tells the turtle router to stop handling tunnels for the given file hash. Traditionally this should
// be called after calling ftServer::fileCancel().
//
virtual void stopMonitoringFileTunnels(const std::string& file_hash) = 0 ;
virtual void stopMonitoringTunnels(const std::string& file_hash) = 0 ;
/// Adds a client tunnel service. This means that the service will be added
/// to the list of services that might respond to tunnel requests.
/// Example tunnel services include:
///
/// p3ChatService: tunnels correspond to private distant chatting
/// ftServer : tunnels correspond to file data transfer
///
virtual void registerTunnelService(RsTurtleClientService *service) = 0;
// Get info from the turtle router. I use std strings to hide the internal structs.
//
@ -136,8 +139,6 @@ class RsTurtle
// Hardcore handles
virtual void setMaxTRForwardRate(int max_tr_up_rate) = 0 ;
virtual int getMaxTRForwardRate() const = 0 ;
protected:
FileSharingStrategy _sharing_strategy ;
};
#endif