Removed some cruft like mymethod(){return;} from pqi

This commit is contained in:
Gio 2015-10-30 09:23:59 +01:00
parent 12acf6de35
commit 30e40470e2
7 changed files with 120 additions and 142 deletions

View File

@ -267,57 +267,57 @@ const uint32_t PQI_CONNECT_HIDDEN_I2P_TCP = 0x0008;
class BinInterface class BinInterface
{ {
public: public:
BinInterface() { return; } BinInterface() {}
virtual ~BinInterface() { return; } virtual ~BinInterface() {}
/** /**
* To be called loop, for updating state * To be called loop, for updating state
*/ */
virtual int tick() = 0; virtual int tick() = 0;
/** /**
* Sends data to a prescribed location (implementation dependent) * Sends data to a prescribed location (implementation dependent)
*@param data what will be sent *@param data what will be sent
*@param len the size of data pointed to in memory *@param len the size of data pointed to in memory
*/ */
virtual int senddata(void *data, int len) = 0; virtual int senddata(void *data, int len) = 0;
/** /**
* reads data from a prescribed location (implementation dependent) * reads data from a prescribed location (implementation dependent)
*@param data what will be sent *@param data what will be sent
*@param len the size of data pointed to in memory *@param len the size of data pointed to in memory
*/ */
virtual int readdata(void *data, int len) = 0; virtual int readdata(void *data, int len) = 0;
/** /**
* Is more particular the case of the sending data through a socket (internet) * Is more particular the case of the sending data through a socket (internet)
* moretoread and candsend, take a microsec timeout argument. * moretoread and candsend, take a microsec timeout argument.
* *
*/ */
virtual int netstatus() = 0; virtual int netstatus() = 0;
virtual int isactive() = 0; virtual int isactive() = 0;
virtual bool moretoread(uint32_t usec) = 0; virtual bool moretoread(uint32_t usec) = 0;
virtual bool cansend(uint32_t usec) = 0; virtual bool cansend(uint32_t usec) = 0;
/** /**
* method for streamer to shutdown bininterface * method for streamer to shutdown bininterface
**/ **/
virtual int close() = 0; virtual int close() = 0;
/** /**
* If hashing data * If hashing data
**/ **/
virtual RsFileHash gethash() = 0; virtual RsFileHash gethash() = 0;
/** /**
* Number of bytes read/sent * Number of bytes read/sent
*/ */
virtual uint64_t bytecount() { return 0; } virtual uint64_t bytecount() { return 0; }
/** /**
* used by pqistreamer to limit transfers * used by pqistreamer to limit transfers
**/ **/
virtual bool bandwidthLimited() { return true; } virtual bool bandwidthLimited() { return true; }
}; };
@ -360,26 +360,30 @@ public:
/** /**
* @param p_in used to notify system of connect/disconnect events * @param p_in used to notify system of connect/disconnect events
*/ */
NetInterface(PQInterface *p_in, const RsPeerId& id) NetInterface(PQInterface *p_in, const RsPeerId& id) : p(p_in), peerId(id) {}
:p(p_in), peerId(id) { return; }
virtual ~NetInterface() virtual ~NetInterface() {}
{ return; }
virtual int connect(const struct sockaddr_storage &raddr) = 0; /* TODO
virtual int listen() = 0; * The data entrypoint is connect(const struct sockaddr_storage &raddr)
virtual int stoplistening() = 0; * To generalize NetInterface we should have a more general type for raddr
virtual int disconnect() = 0; * As an example a string containing an url or encoded like a domain name
virtual int reset() = 0; */
virtual const RsPeerId& PeerId() { return peerId; } virtual int connect(const struct sockaddr_storage &raddr) = 0;
virtual int getConnectAddress(struct sockaddr_storage &raddr) = 0;
virtual bool connect_parameter(uint32_t type, uint32_t value) = 0; virtual int listen() = 0;
virtual bool connect_parameter(uint32_t /* type */ , const std::string & /* value */ ) { return false; } // not generally used. virtual int stoplistening() = 0;
virtual bool connect_additional_address(uint32_t /*type*/, const struct sockaddr_storage & /*addr*/) { return false; } // only needed by udp. virtual int disconnect() = 0;
virtual int reset() = 0;
virtual const RsPeerId& PeerId() { return peerId; }
virtual int getConnectAddress(struct sockaddr_storage &raddr) = 0;
virtual bool connect_parameter(uint32_t type, uint32_t value) = 0;
virtual bool connect_parameter(uint32_t /* type */ , const std::string & /* value */ ) { return false; } // not generally used.
virtual bool connect_additional_address(uint32_t /*type*/, const struct sockaddr_storage & /*addr*/) { return false; } // only needed by udp.
protected: protected:
PQInterface *parent() { return p; } PQInterface *parent() { return p; }
private: private:
PQInterface *p; PQInterface *p;
@ -397,10 +401,9 @@ private:
class NetBinInterface: public NetInterface, public BinInterface class NetBinInterface: public NetInterface, public BinInterface
{ {
public: public:
NetBinInterface(PQInterface *parent, const RsPeerId& id) NetBinInterface(PQInterface *parent, const RsPeerId& id) :
:NetInterface(parent, id) NetInterface(parent, id) {}
{ return; } virtual ~NetBinInterface() {}
virtual ~NetBinInterface() { return; }
}; };
#define CHAN_SIGN_SIZE 16 #define CHAN_SIGN_SIZE 16

View File

@ -31,21 +31,14 @@
class pqilistener class pqilistener
{ {
public: public:
pqilistener() {}
pqilistener() { return; } virtual ~pqilistener() {}
virtual ~pqilistener() { return; } virtual int tick() { return 1; }
virtual int status() { return 1; }
virtual int tick() { return 1; } virtual int setListenAddr(const sockaddr_storage & /*addr*/) { return 1; }
virtual int status() { return 1; } virtual int setuplisten() { return 1; }
virtual int setListenAddr(const struct sockaddr_storage &addr) virtual int resetlisten() { return 1; }
{
(void) addr; /* suppress unused parameter warning */
return 1;
}
virtual int setuplisten() { return 1; }
virtual int resetlisten() { return 1; }
}; };

View File

@ -1936,10 +1936,7 @@ bool pqissl::cansend(uint32_t usec)
} }
RsFileHash pqissl::gethash() RsFileHash pqissl::gethash() { return RsFileHash(); }
{
return RsFileHash() ;
}
/********** End of Implementation of BinInterface ******************/ /********** End of Implementation of BinInterface ******************/

View File

@ -170,10 +170,13 @@ int Extract_Failed_SSL_Certificate(); // try to get cert anyway.
bool CheckConnectionTimeout(); bool CheckConnectionTimeout();
//protected internal fns that are overloaded for udp case. /* Do we really need this ?
virtual int net_internal_close(int fd); * It is very specific TCP+SSL stuff and unlikely to be reused.
virtual int net_internal_SSL_set_fd(SSL *ssl, int fd); * In fact we are overloading them in pqissludp case where they do different things or nothing.
virtual int net_internal_fcntl_nonblock(int fd); */
virtual int net_internal_close(int fd);
virtual int net_internal_SSL_set_fd(SSL *ssl, int fd);
virtual int net_internal_fcntl_nonblock(int fd);
/* data */ /* data */
@ -206,11 +209,9 @@ virtual int net_internal_fcntl_nonblock(int fd);
uint32_t mConnectTimeout; uint32_t mConnectTimeout;
time_t mTimeoutTS; time_t mTimeoutTS;
private: private:
// ssl only fns. // ssl only fns.
int connectInterface(const struct sockaddr_storage &addr); int connectInterface(const struct sockaddr_storage &addr);
}; };

View File

@ -49,13 +49,12 @@ class p3PeerMgr;
class AcceptedSSL class AcceptedSSL
{ {
public: public:
int mFd; int mFd;
SSL *mSSL; SSL *mSSL;
RsPeerId mPeerId; RsPeerId mPeerId;
struct sockaddr_storage mAddr; sockaddr_storage mAddr;
time_t mAcceptTS; time_t mAcceptTS;
}; };
@ -64,11 +63,9 @@ class AcceptedSSL
class pqissllistenbase: public pqilistener class pqissllistenbase: public pqilistener
{ {
public: public:
pqissllistenbase(const struct sockaddr_storage &addr, p3PeerMgr *pm);
virtual ~pqissllistenbase();
pqissllistenbase(const struct sockaddr_storage &addr, p3PeerMgr *pm);
virtual ~pqissllistenbase();
/*************************************/ /*************************************/
/* LISTENER INTERFACE **/ /* LISTENER INTERFACE **/

View File

@ -51,22 +51,22 @@ static const uint32_t PQI_SSLUDP_DEF_CONN_PERIOD = 300; /* 5 minutes? */
/********** PQI SSL UDP STUFF **************************************/ /********** PQI SSL UDP STUFF **************************************/
pqissludp::pqissludp(PQInterface *parent, p3LinkMgr *lm) pqissludp::pqissludp(PQInterface *parent, p3LinkMgr *lm) :
:pqissl(NULL, parent, lm), tou_bio(NULL), pqissl(NULL, parent, lm), tou_bio(NULL), listen_checktime(0),
listen_checktime(0), mConnectPeriod(PQI_SSLUDP_DEF_CONN_PERIOD), mConnectFlags(0), mConnectBandwidth(0) mConnectPeriod(PQI_SSLUDP_DEF_CONN_PERIOD), mConnectFlags(0),
mConnectBandwidth(0)
{ {
RsStackMutex stack(mSslMtx); /**** LOCKED MUTEX ****/ RS_STACK_MUTEX(mSslMtx);
sockaddr_storage_clear(remote_addr); sockaddr_storage_clear(remote_addr);
sockaddr_storage_clear(mConnectProxyAddr); sockaddr_storage_clear(mConnectProxyAddr);
sockaddr_storage_clear(mConnectSrcAddr); sockaddr_storage_clear(mConnectSrcAddr);
return;
} }
pqissludp::~pqissludp() pqissludp::~pqissludp()
{ {
rslog(RSL_ALERT, pqissludpzone, rslog(RSL_ALERT, pqissludpzone,
"pqissludp::~pqissludp -> destroying pqissludp"); "pqissludp::~pqissludp -> destroying pqissludp");
/* must call reset from here, so that the /* must call reset from here, so that the
@ -76,16 +76,13 @@ pqissludp::~pqissludp()
* This means that reset() will be called twice, but this should * This means that reset() will be called twice, but this should
* be harmless. * be harmless.
*/ */
stoplistening(); /* remove from p3proxy listenqueue */ stoplistening(); /* remove from p3proxy listenqueue */
reset(); reset();
RsStackMutex stack(mSslMtx); /**** LOCKED MUTEX ****/ RS_STACK_MUTEX(mSslMtx);
if (tou_bio) // this should be in the reset? if (tou_bio) // this should be in the reset?
{
BIO_free(tou_bio); BIO_free(tou_bio);
}
return;
} }
int pqissludp::reset_locked() int pqissludp::reset_locked()
@ -153,7 +150,7 @@ int pqissludp::attach()
// The Address determination is done centrally // The Address determination is done centrally
int pqissludp::Initiate_Connection() int pqissludp::Initiate_Connection()
{ {
int err; int err;
@ -349,7 +346,7 @@ int pqissludp::Initiate_Connection()
} }
/********* VERY DIFFERENT **********/ /********* VERY DIFFERENT **********/
int pqissludp::Basic_Connection_Complete() int pqissludp::Basic_Connection_Complete()
{ {
rslog(RSL_DEBUG_BASIC, pqissludpzone, rslog(RSL_DEBUG_BASIC, pqissludpzone,
"pqissludp::Basic_Connection_Complete()..."); "pqissludp::Basic_Connection_Complete()...");
@ -449,15 +446,6 @@ int pqissludp::net_internal_fcntl_nonblock(int /*fd*/)
} }
/* These are identical to pqinetssl version */
//int pqissludp::status()
int pqissludp::tick()
{
pqissl::tick();
return 1;
}
// listen fns call the udpproxy. // listen fns call the udpproxy.
int pqissludp::listen() int pqissludp::listen()
{ {

View File

@ -45,7 +45,7 @@
class pqissludp; class pqissludp;
class cert; class cert;
/* This provides a NetBinInterface, which is /* This provides a NetBinInterface, which is
* primarily inherited from pqissl. * primarily inherited from pqissl.
* fns declared here are different -> all others are identical. * fns declared here are different -> all others are identical.
*/ */
@ -53,49 +53,48 @@ class cert;
class pqissludp: public pqissl class pqissludp: public pqissl
{ {
public: public:
pqissludp(PQInterface *parent, p3LinkMgr *lm); pqissludp(PQInterface *parent, p3LinkMgr *lm);
virtual ~pqissludp(); virtual ~pqissludp();
// NetInterface. // NetInterface.
// listen fns call the udpproxy. // listen fns call the udpproxy.
virtual int listen(); virtual int listen();
virtual int stoplistening(); virtual int stoplistening();
virtual int tick();
virtual bool connect_parameter(uint32_t type, uint32_t value); virtual bool connect_parameter(uint32_t type, uint32_t value);
virtual bool connect_additional_address(uint32_t type, const struct sockaddr_storage &addr); virtual bool connect_additional_address(uint32_t type, const struct sockaddr_storage &addr);
// BinInterface. // BinInterface.
// These are reimplemented. // These are reimplemented.
virtual bool moretoread(uint32_t usec); virtual bool moretoread(uint32_t usec);
virtual bool cansend(uint32_t usec); virtual bool cansend(uint32_t usec);
/* UDP always through firewalls -> always bandwidth Limited */ /* UDP always through firewalls -> always bandwidth Limited */
virtual bool bandwidthLimited() { return true; } virtual bool bandwidthLimited() { return true; }
protected: protected:
// pqissludp specific. // pqissludp specific.
// called to initiate a connection; // called to initiate a connection;
int attach(); int attach();
virtual int reset_locked(); virtual int reset_locked();
virtual int Initiate_Connection(); virtual int Initiate_Connection();
virtual int Basic_Connection_Complete(); virtual int Basic_Connection_Complete();
//protected internal fns that are overloaded for udp case. /* Do we really need this ?
virtual int net_internal_close(int fd); * It is very specific UDP+ToU+SSL stuff and unlikely to be reused.
virtual int net_internal_SSL_set_fd(SSL *ssl, int fd); * In fact we are overloading them here becase they are very do different of pqissl.
virtual int net_internal_fcntl_nonblock(int fd); */
virtual int net_internal_close(int fd);
virtual int net_internal_SSL_set_fd(SSL *ssl, int fd);
virtual int net_internal_fcntl_nonblock(int fd);
private: private:
BIO *tou_bio; // specific to ssludp. BIO *tou_bio; // specific to ssludp.
//int remote_timeout;
//int proxy_timeout;
long listen_checktime; long listen_checktime;
uint32_t mConnectPeriod; uint32_t mConnectPeriod;