mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-16 18:39:46 -04:00
Created V0.3.x branch and moved the head into the trunk directory.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@246 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
commit
935745a08e
1318 changed files with 348809 additions and 0 deletions
97
libretroshare/src/dht/dhthandler.h
Normal file
97
libretroshare/src/dht/dhthandler.h
Normal file
|
@ -0,0 +1,97 @@
|
|||
#ifndef _RS_DHT_IFACE_H
|
||||
#define _RS_DHT_IFACE_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* This stuff is actually C */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <int128.h>
|
||||
#include <KadCapi.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern C */
|
||||
#endif
|
||||
/* This stuff is actually C */
|
||||
|
||||
|
||||
#include "util/rsthreads.h"
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
/* platform independent networking... */
|
||||
#include "pqi/pqinetwork.h"
|
||||
#include "pqi/pqiaddrstore.h"
|
||||
|
||||
class dhtentry
|
||||
{
|
||||
public:
|
||||
std::string name;
|
||||
std::string id;
|
||||
struct sockaddr_in addr;
|
||||
unsigned int flags;
|
||||
int status;
|
||||
int lastTs;
|
||||
};
|
||||
|
||||
class dhthandler: public RsThread, public pqiAddrStore
|
||||
{
|
||||
public:
|
||||
|
||||
dhthandler(std::string inifile);
|
||||
~dhthandler();
|
||||
|
||||
/* RsIface */
|
||||
/* set own tag */
|
||||
void setOwnHash(std::string id);
|
||||
void setOwnPort(short port);
|
||||
bool getExtAddr(sockaddr_in &addr, unsigned int &flags);
|
||||
|
||||
/* at startup */
|
||||
void addFriend(std::string id);
|
||||
void removeFriend(std::string id);
|
||||
int dhtPeers();
|
||||
|
||||
/* pqiAddrStore ... called prior to connect */
|
||||
virtual bool addrFriend(std::string id, struct sockaddr_in &addr, unsigned int &flags);
|
||||
|
||||
int init();
|
||||
int shutdown();
|
||||
int print();
|
||||
|
||||
/* must run thread */
|
||||
virtual void run();
|
||||
|
||||
private:
|
||||
|
||||
int write_inifile();
|
||||
|
||||
bool networkUp(); /* get status */
|
||||
|
||||
int checkOwnStatus();
|
||||
int checkPeerIds();
|
||||
int publishOwnId();
|
||||
int searchId(std::string id);
|
||||
|
||||
dhtentry *finddht(std::string id);
|
||||
|
||||
/* Mutex for data below */
|
||||
RsMutex dataMtx;
|
||||
|
||||
dhtentry ownId;
|
||||
std::map<std::string, dhtentry> addrs;
|
||||
|
||||
KadCcontext kcc, *pkcc;
|
||||
KadC_status kcs;
|
||||
std::string kadcFile;
|
||||
bool mShutdown;
|
||||
|
||||
bool dhtOk;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* _RS_DHT_IFACE_H */
|
Loading…
Add table
Add a link
Reference in a new issue