changed names SocketBioInterface->RsFdBinInterface and TcpSocket->RsTcpSocket (more consistent). Moved them to pqi/

This commit is contained in:
csoler 2021-11-16 22:19:27 +01:00
parent a5b1f2d976
commit 0a5f3328df
8 changed files with 47 additions and 47 deletions

View File

@ -24,7 +24,7 @@
#include "retroshare/rspeers.h" #include "retroshare/rspeers.h"
#include "fsclient.h" #include "fsclient.h"
#include "fsbio.h" #include "pqi/pqifdbin.h"
bool FsClient::requestFriends(const std::string& address,uint16_t port,uint32_t reqs,std::map<std::string,bool>& friend_certificates) bool FsClient::requestFriends(const std::string& address,uint16_t port,uint32_t reqs,std::map<std::string,bool>& friend_certificates)
{ {
@ -130,7 +130,7 @@ bool FsClient::sendItem(const std::string& address,uint16_t port,RsItem *item,st
// FsSerializer().serialise(item,data,&size); // FsSerializer().serialise(item,data,&size);
// write(CreateSocket,data,size); // shouldn't we use the pqistreamer in R/W mode instead? // write(CreateSocket,data,size); // shouldn't we use the pqistreamer in R/W mode instead?
FsBioInterface *bio = new FsBioInterface(CreateSocket); // deleted by ~pqistreamer() RsFdBinInterface *bio = new RsFdBinInterface(CreateSocket); // deleted by ~pqistreamer()
pqithreadstreamer p(this,rss,RsPeerId(),bio,BIN_FLAGS_READABLE | BIN_FLAGS_WRITEABLE | BIN_FLAGS_NO_CLOSE); pqithreadstreamer p(this,rss,RsPeerId(),bio,BIN_FLAGS_READABLE | BIN_FLAGS_WRITEABLE | BIN_FLAGS_NO_CLOSE);
p.start(); p.start();

View File

@ -156,7 +156,6 @@ rs_webui {
} }
HEADERS += plugins/pluginmanager.h \ HEADERS += plugins/pluginmanager.h \
friend_server/socketbio.h \
plugins/dlfcn_win32.h \ plugins/dlfcn_win32.h \
rsitems/rspluginitems.h \ rsitems/rspluginitems.h \
util/i2pcommon.h \ util/i2pcommon.h \
@ -366,6 +365,8 @@ HEADERS += pqi/authssl.h \
pqi/authgpg.h \ pqi/authgpg.h \
pgp/pgphandler.h \ pgp/pgphandler.h \
pgp/pgpkeyutil.h \ pgp/pgpkeyutil.h \
pqi/pqifdbin.h \
pqi/rstcpsocket.h \
pgp/rscertificate.h \ pgp/rscertificate.h \
pgp/pgpauxutils.h \ pgp/pgpauxutils.h \
pqi/p3cfgmgr.h \ pqi/p3cfgmgr.h \
@ -406,9 +407,7 @@ HEADERS += pqi/authssl.h \
SOURCES += friend_server/fsclient.h \ SOURCES += friend_server/fsclient.h \
friend_server/fsitem.h \ friend_server/fsitem.h \
friend_server/fsmanager.h \ friend_server/fsmanager.h
friend_server/socketbio.cc \
friend_server/tcpsocket.h
HEADERS += rsserver/p3face.h \ HEADERS += rsserver/p3face.h \
rsserver/p3history.h \ rsserver/p3history.h \
@ -548,6 +547,8 @@ SOURCES += pqi/authgpg.cc \
pqi/p3cfgmgr.cc \ pqi/p3cfgmgr.cc \
pqi/p3peermgr.cc \ pqi/p3peermgr.cc \
pqi/p3linkmgr.cc \ pqi/p3linkmgr.cc \
pqi/pqifdbin.cc \
pqi/rstcpsocket.cc \
pqi/p3netmgr.cc \ pqi/p3netmgr.cc \
pqi/p3notify.cc \ pqi/p3notify.cc \
pqi/pqiqos.cc \ pqi/pqiqos.cc \
@ -574,8 +575,7 @@ SOURCES += pqi/authgpg.cc \
pqi/p3servicecontrol.cc pqi/p3servicecontrol.cc
SOURCES += friend_server/fsclient.cc \ SOURCES += friend_server/fsclient.cc \
friend_server/fsmanager.cc \ friend_server/fsmanager.cc
friend_server/tcpsocket.cc
SOURCES += rsserver/p3face-config.cc \ SOURCES += rsserver/p3face-config.cc \
rsserver/p3face-server.cc \ rsserver/p3face-server.cc \

View File

@ -21,10 +21,10 @@
******************************************************************************/ ******************************************************************************/
#include "util/rsprint.h" #include "util/rsprint.h"
#include "fsbio.h" #include "pqi/pqifdbin.h"
FsBioInterface::FsBioInterface(int socket) RsFdBinInterface::RsFdBinInterface(int file_descriptor)
: mCLintConnt(socket),mIsActive(socket!=0) : mCLintConnt(file_descriptor),mIsActive(file_descriptor!=0)
{ {
mTotalReadBytes=0; mTotalReadBytes=0;
mTotalInBufferBytes=0; mTotalInBufferBytes=0;
@ -32,7 +32,7 @@ FsBioInterface::FsBioInterface(int socket)
mTotalOutBufferBytes=0; mTotalOutBufferBytes=0;
} }
void FsBioInterface::setSocket(int s) void RsFdBinInterface::setSocket(int s)
{ {
if(mIsActive != 0) if(mIsActive != 0)
{ {
@ -42,7 +42,7 @@ void FsBioInterface::setSocket(int s)
mCLintConnt = s; mCLintConnt = s;
mIsActive = (s!=0); mIsActive = (s!=0);
} }
int FsBioInterface::tick() int RsFdBinInterface::tick()
{ {
if(!mIsActive) if(!mIsActive)
{ {
@ -59,7 +59,7 @@ int FsBioInterface::tick()
return res; return res;
} }
int FsBioInterface::read_pending() int RsFdBinInterface::read_pending()
{ {
char inBuffer[1025]; char inBuffer[1025];
memset(inBuffer,0,1025); memset(inBuffer,0,1025);
@ -107,7 +107,7 @@ int FsBioInterface::read_pending()
return mTotalInBufferBytes; return mTotalInBufferBytes;
} }
int FsBioInterface::write_pending() int RsFdBinInterface::write_pending()
{ {
if(out_buffer.empty()) if(out_buffer.empty())
return mTotalOutBufferBytes; return mTotalOutBufferBytes;
@ -160,12 +160,12 @@ int FsBioInterface::write_pending()
return mTotalOutBufferBytes; return mTotalOutBufferBytes;
} }
FsBioInterface::~FsBioInterface() RsFdBinInterface::~RsFdBinInterface()
{ {
clean(); clean();
} }
void FsBioInterface::clean() void RsFdBinInterface::clean()
{ {
for(auto p:in_buffer) free(p.first); for(auto p:in_buffer) free(p.first);
for(auto p:out_buffer) free(p.first); for(auto p:out_buffer) free(p.first);
@ -173,7 +173,7 @@ void FsBioInterface::clean()
in_buffer.clear(); in_buffer.clear();
out_buffer.clear(); out_buffer.clear();
} }
int FsBioInterface::readdata(void *data, int len) int RsFdBinInterface::readdata(void *data, int len)
{ {
// read incoming bytes in the buffer // read incoming bytes in the buffer
@ -217,7 +217,7 @@ int FsBioInterface::readdata(void *data, int len)
return len; return len;
} }
int FsBioInterface::senddata(void *data, int len) int RsFdBinInterface::senddata(void *data, int len)
{ {
// shouldn't we better send in multiple packets, similarly to how we read? // shouldn't we better send in multiple packets, similarly to how we read?
@ -240,26 +240,26 @@ int FsBioInterface::senddata(void *data, int len)
mTotalOutBufferBytes += len; mTotalOutBufferBytes += len;
return len; return len;
} }
int FsBioInterface::netstatus() int RsFdBinInterface::netstatus()
{ {
return mIsActive; // dummy response. return mIsActive; // dummy response.
} }
int FsBioInterface::isactive() int RsFdBinInterface::isactive()
{ {
return mIsActive ; return mIsActive ;
} }
bool FsBioInterface::moretoread(uint32_t /* usec */) bool RsFdBinInterface::moretoread(uint32_t /* usec */)
{ {
return mTotalInBufferBytes > 0; return mTotalInBufferBytes > 0;
} }
bool FsBioInterface::cansend(uint32_t) bool RsFdBinInterface::cansend(uint32_t)
{ {
return isactive(); return isactive();
} }
int FsBioInterface::close() int RsFdBinInterface::close()
{ {
RsDbg() << "Stopping network interface" << std::endl; RsDbg() << "Stopping network interface" << std::endl;
mIsActive = false; mIsActive = false;

View File

@ -22,11 +22,11 @@
#include "pqi/pqi_base.h" #include "pqi/pqi_base.h"
class FsBioInterface: public BinInterface class RsFdBinInterface: public BinInterface
{ {
public: public:
FsBioInterface(int socket); RsFdBinInterface(int file_descriptor);
~FsBioInterface(); ~RsFdBinInterface();
// Implements BinInterface methods // Implements BinInterface methods

View File

@ -4,13 +4,13 @@
#include <string.h> #include <string.h>
#include <iostream> #include <iostream>
#include "tcpsocket.h" #include "rstcpsocket.h"
TcpSocket::TcpSocket(const std::string& tcp_address,uint16_t tcp_port) RsTcpSocket::RsTcpSocket(const std::string& tcp_address,uint16_t tcp_port)
:FsBioInterface(0),mState(DISCONNECTED),mConnectAddress(tcp_address),mConnectPort(tcp_port),mSocket(0) :RsFdBinInterface(0),mState(DISCONNECTED),mConnectAddress(tcp_address),mConnectPort(tcp_port),mSocket(0)
{ {
} }
int TcpSocket::connect() int RsTcpSocket::connect()
{ {
int CreateSocket = 0; int CreateSocket = 0;
char dataReceived[1024]; char dataReceived[1024];
@ -39,19 +39,19 @@ int TcpSocket::connect()
return true; return true;
} }
int TcpSocket::close() int RsTcpSocket::close()
{ {
FsBioInterface::close(); RsFdBinInterface::close();
return !::close(mSocket); return !::close(mSocket);
} }
ThreadedTcpSocket::ThreadedTcpSocket(const std::string& tcp_address,uint16_t tcp_port) RsThreadedTcpSocket::RsThreadedTcpSocket(const std::string& tcp_address,uint16_t tcp_port)
: TcpSocket(tcp_address,tcp_port) : RsTcpSocket(tcp_address,tcp_port)
{ {
} }
void ThreadedTcpSocket::run() void RsThreadedTcpSocket::run()
{ {
if(!connect()) if(!connect())
{ {
@ -67,7 +67,7 @@ void ThreadedTcpSocket::run()
RsWarn() << "Connection to " << connectAddress() << ":" << connectPort() << " is now closed."; RsWarn() << "Connection to " << connectAddress() << ":" << connectPort() << " is now closed.";
} }
ThreadedTcpSocket::~ThreadedTcpSocket() RsThreadedTcpSocket::~RsThreadedTcpSocket()
{ {
fullstop(); // fully wait for stopping. fullstop(); // fully wait for stopping.

View File

@ -1,11 +1,11 @@
#include <string> #include <string>
#include "util/rsthreads.h" #include "util/rsthreads.h"
#include "friend_server/fsbio.h" #include "pqi/pqifdbin.h"
class TcpSocket: public FsBioInterface class RsTcpSocket: public RsFdBinInterface
{ {
public: public:
TcpSocket(const std::string& tcp_address,uint16_t tcp_port); RsTcpSocket(const std::string& tcp_address,uint16_t tcp_port);
enum State: uint8_t { enum State: uint8_t {
UNKNOWN = 0x00, UNKNOWN = 0x00,
@ -30,11 +30,11 @@ private:
int mSocket; int mSocket;
}; };
class ThreadedTcpSocket: public TcpSocket, public RsThread class RsThreadedTcpSocket: public RsTcpSocket, public RsThread
{ {
public: public:
ThreadedTcpSocket(const std::string& tcp_address,uint16_t tcp_port); RsThreadedTcpSocket(const std::string& tcp_address,uint16_t tcp_port);
virtual ~ThreadedTcpSocket(); virtual ~RsThreadedTcpSocket();
virtual void run() override; virtual void run() override;
}; };

View File

@ -35,7 +35,7 @@
#include "util/rsdebug.h" #include "util/rsdebug.h"
#include "pqi/pqithreadstreamer.h" #include "pqi/pqithreadstreamer.h"
#include "friend_server/fsbio.h" #include "pqi/pqifdbin.h"
#include "network.h" #include "network.h"
#include "friend_server/fsitem.h" #include "friend_server/fsitem.h"
@ -154,7 +154,7 @@ bool FsNetworkInterface::checkForNewConnections()
RsSerialiser *rss = new RsSerialiser ; RsSerialiser *rss = new RsSerialiser ;
rss->addSerialType(new FsSerializer) ; rss->addSerialType(new FsSerializer) ;
FsBioInterface *bio = new FsBioInterface(clintConnt); RsFdBinInterface *bio = new RsFdBinInterface(clintConnt);
auto pqi = new pqithreadstreamer(this,rss, pid, bio,BIN_FLAGS_READABLE | BIN_FLAGS_WRITEABLE); auto pqi = new pqithreadstreamer(this,rss, pid, bio,BIN_FLAGS_READABLE | BIN_FLAGS_WRITEABLE);

View File

@ -26,14 +26,14 @@
#include "retroshare/rspeers.h" #include "retroshare/rspeers.h"
class pqithreadstreamer; class pqithreadstreamer;
class FsBioInterface; class RsFdBinInterface;
struct ConnectionData struct ConnectionData
{ {
sockaddr client_address; sockaddr client_address;
int socket; int socket;
pqithreadstreamer *pqi_thread; pqithreadstreamer *pqi_thread;
FsBioInterface *bio; RsFdBinInterface *bio;
std::list<RsItem*> incoming_items; std::list<RsItem*> incoming_items;
}; };