Modified HTTP Server;
Added notice incase a user tries to use tracker as a HTTP tracker.
This commit is contained in:
parent
1aa7eceb2f
commit
d05820a992
|
@ -137,8 +137,13 @@ namespace UDPT
|
|||
{
|
||||
list<string> path;
|
||||
this->instance->addApp(&path, &WebApp::handleRoot);
|
||||
|
||||
path.push_back("api");
|
||||
this->instance->addApp(&path, &WebApp::handleAPI); // "/api"
|
||||
|
||||
path.pop_back();
|
||||
path.push_back("announce");
|
||||
this->instance->addApp(&path, &WebApp::handleAnnounce);
|
||||
}
|
||||
|
||||
void WebApp::handleRoot (HTTPServer *srv, HTTPServer::Request *req, HTTPServer::Response *resp)
|
||||
|
@ -220,6 +225,11 @@ namespace UDPT
|
|||
resp->write("{\"error\":\"failed to add torrent to DB\"}");
|
||||
}
|
||||
|
||||
void WebApp::handleAnnounce (HTTPServer *srv, HTTPServer::Request *req, HTTPServer::Response *resp)
|
||||
{
|
||||
resp->write("d14:failure reason42:this is a UDP tracker, not a HTTP tracker.e");
|
||||
}
|
||||
|
||||
void WebApp::handleAPI(HTTPServer *srv, HTTPServer::Request *req, HTTPServer::Response *resp)
|
||||
{
|
||||
if (req->getAddress()->sin_family != AF_INET)
|
||||
|
|
|
@ -49,6 +49,7 @@ namespace UDPT
|
|||
std::map<std::string, list<uint32_t> > ip_whitelist;
|
||||
|
||||
static void handleRoot (HTTPServer*,HTTPServer::Request*, HTTPServer::Response*);
|
||||
static void handleAnnounce (HTTPServer*,HTTPServer::Request*, HTTPServer::Response*);
|
||||
static void handleAPI (HTTPServer*,HTTPServer::Request*, HTTPServer::Response*);
|
||||
static bool isAllowedIP (WebApp *, string, uint32_t);
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "settings.hpp"
|
||||
#include "http/httpserver.hpp"
|
||||
#include "http/webapp.hpp"
|
||||
#include <cstdlib> // atoi
|
||||
|
||||
using namespace std;
|
||||
using namespace UDPT;
|
||||
|
|
|
@ -455,7 +455,7 @@ static int _isIANA_IP (uint32_t ip)
|
|||
}
|
||||
}
|
||||
|
||||
cout << ":: " << (void*)m_hton32(remote->sin_addr.s_addr) << ": " << m_hton16(remote->sin_port) << " ACTION=" << action << endl;
|
||||
// cout << ":: " << (void*)m_hton32(remote->sin_addr.s_addr) << ": " << m_hton16(remote->sin_port) << " ACTION=" << action << endl;
|
||||
|
||||
if (action == 0 && r >= 16)
|
||||
return UDPTracker::handleConnection (usi, remote, data);
|
||||
|
@ -465,7 +465,7 @@ static int _isIANA_IP (uint32_t ip)
|
|||
return UDPTracker::handleScrape (usi, remote, data, r);
|
||||
else
|
||||
{
|
||||
cout << "E: action=" << action << ", r=" << r << endl;
|
||||
// cout << "E: action=" << action << ", r=" << r << endl;
|
||||
UDPTracker::sendError (usi, remote, cR->transaction_id, "Tracker couldn't understand Client's request.");
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue