mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-30 09:56:14 -05:00
Added missing functions to get retroshare running again.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-netupgrade@4420 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
bbd11e69c1
commit
59abce2d48
@ -1,7 +1,30 @@
|
||||
/* a connect state box */
|
||||
/*
|
||||
* libretroshare/src/dht: connectstatebox.cc
|
||||
*
|
||||
* RetroShare DHT C++ Interface.
|
||||
*
|
||||
* Copyright 2011-2011 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".
|
||||
*
|
||||
*/
|
||||
|
||||
#include "connectstatebox.h"
|
||||
#include "netstatebox.h"
|
||||
#include "dht/connectstatebox.h"
|
||||
#include "retroshare/rsnetwork.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
@ -176,14 +199,14 @@ uint32_t convertNetStateToInternal(uint32_t netmode, uint32_t nattype)
|
||||
{
|
||||
uint32_t connNet = CSB_NETSTATE_UNKNOWN;
|
||||
|
||||
if (netmode == PNSB_NETWORK_EXTERNALIP)
|
||||
if (netmode == RSNET_NETWORK_EXTERNALIP)
|
||||
{
|
||||
connNet = CSB_NETSTATE_FORWARD;
|
||||
}
|
||||
else if (netmode == PNSB_NETWORK_BEHINDNAT)
|
||||
else if (netmode == RSNET_NETWORK_BEHINDNAT)
|
||||
{
|
||||
if ((nattype == PNSB_NATTYPE_RESTRICTED_CONE) ||
|
||||
(nattype == PNSB_NATTYPE_FULL_CONE))
|
||||
if ((nattype == RSNET_NATTYPE_RESTRICTED_CONE) ||
|
||||
(nattype == RSNET_NATTYPE_FULL_CONE))
|
||||
{
|
||||
connNet = CSB_NETSTATE_STABLENAT;
|
||||
}
|
||||
@ -770,7 +793,7 @@ bool PeerConnectStateBox::getProxyPortChoice()
|
||||
std::cerr << " UseProxyPort? " << mProxyPortChoice;
|
||||
std::cerr << std::endl;
|
||||
|
||||
return useProxyPort;
|
||||
return mProxyPortChoice;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,31 @@
|
||||
#ifndef CONNECT_STATUS_BOX_H
|
||||
#define CONNECT_STATUS_BOX_H
|
||||
|
||||
/*
|
||||
* libretroshare/src/dht: connectstatebox.h
|
||||
*
|
||||
* RetroShare DHT C++ Interface.
|
||||
*
|
||||
* Copyright 2011-2011 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".
|
||||
*
|
||||
*/
|
||||
|
||||
/* a connect state box */
|
||||
|
||||
#define CSB_START 1
|
||||
|
@ -64,11 +64,15 @@ debug {
|
||||
|
||||
bitdht {
|
||||
|
||||
HEADERS += dht/p3bitdht.h
|
||||
HEADERS += dht/p3bitdht.h \
|
||||
dht/connectstatebox.h \
|
||||
dht/stunaddrassist.h
|
||||
|
||||
SOURCES += dht/p3bitdht.cc \
|
||||
dht/p3bitdht_interface.cc \
|
||||
dht/p3bitdht_peers.cc \
|
||||
dht/p3bitdht_peernet.cc
|
||||
dht/p3bitdht_peernet.cc \
|
||||
dht/connectstatebox.cc
|
||||
|
||||
HEADERS += tcponudp/udppeer.h \
|
||||
tcponudp/bio_tou.h \
|
||||
@ -142,7 +146,8 @@ PUBLIC_HEADERS = retroshare/rsblogs.h \
|
||||
retroshare/rsstatus.h \
|
||||
retroshare/rsturtle.h \
|
||||
retroshare/rstypes.h \
|
||||
retroshare/rsdht.h
|
||||
retroshare/rsdht.h \
|
||||
retroshare/rsnetwork.h
|
||||
|
||||
HEADERS += plugins/pluginmanager.h \
|
||||
plugins/dlfcn_win32.h \
|
||||
|
@ -170,6 +170,36 @@ bool p3LinkMgr::getTunnelConnection()
|
||||
return mAllowTunnelConnection;
|
||||
}
|
||||
|
||||
bool p3LinkMgr::setLocalAddress(struct sockaddr_in addr)
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
mLocalAddress = addr;
|
||||
}
|
||||
|
||||
struct sockaddr_in p3LinkMgr::getLocalAddress()
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
return mLocalAddress;
|
||||
}
|
||||
|
||||
|
||||
bool p3LinkMgr::isOnline(const std::string &ssl_id)
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
it = mFriendList.find(ssl_id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (it->second.state & RS_PEER_S_CONNECTED)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void p3LinkMgr::getOnlineList(std::list<std::string> &ssl_peers)
|
||||
{
|
||||
@ -228,6 +258,22 @@ int p3LinkMgr::getOnlineCount()
|
||||
|
||||
}
|
||||
|
||||
bool p3LinkMgr::getFriendNetStatus(const std::string &id, peerConnectState &state)
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
it = mFriendList.find(id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
state = it->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void p3LinkMgr::setFriendVisibility(const std::string &id, bool isVisible)
|
||||
{
|
||||
@ -269,7 +315,6 @@ void p3LinkMgr::setFriendVisibility(const std::string &id, bool isVisible)
|
||||
|
||||
void p3LinkMgr::tick()
|
||||
{
|
||||
netTick();
|
||||
statusTick();
|
||||
tickMonitors();
|
||||
}
|
||||
@ -737,9 +782,9 @@ bool p3LinkMgr::connectResult(const std::string &id, bool success, uint32_t flag
|
||||
}
|
||||
|
||||
if(should_netAssistFriend_true)
|
||||
netAssistFriend(id,true) ;
|
||||
mNetMgr->netAssistFriend(id,true) ;
|
||||
if(should_netAssistFriend_false)
|
||||
netAssistFriend(id,false) ;
|
||||
mNetMgr->netAssistFriend(id,false) ;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -191,11 +191,12 @@ int removeFriend(const std::string &ssl_id);
|
||||
const std::string getOwnId();
|
||||
bool getOwnNetStatus(peerConnectState &state);
|
||||
|
||||
bool setLocalAddress(struct sockaddr_in addr);
|
||||
struct sockaddr_in getLocalAddress();
|
||||
|
||||
bool isOnline(const std::string &ssl_id);
|
||||
bool getFriendNetStatus(const std::string &id, peerConnectState &state);
|
||||
bool getOthersNetStatus(const std::string &id, peerConnectState &state);
|
||||
//bool getOthersNetStatus(const std::string &id, peerConnectState &state);
|
||||
|
||||
void getOnlineList(std::list<std::string> &ssl_peers);
|
||||
void getFriendList(std::list<std::string> &ssl_peers);
|
||||
@ -222,25 +223,21 @@ bool connectResult(const std::string &id, bool success, uint32_t flags, struct
|
||||
protected:
|
||||
/****************** Internal Interface *******************/
|
||||
|
||||
virtual bool enableNetAssistConnect(bool on);
|
||||
virtual bool netAssistConnectEnabled();
|
||||
virtual bool netAssistConnectActive();
|
||||
virtual bool netAssistConnectShutdown();
|
||||
virtual bool netAssistConnectStats(uint32_t &netsize, uint32_t &localnetsize);
|
||||
//virtual bool enableNetAssistConnect(bool on);
|
||||
//virtual bool netAssistConnectEnabled();
|
||||
//virtual bool netAssistConnectActive();
|
||||
//virtual bool netAssistConnectShutdown();
|
||||
//virtual bool netAssistConnectStats(uint32_t &netsize, uint32_t &localnetsize);
|
||||
|
||||
/* Assist Connect */
|
||||
virtual bool netAssistFriend(std::string id, bool on);
|
||||
virtual bool netAssistSetAddress( struct sockaddr_in &laddr,
|
||||
struct sockaddr_in &eaddr,
|
||||
uint32_t mode);
|
||||
//virtual bool netAssistFriend(std::string id, bool on);
|
||||
//virtual bool netAssistSetAddress( struct sockaddr_in &laddr,
|
||||
// struct sockaddr_in &eaddr,
|
||||
// uint32_t mode);
|
||||
|
||||
|
||||
/* Internal Functions */
|
||||
void netReset();
|
||||
|
||||
void statusTick();
|
||||
void netTick();
|
||||
void netStartup();
|
||||
|
||||
/* monitor control */
|
||||
void tickMonitors();
|
||||
@ -268,8 +265,6 @@ private:
|
||||
//p3tunnel *mP3tunnel;
|
||||
DNSResolver *mDNSResolver ;
|
||||
|
||||
std::map<uint32_t, pqiNetAssistConnect *> mDhts;
|
||||
|
||||
p3PeerMgr *mPeerMgr;
|
||||
p3NetMgr *mNetMgr;
|
||||
|
||||
|
@ -153,6 +153,33 @@ void p3NetMgr::setAddrAssist(pqiAddrAssist *dhtStun, pqiAddrAssist *proxyStun)
|
||||
}
|
||||
|
||||
|
||||
uint32_t p3NetMgr::getNetStateMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t p3NetMgr::getNetworkMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t p3NetMgr::getNatTypeMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t p3NetMgr::getNatHoleMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t p3NetMgr::getConnectModes()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***** Framework / initial implementation for a connection manager.
|
||||
*
|
||||
* This needs a state machine for Initialisation.
|
||||
@ -405,7 +432,6 @@ void p3NetMgr::netTick()
|
||||
// periodically check for a local net address.
|
||||
//
|
||||
checkNetAddress() ;
|
||||
networkConsistencyCheck(); /* check consistency. If not consistent, do a reset inside networkConsistencyCheck() */
|
||||
|
||||
uint32_t netStatus = 0;
|
||||
time_t age = 0;
|
||||
|
@ -201,9 +201,6 @@ void netUpnpCheck();
|
||||
|
||||
void netUnreachableCheck();
|
||||
|
||||
void networkConsistencyCheck();
|
||||
|
||||
|
||||
private:
|
||||
// These should have there own Mutex Protection,
|
||||
ExtAddrFinder *mExtAddrFinder ;
|
||||
|
@ -180,8 +180,6 @@ void p3PeerMgr::setOwnVisState(uint32_t visState)
|
||||
|
||||
void p3PeerMgr::tick()
|
||||
{
|
||||
statusTick();
|
||||
tickMonitors();
|
||||
|
||||
static time_t last_friends_check = time(NULL) ;
|
||||
static const time_t INTERVAL_BETWEEN_LOCATION_CLEANING = 600 ; // Remove unused locations every 10 minutes.
|
||||
@ -603,6 +601,7 @@ bool p3PeerMgr::setLocalAddress(const std::string &id, struct sockaddr_in add
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
|
||||
mNetMgr->setLocalAddress(addr);
|
||||
mLinkMgr->setLocalAddress(addr);
|
||||
|
||||
#ifdef CONN_DEBUG_RESET
|
||||
std::cerr << "p3PeerMgr::setLocalAddress() Calling NetReset" << std::endl;
|
||||
|
@ -181,12 +181,7 @@ bool assignPeersToGroup(const std::string &groupId, const std::list<std::stri
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/* Internal Functions */
|
||||
void statusTick();
|
||||
|
||||
/* monitor control */
|
||||
void tickMonitors();
|
||||
|
||||
protected:
|
||||
/*****************************************************************/
|
||||
|
82
libretroshare/src/retroshare/rsnetwork.h
Normal file
82
libretroshare/src/retroshare/rsnetwork.h
Normal file
@ -0,0 +1,82 @@
|
||||
#ifndef RETROSHARE_NETWORK_GUI_INTERFACE_H
|
||||
#define RETROSHARE_NETWORK_GUI_INTERFACE_H
|
||||
|
||||
/*
|
||||
* libretroshare/src/retroshare: rsnetwork.h
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 2011-2011 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".
|
||||
*
|
||||
*/
|
||||
|
||||
#define RSNET_NETWORK_UNKNOWN 1
|
||||
#define RSNET_NETWORK_RESTARTING 2
|
||||
#define RSNET_NETWORK_OFFLINE 3
|
||||
#define RSNET_NETWORK_LOCALNET 4
|
||||
#define RSNET_NETWORK_BEHINDNAT 5
|
||||
#define RSNET_NETWORK_EXTERNALIP 6
|
||||
|
||||
// WHAT TYPE OF FIREWALL?
|
||||
#define RSNET_NATTYPE_NONE 1
|
||||
#define RSNET_NATTYPE_UNKNOWN 2
|
||||
#define RSNET_NATTYPE_SYMMETRIC 3
|
||||
#define RSNET_NATTYPE_RESTRICTED_CONE 4
|
||||
#define RSNET_NATTYPE_FULL_CONE 5
|
||||
#define RSNET_NATTYPE_OTHER 6
|
||||
|
||||
// WHAT TYPE OF HOLE?
|
||||
#define RSNET_NATHOLE_UNKNOWN 0
|
||||
#define RSNET_NATHOLE_NONE 1
|
||||
#define RSNET_NATHOLE_UPNP 2
|
||||
#define RSNET_NATHOLE_NATPMP 3
|
||||
#define RSNET_NATHOLE_FORWARDED 4
|
||||
|
||||
// Types of Connections.
|
||||
#define RSNET_CONNECT_NONE 0x0000
|
||||
#define RSNET_CONNECT_ACCEPT_TCP 0x0001
|
||||
#define RSNET_CONNECT_OUTGOING_TCP 0x0002
|
||||
#define RSNET_CONNECT_DIRECT_UDP 0x0100
|
||||
#define RSNET_CONNECT_PROXY_UDP 0x0200
|
||||
#define RSNET_CONNECT_RELAY_UDP 0x0400
|
||||
|
||||
// net state (good, okay, bad)
|
||||
// BAD. (RED)
|
||||
#define RSNET_NETSTATE_BAD_UNKNOWN 1
|
||||
#define RSNET_NETSTATE_BAD_OFFLINE 2
|
||||
#define RSNET_NETSTATE_BAD_NATSYM 3
|
||||
#define RSNET_NETSTATE_BAD_NODHT_NAT 4
|
||||
|
||||
// CAUTION. (ORANGE)
|
||||
#define RSNET_NETSTATE_WARNING_RESTART 5
|
||||
#define RSNET_NETSTATE_WARNING_NATTED 6
|
||||
#define RSNET_NETSTATE_WARNING_NODHT 7
|
||||
|
||||
// GOOD (GREEN)
|
||||
// NAT with forwarded port, or EXT port.
|
||||
#define RSNET_NETSTATE_GOOD 8
|
||||
|
||||
// ADVANCED MODE (BLUE)
|
||||
// If the user knows what they are doing... we cannot confirm this.
|
||||
#define RSNET_NETSTATE_ADV_FORWARD 9
|
||||
#define RSNET_NETSTATE_ADV_DARK_FORWARD 10
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -1836,6 +1836,7 @@ int RsServer::StartupRetroShare()
|
||||
mNetMgr = new p3NetMgr();
|
||||
mLinkMgr = new p3LinkMgr(mPeerMgr, mNetMgr);
|
||||
|
||||
mPeerMgr->setManagers(mLinkMgr, mNetMgr);
|
||||
mNetMgr->setManagers(mPeerMgr, mLinkMgr);
|
||||
|
||||
//load all the SSL certs as friends
|
||||
|
Loading…
Reference in New Issue
Block a user