mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 00:19:25 -05:00
convert RSNET_CONNECT to enum class
This commit is contained in:
parent
d310102808
commit
acda7b8cc4
@ -1651,7 +1651,7 @@ RsNatHoleMode p3NetMgrIMPL::getNatHoleMode()
|
||||
return mNetStateBox.getNatHoleMode();
|
||||
}
|
||||
|
||||
uint32_t p3NetMgrIMPL::getConnectModes()
|
||||
RsConnectModes p3NetMgrIMPL::getConnectModes()
|
||||
{
|
||||
RsStackMutex stack(mNetMtx); /****** STACK LOCK MUTEX *******/
|
||||
return mNetStateBox.getConnectModes();
|
||||
|
@ -107,7 +107,7 @@ virtual uint32_t getNetStateMode() = 0;
|
||||
virtual RsNetworkMode getNetworkMode() = 0;
|
||||
virtual RsNatTypeMode getNatTypeMode() = 0;
|
||||
virtual RsNatHoleMode getNatHoleMode() = 0;
|
||||
virtual uint32_t getConnectModes() = 0;
|
||||
virtual RsConnectModes getConnectModes() = 0;
|
||||
|
||||
/* Shut It Down! */
|
||||
virtual bool shutdown() = 0; /* blocking shutdown call */
|
||||
@ -158,7 +158,7 @@ virtual uint32_t getNetStateMode();
|
||||
virtual RsNetworkMode getNetworkMode();
|
||||
virtual RsNatTypeMode getNatTypeMode();
|
||||
virtual RsNatHoleMode getNatHoleMode();
|
||||
virtual uint32_t getConnectModes();
|
||||
virtual RsConnectModes getConnectModes();
|
||||
|
||||
/* Shut It Down! */
|
||||
virtual bool shutdown(); /* blocking shutdown call */
|
||||
|
@ -164,7 +164,7 @@ RsNatHoleMode pqiNetStateBox::getNatHoleMode()
|
||||
return mNatHoleMode;
|
||||
}
|
||||
|
||||
uint32_t pqiNetStateBox::getConnectModes()
|
||||
RsConnectModes pqiNetStateBox::getConnectModes()
|
||||
{
|
||||
updateNetState();
|
||||
return mConnectModes;
|
||||
@ -195,7 +195,7 @@ void pqiNetStateBox::reset()
|
||||
mNetworkMode = RsNetworkMode::UNKNOWN;
|
||||
mNatTypeMode = RsNatTypeMode::UNKNOWN;
|
||||
mNatHoleMode = RsNatHoleMode::UNKNOWN;
|
||||
mConnectModes = RSNET_CONNECT_NONE;
|
||||
mConnectModes = RsConnectModes::NONE;
|
||||
mNetStateMode = RSNET_NETSTATE_BAD_UNKNOWN;
|
||||
|
||||
/* Parameters set externally */
|
||||
@ -552,7 +552,7 @@ void pqiNetStateBox::determineNetworkState()
|
||||
void pqiNetStateBox::workoutNetworkMode()
|
||||
{
|
||||
/* connectModes are dependent on the other modes */
|
||||
mConnectModes = RSNET_CONNECT_NONE;
|
||||
mConnectModes = RsConnectModes::NONE;
|
||||
switch(mNetworkMode)
|
||||
{
|
||||
case RsNetworkMode::UNKNOWN:
|
||||
@ -562,33 +562,33 @@ void pqiNetStateBox::workoutNetworkMode()
|
||||
/* nothing here */
|
||||
break;
|
||||
case RsNetworkMode::EXTERNALIP:
|
||||
mConnectModes = RSNET_CONNECT_OUTGOING_TCP;
|
||||
mConnectModes |= RSNET_CONNECT_ACCEPT_TCP;
|
||||
mConnectModes = RsConnectModes::OUTGOING_TCP;
|
||||
mConnectModes |= RsConnectModes::ACCEPT_TCP;
|
||||
|
||||
if (mDhtActive)
|
||||
{
|
||||
mConnectModes |= RSNET_CONNECT_DIRECT_UDP;
|
||||
mConnectModes |= RsConnectModes::DIRECT_UDP;
|
||||
/* if open port. don't want PROXY or RELAY connect
|
||||
* because we should be able to do direct with EVERYONE.
|
||||
* Ability to do Proxy is dependent on FIREWALL status.
|
||||
* Technically could do RELAY, but disable both.
|
||||
*/
|
||||
//mConnectModes |= RSNET_CONNECT_PROXY_UDP;
|
||||
//mConnectModes |= RSNET_CONNECT_RELAY_UDP;
|
||||
//mConnectModes |= RsConnectModes::PROXY_UDP;
|
||||
//mConnectModes |= RsConnectModes::RELAY_UDP;
|
||||
}
|
||||
break;
|
||||
case RsNetworkMode::BEHINDNAT:
|
||||
mConnectModes = RSNET_CONNECT_OUTGOING_TCP;
|
||||
mConnectModes = RsConnectModes::OUTGOING_TCP;
|
||||
|
||||
/* we're okay if there's a NAT HOLE */
|
||||
if ((mNatHoleMode == RsNatHoleMode::UPNP) ||
|
||||
(mNatHoleMode == RsNatHoleMode::NATPMP) ||
|
||||
(mNatHoleMode == RsNatHoleMode::FORWARDED))
|
||||
{
|
||||
mConnectModes |= RSNET_CONNECT_ACCEPT_TCP;
|
||||
mConnectModes |= RsConnectModes::ACCEPT_TCP;
|
||||
if (mDhtActive)
|
||||
{
|
||||
mConnectModes |= RSNET_CONNECT_DIRECT_UDP;
|
||||
mConnectModes |= RsConnectModes::DIRECT_UDP;
|
||||
/* dont want PROXY | RELAY with open ports */
|
||||
}
|
||||
}
|
||||
@ -600,14 +600,14 @@ void pqiNetStateBox::workoutNetworkMode()
|
||||
*/
|
||||
if (mDhtActive)
|
||||
{
|
||||
mConnectModes |= RSNET_CONNECT_DIRECT_UDP;
|
||||
mConnectModes |= RSNET_CONNECT_RELAY_UDP;
|
||||
mConnectModes |= RsConnectModes::DIRECT_UDP;
|
||||
mConnectModes |= RsConnectModes::RELAY_UDP;
|
||||
|
||||
if ((mNatTypeMode == RsNatTypeMode::RESTRICTED_CONE) ||
|
||||
(mNatTypeMode == RsNatTypeMode::FULL_CONE) ||
|
||||
(mNatTypeMode == RsNatTypeMode::DETERM_SYM))
|
||||
{
|
||||
mConnectModes |= RSNET_CONNECT_PROXY_UDP;
|
||||
mConnectModes |= RsConnectModes::PROXY_UDP;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -616,34 +616,6 @@ void pqiNetStateBox::workoutNetworkMode()
|
||||
}
|
||||
|
||||
|
||||
std::string NetStateConnectModesString(uint32_t connect)
|
||||
{
|
||||
std::string connOut;
|
||||
if (connect & RSNET_CONNECT_OUTGOING_TCP)
|
||||
{
|
||||
connOut += "TCP_OUT ";
|
||||
}
|
||||
if (connect & RSNET_CONNECT_ACCEPT_TCP)
|
||||
{
|
||||
connOut += "TCP_IN ";
|
||||
}
|
||||
if (connect & RSNET_CONNECT_DIRECT_UDP)
|
||||
{
|
||||
connOut += "DIRECT_UDP ";
|
||||
}
|
||||
if (connect & RSNET_CONNECT_PROXY_UDP)
|
||||
{
|
||||
connOut += "PROXY_UDP ";
|
||||
}
|
||||
if (connect & RSNET_CONNECT_RELAY_UDP)
|
||||
{
|
||||
connOut += "RELAY_UDP ";
|
||||
}
|
||||
return connOut;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string NetStateNetStateString(uint32_t netstate)
|
||||
{
|
||||
std::string str;
|
||||
|
@ -58,7 +58,7 @@ class pqiNetStateBox
|
||||
RsNetworkMode getNetworkMode();
|
||||
RsNatTypeMode getNatTypeMode();
|
||||
RsNatHoleMode getNatHoleMode();
|
||||
uint32_t getConnectModes();
|
||||
RsConnectModes getConnectModes();
|
||||
|
||||
private:
|
||||
|
||||
@ -77,7 +77,7 @@ class pqiNetStateBox
|
||||
RsNetworkMode mNetworkMode;
|
||||
RsNatTypeMode mNatTypeMode;
|
||||
RsNatHoleMode mNatHoleMode;
|
||||
uint32_t mConnectModes;
|
||||
RsConnectModes mConnectModes;
|
||||
uint32_t mNetStateMode;
|
||||
|
||||
/* Parameters set externally */
|
||||
@ -120,7 +120,5 @@ class pqiNetStateBox
|
||||
|
||||
|
||||
std::string NetStateNetStateString(uint32_t netstate);
|
||||
std::string NetStateConnectModesString(uint32_t connect);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -67,13 +67,16 @@ enum class RsNatHoleMode : uint8_t
|
||||
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
|
||||
enum class RsConnectModes : uint16_t
|
||||
{
|
||||
NONE = 0x0000,
|
||||
ACCEPT_TCP = 0x0001,
|
||||
OUTGOING_TCP= 0x0002,
|
||||
DIRECT_UDP = 0x0100,
|
||||
PROXY_UDP = 0x0200,
|
||||
RELAY_UDP = 0x0400
|
||||
};
|
||||
RS_REGISTER_ENUM_FLAGS_TYPE(RsConnectModes)
|
||||
|
||||
// net state (good, okay, bad)
|
||||
// BAD. (RED)
|
||||
@ -361,7 +364,7 @@ public:
|
||||
virtual RsNetworkMode getNetworkMode() = 0;
|
||||
virtual RsNatTypeMode getNatTypeMode() = 0;
|
||||
virtual RsNatHoleMode getNatHoleMode() = 0;
|
||||
virtual uint32_t getConnectModes() = 0;
|
||||
virtual RsConnectModes getConnectModes() = 0;
|
||||
|
||||
virtual bool getConfigurationOption(uint32_t key, std::string &opt) = 0;
|
||||
virtual bool setConfigurationOption(uint32_t key, const std::string &opt) = 0;
|
||||
|
@ -349,7 +349,7 @@ RsNatHoleMode p3ServerConfig::getNatHoleMode()
|
||||
return mNetMgr->getNatHoleMode();
|
||||
}
|
||||
|
||||
uint32_t p3ServerConfig::getConnectModes()
|
||||
RsConnectModes p3ServerConfig::getConnectModes()
|
||||
{
|
||||
return mNetMgr->getConnectModes();
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ virtual uint32_t getNetState();
|
||||
virtual RsNetworkMode getNetworkMode();
|
||||
virtual RsNatTypeMode getNatTypeMode();
|
||||
virtual RsNatHoleMode getNatHoleMode();
|
||||
virtual uint32_t getConnectModes();
|
||||
virtual RsConnectModes getConnectModes();
|
||||
|
||||
virtual bool getConfigurationOption(uint32_t key, std::string &opt);
|
||||
virtual bool setConfigurationOption(uint32_t key, const std::string &opt);
|
||||
|
@ -214,27 +214,27 @@ void DhtWindow::updateNetStatus()
|
||||
break;
|
||||
}
|
||||
|
||||
uint32_t connect = rsConfig->getConnectModes();
|
||||
RsConnectModes connect = rsConfig->getConnectModes();
|
||||
|
||||
label = ui.connectLabel;
|
||||
QString connOut;
|
||||
if (connect & RSNET_CONNECT_OUTGOING_TCP)
|
||||
if (!!(connect & RsConnectModes::OUTGOING_TCP))
|
||||
{
|
||||
connOut += "TCP_OUT ";
|
||||
}
|
||||
if (connect & RSNET_CONNECT_ACCEPT_TCP)
|
||||
if (!!(connect & RsConnectModes::ACCEPT_TCP))
|
||||
{
|
||||
connOut += "TCP_IN ";
|
||||
}
|
||||
if (connect & RSNET_CONNECT_DIRECT_UDP)
|
||||
if (!!(connect & RsConnectModes::DIRECT_UDP))
|
||||
{
|
||||
connOut += "DIRECT_UDP ";
|
||||
}
|
||||
if (connect & RSNET_CONNECT_PROXY_UDP)
|
||||
if (!!(connect & RsConnectModes::PROXY_UDP))
|
||||
{
|
||||
connOut += "PROXY_UDP ";
|
||||
}
|
||||
if (connect & RSNET_CONNECT_RELAY_UDP)
|
||||
if (!!(connect & RsConnectModes::RELAY_UDP))
|
||||
{
|
||||
connOut += "RELAY_UDP ";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user