mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Partially completed changes to implement final relay bits.
* Adding more detailed flags to each connection. * Cleaned up unneeded stuff from p3LinkMgr. * Added rswin.h includes before openssl - allows compilation using std Win OpenSSL. * Added getConnectFlags() to Net Base. * removed net_attempt and associated obsolete variables from pqissl * Made NetBinInterface protected in pqiperson (is this okay?) git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-dhtmods@4767 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
e432d89310
commit
abbebf48ff
@ -39,6 +39,7 @@
|
||||
#ifndef RS_GPG_AUTH_HEADER
|
||||
#define RS_GPG_AUTH_HEADER
|
||||
|
||||
#include "util/rswin.h"
|
||||
#include <gpgme.h>
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/evp.h>
|
||||
|
@ -39,6 +39,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "util/rswin.h"
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
|
@ -29,8 +29,6 @@
|
||||
#include "pqi/pqimonitor.h"
|
||||
#include "pqi/pqiipset.h"
|
||||
|
||||
//#include "pqi/p3dhtmgr.h"
|
||||
//#include "pqi/p3upnpmgr.h"
|
||||
#include "pqi/pqiassist.h"
|
||||
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
@ -40,22 +38,47 @@
|
||||
class ExtAddrFinder ;
|
||||
class DNSResolver ;
|
||||
|
||||
/* order of attempts ... */
|
||||
const uint32_t RS_NET_CONN_TCP_ALL = 0x000f;
|
||||
const uint32_t RS_NET_CONN_UDP_ALL = 0x00f0;
|
||||
const uint32_t RS_NET_CONN_TUNNEL = 0x0f00;
|
||||
/******************* FLAGS that are passed to p3LinkMgr *****
|
||||
* TRANSPORT: TCP/UDP/TUNNEL.
|
||||
* TYPE: SERVER / PEER.
|
||||
* LINK QUALITY: LIMITED, NORMAL, HIGH_SPEED.
|
||||
*/
|
||||
|
||||
const uint32_t RS_NET_CONN_TCP_LOCAL = 0x0001;
|
||||
const uint32_t RS_NET_CONN_TCP_EXTERNAL = 0x0002;
|
||||
const uint32_t RS_NET_CONN_TCP_UNKNOW_TOPOLOGY = 0x0004;
|
||||
const uint32_t RS_NET_CONN_UDP_DHT_SYNC = 0x0010;
|
||||
const uint32_t RS_NET_CONN_UDP_PEER_SYNC = 0x0020; /* coming soon */
|
||||
// CONNECTION
|
||||
const uint32_t RS_NET_CONN_TRANS_MASK = 0x0000ffff;
|
||||
const uint32_t RS_NET_CONN_TRANS_TCP_MASK = 0x0000000f;
|
||||
const uint32_t RS_NET_CONN_TRANS_TCP_UNKNOWN = 0x00000001;
|
||||
const uint32_t RS_NET_CONN_TRANS_TCP_LOCAL = 0x00000002;
|
||||
const uint32_t RS_NET_CONN_TRANS_TCP_EXTERNAL = 0x00000004;
|
||||
|
||||
const uint32_t RS_NET_CONN_TRANS_UDP_MASK = 0x000000f0;
|
||||
const uint32_t RS_NET_CONN_TRANS_UDP_UNKNOWN = 0x00000010;
|
||||
const uint32_t RS_NET_CONN_TRANS_UDP_DIRECT = 0x00000020;
|
||||
const uint32_t RS_NET_CONN_TRANS_UDP_PROXY = 0x00000040;
|
||||
const uint32_t RS_NET_CONN_TRANS_UDP_RELAY = 0x00000080;
|
||||
|
||||
const uint32_t RS_NET_CONN_TRANS_OTHER_MASK = 0x00000f00;
|
||||
const uint32_t RS_NET_CONN_TRANS_TUNNEL = 0x00000100;
|
||||
|
||||
|
||||
const uint32_t RS_NET_CONN_SPEED_MASK = 0x000f0000;
|
||||
const uint32_t RS_NET_CONN_SPEED_UNKNOWN = 0x00000000;
|
||||
const uint32_t RS_NET_CONN_SPEED_LOW = 0x00010000;
|
||||
const uint32_t RS_NET_CONN_SPEED_NORMAL = 0x00020000;
|
||||
const uint32_t RS_NET_CONN_SPEED_HIGH = 0x00040000;
|
||||
|
||||
const uint32_t RS_NET_CONN_QUALITY_MASK = 0x00f00000;
|
||||
const uint32_t RS_NET_CONN_QUALITY_UNKNOWN = 0x00000000;
|
||||
|
||||
// THIS INFO MUST BE SUPPLIED BY PEERMGR....
|
||||
// Don't know if it should be here.
|
||||
const uint32_t RS_NET_CONN_TYPE_MASK = 0x0f000000;
|
||||
const uint32_t RS_NET_CONN_TYPE_UNKNOWN = 0x00000000;
|
||||
const uint32_t RS_NET_CONN_TYPE_ACQUAINTANCE = 0x01000000;
|
||||
const uint32_t RS_NET_CONN_TYPE_FRIEND = 0x02000000;
|
||||
const uint32_t RS_NET_CONN_TYPE_SERVER = 0x04000000;
|
||||
const uint32_t RS_NET_CONN_TYPE_CLIENT = 0x08000000;
|
||||
|
||||
/* extra flags */
|
||||
// not sure if needed yet.
|
||||
//const uint32_t RS_NET_CONN_PEERAGE = 0x0f00;
|
||||
//const uint32_t RS_NET_CONN_SERVER = 0x0100; /* TCP only */
|
||||
//const uint32_t RS_NET_CONN_PEER = 0x0200; /* all UDP */
|
||||
|
||||
const uint32_t RS_TCP_STD_TIMEOUT_PERIOD = 5; /* 5 seconds! */
|
||||
const uint32_t RS_UDP_STD_TIMEOUT_PERIOD = 80; /* 80 secs, allows UDP TTL to get to 40! - Plenty of time (30+80) = 110 secs */
|
||||
@ -95,36 +118,17 @@ class peerConnectState
|
||||
peerConnectState(); /* init */
|
||||
|
||||
std::string id;
|
||||
//std::string gpg_id;
|
||||
|
||||
//uint32_t netMode; /* EXT / UPNP / UDP / INVALID */
|
||||
//uint32_t visState; /* STD, GRAY, DARK */
|
||||
|
||||
//struct sockaddr_in localaddr, serveraddr;
|
||||
|
||||
//used to store current ip (for config and connection management)
|
||||
//struct sockaddr_in currentlocaladdr; /* Mandatory */
|
||||
//struct sockaddr_in currentserveraddr; /* Mandatory */
|
||||
//std::string dyndns;
|
||||
|
||||
|
||||
/* list of addresses from various sources */
|
||||
//pqiIpAddrSet ipAddrs;
|
||||
|
||||
/***** Below here not stored permanently *****/
|
||||
|
||||
bool dhtVisible;
|
||||
|
||||
//time_t lastcontact;
|
||||
|
||||
uint32_t connecttype; // RS_NET_CONN_TCP_ALL / RS_NET_CONN_UDP_ALL
|
||||
time_t lastavailable;
|
||||
time_t lastattempt;
|
||||
|
||||
std::string name;
|
||||
|
||||
//std::string location;
|
||||
|
||||
uint32_t state;
|
||||
uint32_t actions;
|
||||
|
||||
|
@ -276,6 +276,7 @@ virtual int disconnect() = 0;
|
||||
virtual int reset() = 0;
|
||||
virtual std::string PeerId() { return peerId; }
|
||||
virtual int getConnectAddress(struct sockaddr_in &raddr) = 0;
|
||||
virtual int getConnectFlags(uint32_t &flags) = 0;
|
||||
|
||||
virtual bool connect_parameter(uint32_t type, uint32_t value) = 0;
|
||||
virtual bool connect_additional_address(uint32_t /*type*/, struct sockaddr_in */*addr*/) { return false; } // only needed by udp.
|
||||
|
@ -74,8 +74,8 @@ virtual bool connect_parameter(uint32_t type, uint32_t value) { return ni -> co
|
||||
virtual bool connect_additional_address(uint32_t type, struct sockaddr_in *addr) { return ni -> connect_additional_address(type, addr);}
|
||||
|
||||
|
||||
|
||||
virtual int getConnectAddress(struct sockaddr_in &raddr){ return ni->getConnectAddress(raddr); }
|
||||
virtual int getConnectFlags(uint32_t &flags){ return ni->getConnectFlags(flags); }
|
||||
|
||||
// get the contact from the net side!
|
||||
virtual std::string PeerId()
|
||||
@ -92,7 +92,7 @@ virtual std::string PeerId()
|
||||
|
||||
// to check if our interface.
|
||||
virtual bool thisNetInterface(NetInterface *ni_in) { return (ni_in == ni); }
|
||||
//protected:
|
||||
protected:
|
||||
NetBinInterface *ni;
|
||||
protected:
|
||||
};
|
||||
|
@ -101,7 +101,6 @@ pqissl::pqissl(pqissllistener *l, PQInterface *parent, p3LinkMgr *lm)
|
||||
pqil(l), // no init for remote_addr.
|
||||
readpkt(NULL), pktlen(0),
|
||||
attempt_ts(0),
|
||||
net_attempt(0), net_failure(0), net_unreachable(0),
|
||||
sameLAN(false), n_read_zero(0), mReadZeroTS(0),
|
||||
mConnectDelay(0), mConnectTS(0),
|
||||
mConnectTimeout(0), mTimeoutTS(0), mLinkMgr(lm)
|
||||
@ -151,7 +150,6 @@ pqissl::pqissl(pqissllistener *l, PQInterface *parent, p3LinkMgr *lm)
|
||||
int pqissl::connect(struct sockaddr_in raddr)
|
||||
{
|
||||
// reset failures
|
||||
net_failure = 0;
|
||||
remote_addr = raddr;
|
||||
remote_addr.sin_family = AF_INET;
|
||||
|
||||
@ -709,8 +707,6 @@ int pqissl::Initiate_Connection()
|
||||
//reset();
|
||||
|
||||
waiting = WAITING_FAIL_INTERFACE;
|
||||
// removing unreachables...
|
||||
//net_unreachable |= net_attempt;
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -923,8 +919,6 @@ int pqissl::Basic_Connection_Complete()
|
||||
//reset();
|
||||
|
||||
waiting = WAITING_FAIL_INTERFACE;
|
||||
// removing unreachables...
|
||||
//net_unreachable |= net_attempt;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -28,6 +28,8 @@
|
||||
#ifndef MRK_PQI_SSL_HEADER
|
||||
#define MRK_PQI_SSL_HEADER
|
||||
|
||||
#include "util/rswin.h"
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
// operating system specific network header.
|
||||
@ -98,6 +100,7 @@ virtual int stoplistening();
|
||||
virtual int reset();
|
||||
virtual int disconnect();
|
||||
virtual int getConnectAddress(struct sockaddr_in &raddr);
|
||||
virtual int getConnectFlags(uint32_t &flags);
|
||||
|
||||
virtual bool connect_parameter(uint32_t type, uint32_t value);
|
||||
|
||||
@ -114,7 +117,7 @@ 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
|
||||
virtual bool bandwidthLimited() { return true ; } // replace by !sameLAN to avoid bandwidth limiting on LAN
|
||||
|
||||
protected:
|
||||
// A little bit of information to describe
|
||||
@ -179,12 +182,7 @@ virtual int net_internal_fcntl_nonblock(int fd) { return unix_fcntl_nonblock(fd)
|
||||
|
||||
int attempt_ts;
|
||||
|
||||
// Some flags to indicate
|
||||
// the status of the various interfaces
|
||||
// (local), (server)
|
||||
unsigned int net_attempt;
|
||||
unsigned int net_failure;
|
||||
unsigned int net_unreachable;
|
||||
uint32_t mNetConnectFlags; // What info we have about the connection.
|
||||
|
||||
bool sameLAN; /* flag use to allow high-speed transfers */
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#ifndef MRK_PQI_SSL_TUNNEL_HEADER
|
||||
#define MRK_PQI_SSL_TUNNEL_HEADER
|
||||
|
||||
#include "util/rswin.h"
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
|
@ -28,6 +28,8 @@
|
||||
#ifndef MRK_PQI_SSL_UDP_HEADER
|
||||
#define MRK_PQI_SSL_UDP_HEADER
|
||||
|
||||
#include "util/rswin.h"
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
// operating system specific network header.
|
||||
@ -66,6 +68,8 @@ virtual int stoplistening();
|
||||
virtual int tick();
|
||||
virtual int reset();
|
||||
|
||||
//virtual int getConnectFlags(uint32_t &flags);
|
||||
|
||||
virtual bool connect_parameter(uint32_t type, uint32_t value);
|
||||
virtual bool connect_additional_address(uint32_t type, struct sockaddr_in *addr);
|
||||
|
||||
|
@ -33,6 +33,8 @@
|
||||
|
||||
/******************** notify of new Cert **************************/
|
||||
|
||||
#include "util/rswin.h"
|
||||
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/ssl.h>
|
||||
|
Loading…
Reference in New Issue
Block a user