mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-10 07:32:42 -04:00
Add the tunneling connection. Warning, encryption is not implemented yet for tunnel connection, use only for testing.
Redesign the udp connection Remove the rsiface duplicates from retroshare-gui. Add some randomness in timings for connect manager Merge branch 'connectionTunneling' Conflicts: libretroshare/src/libretroshare.pro libretroshare/src/pqi/p3connmgr.cc retroshare-gui/src/RetroShare.pro retroshare-gui/src/rsiface/rsfiles.h retroshare-gui/src/rsiface/rstypes.h git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1867 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
1d567a7faa
commit
fdb3673ce2
56 changed files with 2420 additions and 3394 deletions
145
libretroshare/src/pqi/pqissltunnel.h
Normal file
145
libretroshare/src/pqi/pqissltunnel.h
Normal file
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
* "$Id: pqissl.h,v 1.18 2007-03-11 14:54:22 rmf24 Exp $"
|
||||
*
|
||||
* 3P/PQI network interface for RetroShare.
|
||||
*
|
||||
* Copyright 2004-2006 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_SSL_TUNNEL_HEADER
|
||||
#define MRK_PQI_SSL_TUNNEL_HEADER
|
||||
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
// operating system specific network header.
|
||||
//#include "pqi/pqinetwork.h"
|
||||
|
||||
#include "pqi/pqi_base.h"
|
||||
|
||||
#include "pqi/p3connmgr.h"
|
||||
|
||||
#include "services/p3tunnel.h"
|
||||
|
||||
#include "pqi/authssl.h"
|
||||
|
||||
/***************************** pqi Net SSL Interface *********************************
|
||||
* This provides the base SSL interface class,
|
||||
* and handles most of the required functionality.
|
||||
*
|
||||
* there are a series of small fn's that can be overloaded
|
||||
* to provide alternative behaviour....
|
||||
*
|
||||
* Classes expected to inherit from this are:
|
||||
*
|
||||
* pqissllistener -> pqissllistener (tcp only)
|
||||
* -> pqixpgplistener (tcp only)
|
||||
*
|
||||
* pqissl -> pqissltcp
|
||||
* -> pqissludp
|
||||
* -> pqixpgptcp
|
||||
* -> pqixpgpudp
|
||||
*
|
||||
*/
|
||||
|
||||
class pqissl;
|
||||
class cert;
|
||||
|
||||
class pqissltunnellistener;
|
||||
|
||||
struct data_with_length {
|
||||
int length;
|
||||
void *data;
|
||||
};
|
||||
|
||||
class pqissltunnel: public NetBinInterface
|
||||
{
|
||||
public:
|
||||
pqissltunnel(PQInterface *parent, p3AuthMgr *am, p3ConnectMgr *cm);
|
||||
virtual ~pqissltunnel();
|
||||
|
||||
// NetInterface
|
||||
|
||||
//the addr is not used for the tunnel
|
||||
virtual int connect(struct sockaddr_in raddr);
|
||||
virtual int listen();
|
||||
virtual int stoplistening();
|
||||
virtual int reset();
|
||||
virtual int disconnect();
|
||||
|
||||
virtual bool connect_parameter(uint32_t type, uint32_t value);
|
||||
|
||||
// BinInterface
|
||||
virtual int tick();
|
||||
virtual int status();
|
||||
|
||||
virtual int senddata(void*, int);
|
||||
virtual int readdata(void*, int);
|
||||
virtual int netstatus();
|
||||
virtual int isactive();
|
||||
virtual bool moretoread();
|
||||
virtual bool cansend();
|
||||
|
||||
virtual int close(); /* BinInterface version of reset() */
|
||||
virtual std::string gethash(); /* not used here */
|
||||
virtual bool bandwidthLimited() { return true ; } // replace by !sameLAN to avoid bandwidth limiting on lAN
|
||||
|
||||
//called by the p3tunnel service to add incoming packets that will be read by the read data function.
|
||||
void addIncomingPacket(void* encoded_data, int data_length);
|
||||
void IncommingPingPacket(std::string incRelayPeerId);
|
||||
|
||||
private:
|
||||
//if no packet (last_time_packet_time) is received since PING_RECEIVE_TIME_OUT, let's assume the connection is broken
|
||||
int last_normal_connection_attempt_time;
|
||||
|
||||
//if no packet (last_time_packet_time) is received since PING_RECEIVE_TIME_OUT, let's assume the connection is broken
|
||||
int last_packet_time;
|
||||
|
||||
//send a ping on a regular basis
|
||||
int last_ping_send_time;
|
||||
|
||||
int ConnectAttempt();
|
||||
void Spam_Ping();
|
||||
int waiting;
|
||||
bool active;
|
||||
time_t resetTime;
|
||||
pqissltunnellistener *pqil;
|
||||
|
||||
/* Need Certificate specific functions here! */
|
||||
time_t mConnectTS;
|
||||
|
||||
AuthSSL *mAuthMgr;
|
||||
|
||||
p3ConnectMgr *mConnMgr;
|
||||
|
||||
p3tunnel *mP3tunnel;
|
||||
|
||||
std::list<data_with_length> data_packet_queue;
|
||||
data_with_length curent_data_packet;
|
||||
int current_data_offset;
|
||||
|
||||
//tunneling details
|
||||
std::string relayPeerId;
|
||||
|
||||
};
|
||||
|
||||
#endif // MRK_PQI_SSL_HEADER
|
Loading…
Add table
Add a link
Reference in a new issue