mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
commit
488b382522
@ -1078,7 +1078,7 @@ int pqissl::SSL_Connection_Complete()
|
||||
/* if we are passive - then accept! */
|
||||
int err;
|
||||
|
||||
if (sslmode)
|
||||
if (sslmode == PQISSL_ACTIVE)
|
||||
{
|
||||
#ifdef PQISSL_LOG_DEBUG
|
||||
rslog(RSL_DEBUG_BASIC, pqisslzone, "--------> Active Connect! Client side.");
|
||||
|
@ -3,7 +3,8 @@
|
||||
* *
|
||||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright 2004-2006 by Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2004-2006 Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2015-2019 Gioacchino Mazzurco <gio@altermundi.net> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -50,39 +51,22 @@ static const uint32_t PQI_SSLUDP_DEF_CONN_PERIOD = 300; /* 5 minutes? */
|
||||
/********** PQI SSL UDP STUFF **************************************/
|
||||
|
||||
pqissludp::pqissludp(PQInterface *parent, p3LinkMgr *lm) :
|
||||
pqissl(NULL, parent, lm), tou_bio(NULL),// listen_checktime(0),
|
||||
mConnectPeriod(PQI_SSLUDP_DEF_CONN_PERIOD), mConnectFlags(0),
|
||||
mConnectBandwidth(0)
|
||||
{
|
||||
RS_STACK_MUTEX(mSslMtx);
|
||||
pqissl(nullptr, parent, lm), tou_bio(nullptr),
|
||||
mConnectPeriod(PQI_SSLUDP_DEF_CONN_PERIOD), mConnectFlags(0),
|
||||
mConnectBandwidth(0), mConnectProxyAddr(), mConnectSrcAddr() {}
|
||||
|
||||
sockaddr_storage_clear(remote_addr);
|
||||
sockaddr_storage_clear(mConnectProxyAddr);
|
||||
sockaddr_storage_clear(mConnectSrcAddr);
|
||||
}
|
||||
/*
|
||||
* No need to call reset() here as it will be called in the upper class,
|
||||
* pqissludp::reset_locked() just reset a few members to 0 that (that will be
|
||||
* deleted anyway when this destructor ends), so pqissl::reset_locked() that is
|
||||
* called by in parent class destructor will do just fine.
|
||||
*
|
||||
* DISCLAIMER: do not double free tou_bio here, as it is implicitely freed
|
||||
* by SSL_free(...) in pqissl::reset()
|
||||
*/
|
||||
pqissludp::~pqissludp() = default;
|
||||
|
||||
|
||||
pqissludp::~pqissludp()
|
||||
{
|
||||
rslog(RSL_ALERT, pqissludpzone,
|
||||
"pqissludp::~pqissludp -> destroying pqissludp");
|
||||
|
||||
/* must call reset from here, so that the
|
||||
* virtual functions will still work.
|
||||
* -> as they stop working in base class destructor.
|
||||
*
|
||||
* This means that reset() will be called twice, but this should
|
||||
* be harmless.
|
||||
*/
|
||||
stoplistening(); /* remove from p3proxy listenqueue */
|
||||
reset();
|
||||
|
||||
RS_STACK_MUTEX(mSslMtx);
|
||||
|
||||
if (tou_bio) // this should be in the reset?
|
||||
BIO_free(tou_bio);
|
||||
}
|
||||
|
||||
int pqissludp::reset_locked()
|
||||
{
|
||||
/* reset for next time.*/
|
||||
@ -203,7 +187,7 @@ int pqissludp::Initiate_Connection()
|
||||
out += sockaddr_storage_tostring(remote_addr);
|
||||
out += " ";
|
||||
|
||||
if (sslmode)
|
||||
if (sslmode == PQISSL_ACTIVE)
|
||||
{
|
||||
out += "ACTIVE Connect (SSL_Connect)";
|
||||
}
|
||||
@ -430,30 +414,6 @@ int pqissludp::net_internal_SSL_set_fd(SSL *ssl, int fd)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int pqissludp::net_internal_fcntl_nonblock(int /*fd*/)
|
||||
{
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone,
|
||||
"pqissludp::net_internal_fcntl_nonblock()");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// listen fns call the udpproxy.
|
||||
int pqissludp::listen()
|
||||
{
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone, "pqissludp::listen() (NULLOP)");
|
||||
|
||||
return 1; //udpproxy->listen();
|
||||
}
|
||||
|
||||
int pqissludp::stoplistening()
|
||||
{
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone, "pqissludp::stoplistening() (NULLOP)");
|
||||
|
||||
return 1; //udpproxy->stoplistening();
|
||||
}
|
||||
|
||||
|
||||
bool pqissludp::connect_parameter(uint32_t type, uint32_t value)
|
||||
{
|
||||
{
|
||||
|
@ -3,7 +3,8 @@
|
||||
* *
|
||||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright 2004-2006 by Robert Fernie. *
|
||||
* Copyright (C) 2004-2006 Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2015-2019 Gioacchino Mazzurco <gio@altermundi.net> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -19,42 +20,31 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
#ifndef MRK_PQI_SSL_UDP_HEADER
|
||||
#define MRK_PQI_SSL_UDP_HEADER
|
||||
|
||||
// operating system specific network header.
|
||||
#include "pqi/pqinetwork.h"
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#include "pqi/pqissl.h"
|
||||
#include "pqi/pqinetwork.h"
|
||||
#include "util/rsdebug.h"
|
||||
|
||||
/* So pqissludp is the special firewall breaking protocol.
|
||||
* This class will implement the basics of streaming
|
||||
* ssl over udp using a tcponudp library....
|
||||
* and a small extension to ssl.
|
||||
*/
|
||||
|
||||
class pqissludp;
|
||||
class cert;
|
||||
|
||||
/* This provides a NetBinInterface, which is
|
||||
* primarily inherited from pqissl.
|
||||
* fns declared here are different -> all others are identical.
|
||||
/**
|
||||
* @brief pqissludp is the special NAT traversal protocol.
|
||||
* This class will implement the basics of streaming ssl over udp using a
|
||||
* tcponudp library.
|
||||
* It provides a NetBinInterface, which is primarily inherited from pqissl.
|
||||
* Some methods are override all others are identical.
|
||||
*/
|
||||
|
||||
class pqissludp: public pqissl
|
||||
{
|
||||
public:
|
||||
pqissludp(PQInterface *parent, p3LinkMgr *lm);
|
||||
~pqissludp() override;
|
||||
|
||||
virtual ~pqissludp();
|
||||
|
||||
// NetInterface.
|
||||
// listen fns call the udpproxy.
|
||||
virtual int listen();
|
||||
virtual int stoplistening();
|
||||
int listen() override { return 1; }
|
||||
int stoplistening() override { return 1; }
|
||||
|
||||
virtual bool connect_parameter(uint32_t type, uint32_t value);
|
||||
virtual bool connect_additional_address(uint32_t type, const struct sockaddr_storage &addr);
|
||||
@ -83,20 +73,18 @@ protected:
|
||||
*/
|
||||
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);
|
||||
virtual int net_internal_fcntl_nonblock(int /*fd*/) { return 0; }
|
||||
|
||||
private:
|
||||
|
||||
BIO *tou_bio; // specific to ssludp.
|
||||
|
||||
//long listen_checktime;
|
||||
|
||||
uint32_t mConnectPeriod;
|
||||
uint32_t mConnectFlags;
|
||||
uint32_t mConnectBandwidth;
|
||||
|
||||
struct sockaddr_storage mConnectProxyAddr;
|
||||
struct sockaddr_storage mConnectSrcAddr;
|
||||
};
|
||||
|
||||
#endif // MRK_PQI_SSL_UDP_HEADER
|
||||
RS_SET_CONTEXT_DEBUG_LEVEL(2)
|
||||
};
|
||||
|
@ -56,7 +56,10 @@ void RsGxsForumModel::preMods()
|
||||
}
|
||||
void RsGxsForumModel::postMods()
|
||||
{
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(0,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
|
||||
if(mTreeMode == TREE_MODE_FLAT)
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mPosts.size(),COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
|
||||
else
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mPosts[0].mChildren.size(),COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
|
||||
}
|
||||
|
||||
void RsGxsForumModel::setTreeMode(TreeMode mode)
|
||||
@ -65,7 +68,21 @@ void RsGxsForumModel::setTreeMode(TreeMode mode)
|
||||
return;
|
||||
|
||||
preMods();
|
||||
|
||||
if(mode == TREE_MODE_TREE) // means we were in FLAT mode, so the last rows are removed.
|
||||
{
|
||||
beginRemoveRows(QModelIndex(),mPosts[0].mChildren.size(),mPosts.size()-1);
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
mTreeMode = mode;
|
||||
|
||||
if(mode == TREE_MODE_FLAT) // means we were in tree mode, so the last rows are added.
|
||||
{
|
||||
beginInsertRows(QModelIndex(),mPosts[0].mChildren.size(),mPosts.size()-1);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
postMods();
|
||||
}
|
||||
|
||||
@ -264,12 +281,22 @@ void *RsGxsForumModel::getParentRef(void *ref,int& row) const
|
||||
{
|
||||
ForumModelIndex ref_entry;
|
||||
|
||||
if(mTreeMode == TREE_MODE_FLAT)
|
||||
return NULL;
|
||||
|
||||
if(!convertRefPointerToTabEntry(ref,ref_entry) || ref_entry >= mPosts.size())
|
||||
return NULL ;
|
||||
|
||||
if(mTreeMode == TREE_MODE_FLAT)
|
||||
{
|
||||
if(ref_entry == 0)
|
||||
{
|
||||
RsErr() << "getParentRef() shouldn't be asked for the parent of NULL" << std::endl;
|
||||
row = 0;
|
||||
}
|
||||
else
|
||||
row = ref_entry-1;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ForumModelIndex parent_entry = mPosts[ref_entry].mParent;
|
||||
|
||||
if(parent_entry == 0) // top level index
|
||||
@ -296,11 +323,21 @@ int RsGxsForumModel::getChildrenCount(void *ref) const
|
||||
|
||||
if(mTreeMode == TREE_MODE_FLAT)
|
||||
if(entry == 0)
|
||||
{
|
||||
#ifdef DEBUG_FORUMMODEL
|
||||
std::cerr << "Children count (flat mode): " << mPosts.size()-1 << std::endl;
|
||||
#endif
|
||||
return ((int)mPosts.size())-1;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG_FORUMMODEL
|
||||
std::cerr << "Children count (tree mode): " << mPosts[entry].mChildren.size() << std::endl;
|
||||
#endif
|
||||
return mPosts[entry].mChildren.size();
|
||||
}
|
||||
}
|
||||
|
||||
QVariant RsGxsForumModel::headerData(int section, Qt::Orientation /*orientation*/, int role) const
|
||||
@ -699,7 +736,11 @@ void RsGxsForumModel::setPosts(const RsGxsForumGroup& group, const std::vector<F
|
||||
{
|
||||
preMods();
|
||||
|
||||
beginRemoveRows(QModelIndex(),0,mPosts[0].mChildren.size()-1);
|
||||
if(mTreeMode == TREE_MODE_FLAT)
|
||||
beginRemoveRows(QModelIndex(),0,mPosts.size()-1);
|
||||
else
|
||||
beginRemoveRows(QModelIndex(),0,mPosts[0].mChildren.size()-1);
|
||||
|
||||
endRemoveRows();
|
||||
|
||||
mForumGroup = group;
|
||||
@ -723,7 +764,10 @@ void RsGxsForumModel::setPosts(const RsGxsForumGroup& group, const std::vector<F
|
||||
debug_dump();
|
||||
#endif
|
||||
|
||||
beginInsertRows(QModelIndex(),0,mPosts[0].mChildren.size()-1);
|
||||
if(mTreeMode == TREE_MODE_FLAT)
|
||||
beginInsertRows(QModelIndex(),0,mPosts.size()-1);
|
||||
else
|
||||
beginInsertRows(QModelIndex(),0,mPosts[0].mChildren.size()-1);
|
||||
endInsertRows();
|
||||
postMods();
|
||||
emit forumLoaded();
|
||||
@ -1247,18 +1291,24 @@ QModelIndex RsGxsForumModel::getIndexOfMessage(const RsGxsMessageId& mid) const
|
||||
|
||||
// First look into msg versions, in case the msg is a version of an existing message
|
||||
|
||||
for(auto it(mPostVersions.begin());it!=mPostVersions.end();++it)
|
||||
for(auto it(mPostVersions.begin());it!=mPostVersions.end() && postId==mid;++it)
|
||||
for(uint32_t i=0;i<it->second.size();++i)
|
||||
if(it->second[i].second == mid)
|
||||
{
|
||||
postId = it->first;
|
||||
break;
|
||||
}
|
||||
|
||||
for(uint32_t i=0;i<mPosts.size();++i)
|
||||
for(uint32_t i=1;i<mPosts.size();++i)
|
||||
if(mPosts[i].mMsgId == postId)
|
||||
{
|
||||
void *ref ;
|
||||
convertTabEntryToRefPointer(i,ref);
|
||||
convertTabEntryToRefPointer(i,ref); // we dont use i+1 here because i is not a row, but an index in the mPosts tab
|
||||
|
||||
return createIndex(mPosts[i].prow,0,ref);
|
||||
if(mTreeMode == TREE_MODE_FLAT)
|
||||
return createIndex(i-1,0,ref);
|
||||
else
|
||||
return createIndex(mPosts[i].prow,0,ref);
|
||||
}
|
||||
|
||||
return QModelIndex();
|
||||
|
@ -84,20 +84,6 @@
|
||||
|
||||
// We need consts for that!! Defined in multiple places.
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
#define ROLE_THREAD_MSGID Qt::UserRole
|
||||
#define ROLE_THREAD_STATUS Qt::UserRole + 1
|
||||
#define ROLE_THREAD_MISSING Qt::UserRole + 2
|
||||
#define ROLE_THREAD_AUTHOR Qt::UserRole + 3
|
||||
// no need to copy, don't count in ROLE_THREAD_COUNT
|
||||
#define ROLE_THREAD_READCHILDREN Qt::UserRole + 4
|
||||
#define ROLE_THREAD_UNREADCHILDREN Qt::UserRole + 5
|
||||
#define ROLE_THREAD_SORT Qt::UserRole + 6
|
||||
#define ROLE_THREAD_PINNED Qt::UserRole + 7
|
||||
|
||||
#define ROLE_THREAD_COUNT 4
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_FORUMS
|
||||
static std::ostream& operator<<(std::ostream& o,const QModelIndex& q)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user