/usr/include/libktorrent/dht/dht.h is in libktorrent-dev 1.3.1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | /***************************************************************************
* Copyright (C) 2005 by Joris Guisson *
* joris.guisson@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef DHTDHT_H
#define DHTDHT_H
#include <qtimer.h>
#include <qstring.h>
#include <qmap.h>
#include <util/constants.h>
#include <util/timer.h>
#include "key.h"
#include "dhtbase.h"
#include "rpcmsg.h"
namespace net
{
class AddressResolver;
}
namespace bt
{
class SHA1Hash;
}
namespace dht
{
class Node;
class RPCServer;
class Database;
class TaskManager;
class Task;
class AnnounceTask;
class NodeLookup;
class KBucket;
class ErrMsg;
class PingReq;
class FindNodeReq;
class GetPeersReq;
class AnnounceReq;
/**
@author Joris Guisson <joris.guisson@gmail.com>
*/
class DHT : public DHTBase
{
Q_OBJECT
public:
DHT();
virtual ~DHT();
void ping(const PingReq & r);
void findNode(const FindNodeReq & r);
void response(const RPCMsg & r);
void getPeers(const GetPeersReq & r);
void announce(const AnnounceReq & r);
void error(const ErrMsg & r);
void timeout(RPCMsg::Ptr r);
/**
* A Peer has received a PORT message, and uses this function to alert the DHT of it.
* @param ip The IP of the peer
* @param port The port in the PORT message
*/
void portReceived(const QString & ip,bt::Uint16 port);
/**
* Do an announce on the DHT network
* @param info_hash The info_hash
* @param port The port
* @return The task which handles this
*/
AnnounceTask* announce(const bt::SHA1Hash & info_hash,bt::Uint16 port);
/**
* Refresh a bucket using a find node task.
* @param id The id
* @param bucket The bucket to refresh
*/
NodeLookup* refreshBucket(const dht::Key & id,KBucket & bucket);
/**
* Do a NodeLookup.
* @param id The id of the key to search
*/
NodeLookup* findNode(const dht::Key & id);
/// Do a findNode for our node id
NodeLookup* findOwnNode();
/// See if it is possible to start a task
bool canStartTask() const;
void start(const QString & table,const QString & key_file,bt::Uint16 port);
void stop();
void addDHTNode(const QString & host,bt::Uint16 hport);
virtual QMap<QString, int> getClosestGoodNodes(int maxNodes);
private slots:
void update();
void onResolverResults(net::AddressResolver* ar);
void ownNodeLookupFinished(Task* t);
void expireDatabaseItems();
private:
Node* node;
RPCServer* srv;
Database* db;
TaskManager* tman;
QTimer expire_timer;
QString table_file;
QTimer update_timer;
NodeLookup* our_node_lookup;
};
}
#endif
|