mirror of
https://github.com/asamy/ctorrent
synced 2025-10-05 23:52:41 +02:00
tracker: correctness
This commit is contained in:
@@ -456,10 +456,8 @@ bool TorrentFileManager::registerFiles(const std::string &baseDir, const Torrent
|
||||
|
||||
if (inf.path != filePath) {
|
||||
std::string path = baseDir + filePath;
|
||||
if (!validatePath(baseDir, path)) {
|
||||
std::clog << "Error validating dir: " << path << std::endl;
|
||||
if (!validatePath(baseDir, path))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!nodeExists(path))
|
||||
MKDIR(path);
|
||||
|
@@ -27,7 +27,7 @@
|
||||
bool Tracker::query(const TrackerQuery &req)
|
||||
{
|
||||
bool ret = false;
|
||||
if (m_prot == "http")
|
||||
if (m_type == TrackerHTTP)
|
||||
ret = httpRequest(req);
|
||||
else
|
||||
ret = udpRequest(req);
|
||||
|
@@ -45,14 +45,19 @@ struct TrackerQuery {
|
||||
class Torrent;
|
||||
class Tracker
|
||||
{
|
||||
enum TrackerType {
|
||||
TrackerHTTP,
|
||||
TrackerUDP,
|
||||
};
|
||||
|
||||
public:
|
||||
Tracker(Torrent *torrent, const std::string &host, const std::string &port, const std::string &proto, uint16_t tport)
|
||||
: m_torrent(torrent),
|
||||
m_tport(tport),
|
||||
m_host(host),
|
||||
m_port(port),
|
||||
m_prot(proto)
|
||||
m_port(port)
|
||||
{
|
||||
m_type = proto == "http" ? TrackerHTTP : TrackerUDP;
|
||||
}
|
||||
|
||||
std::string host() const { return m_host; }
|
||||
@@ -71,10 +76,10 @@ private:
|
||||
Torrent *m_torrent;
|
||||
TimePoint m_timeToNextRequest;
|
||||
|
||||
TrackerType m_type;
|
||||
uint16_t m_tport;
|
||||
std::string m_host;
|
||||
std::string m_port;
|
||||
std::string m_prot;
|
||||
|
||||
friend class Torrent;
|
||||
};
|
||||
|
Reference in New Issue
Block a user