mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-17 05:22:31 -04:00
Completed basics of the new p3bitdht system.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-netupgrade@4418 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
21145a29bb
commit
6eb27c9a1a
8 changed files with 3262 additions and 415 deletions
91
libretroshare/src/dht/connectstatebox.h
Normal file
91
libretroshare/src/dht/connectstatebox.h
Normal file
|
@ -0,0 +1,91 @@
|
|||
#ifndef CONNECT_STATUS_BOX_H
|
||||
#define CONNECT_STATUS_BOX_H
|
||||
|
||||
/* a connect state box */
|
||||
|
||||
#define CSB_START 1
|
||||
#define CSB_DIRECT_ATTEMPT 2
|
||||
#define CSB_DIRECT_WAIT 3
|
||||
#define CSB_PROXY_ATTEMPT 4
|
||||
#define CSB_PROXY_WAIT 5
|
||||
#define CSB_RELAY_ATTEMPT 6
|
||||
#define CSB_RELAY_WAIT 7
|
||||
#define CSB_REVERSE_WAIT 8
|
||||
#define CSB_FAILED_WAIT 9
|
||||
#define CSB_CONNECTED 10
|
||||
|
||||
|
||||
#define CSB_NETSTATE_UNKNOWN 0
|
||||
#define CSB_NETSTATE_FORWARD 1
|
||||
#define CSB_NETSTATE_STABLENAT 2
|
||||
#define CSB_NETSTATE_FIREWALLED 3
|
||||
|
||||
#define CSB_CONNECT_DIRECT 1
|
||||
#define CSB_CONNECT_UNREACHABLE 2
|
||||
|
||||
/* return values */
|
||||
#define CSB_ACTION_MASK_MODE 0x00ff
|
||||
#define CSB_ACTION_MASK_PORT 0xff00
|
||||
|
||||
#define CSB_ACTION_WAIT 0x0001
|
||||
#define CSB_ACTION_DIRECT_CONN 0x0002
|
||||
#define CSB_ACTION_PROXY_CONN 0x0004
|
||||
#define CSB_ACTION_RELAY_CONN 0x0008
|
||||
|
||||
#define CSB_ACTION_DHT_PORT 0x0100
|
||||
#define CSB_ACTION_PROXY_PORT 0x0200
|
||||
|
||||
/* update input */
|
||||
#define CSB_UPDATE_NONE 0x0000
|
||||
#define CSB_UPDATE_CONNECTED 0x0001
|
||||
#define CSB_UPDATE_DISCONNECTED 0x0002
|
||||
#define CSB_UPDATE_AUTH_DENIED 0x0003
|
||||
#define CSB_UPDATE_FAILED_ATTEMPT 0x0004
|
||||
#define CSB_UPDATE_MODE_UNAVAILABLE 0x0005
|
||||
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
class PeerConnectStateBox
|
||||
{
|
||||
public:
|
||||
PeerConnectStateBox();
|
||||
|
||||
uint32_t connectCb(uint32_t cbtype, uint32_t netmode, uint32_t nattype);
|
||||
uint32_t updateCb(uint32_t updateType);
|
||||
|
||||
bool shouldUseProxyPort(uint32_t netmode, uint32_t nattype);
|
||||
|
||||
std::string connectState();
|
||||
|
||||
std::string mPeerId;
|
||||
|
||||
bool storeProxyPortChoice(uint32_t flags, bool useProxyPort);
|
||||
bool getProxyPortChoice();
|
||||
|
||||
private:
|
||||
|
||||
uint32_t connectCb_direct();
|
||||
uint32_t connectCb_unreachable();
|
||||
|
||||
void errorMsg(std::ostream &out, std::string msg, uint32_t updateParam);
|
||||
void stateMsg(std::ostream &out, std::string msg, uint32_t updateParam);
|
||||
|
||||
|
||||
uint32_t mState;
|
||||
uint32_t mNetState;
|
||||
time_t mStateTS;
|
||||
uint32_t mNoAttempts;
|
||||
|
||||
// ProxyPort Storage.
|
||||
uint32_t mProxyPortFlags;
|
||||
bool mProxyPortChoice;
|
||||
time_t mProxyPortTS;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue