mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-11 12:42:31 +00:00
* Added xmlrpc calls for peer snubbed, banned and disconnect.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1180 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+21
-7
@@ -41,6 +41,8 @@
|
||||
#include <xmlrpc-c/server.h>
|
||||
#endif
|
||||
|
||||
#include <cctype>
|
||||
#include <rak/string_manip.h>
|
||||
#include <torrent/object.h>
|
||||
#include <torrent/exceptions.h>
|
||||
|
||||
@@ -175,29 +177,38 @@ xmlrpc_to_target(xmlrpc_env* env, xmlrpc_value* value) {
|
||||
// Trackers: "<hash>:t<index>"
|
||||
|
||||
int index;
|
||||
const char* end;
|
||||
const char* end_ptr = str + 42;
|
||||
|
||||
switch (str[41]) {
|
||||
case 'f':
|
||||
end = str + 42;
|
||||
index = ::strtol(str + 42, (char**)&end, 0);
|
||||
index = ::strtol(str + 42, (char**)&end_ptr, 0);
|
||||
|
||||
if (*str == '\0' || *end != '\0')
|
||||
if (*str == '\0' || *end_ptr != '\0')
|
||||
throw xmlrpc_error(XMLRPC_TYPE_ERROR, "Invalid index.");
|
||||
|
||||
target = rpc::make_target(XmlRpc::call_file, xmlrpc.get_slot_find_file()(download, index));
|
||||
break;
|
||||
|
||||
case 't':
|
||||
end = str + 42;
|
||||
index = ::strtol(str + 42, (char**)&end, 0);
|
||||
index = ::strtol(str + 42, (char**)&end_ptr, 0);
|
||||
|
||||
if (*str == '\0' || *end != '\0')
|
||||
if (*str == '\0' || *end_ptr != '\0')
|
||||
throw xmlrpc_error(XMLRPC_TYPE_ERROR, "Invalid index.");
|
||||
|
||||
target = rpc::make_target(XmlRpc::call_tracker, xmlrpc.get_slot_find_tracker()(download, index));
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
{
|
||||
torrent::HashString hash;
|
||||
const char* hash_end = torrent::hash_string_from_hex_c_str(str + 42, hash);
|
||||
|
||||
if (hash_end == end_ptr || *hash_end != '\0')
|
||||
throw xmlrpc_error(XMLRPC_TYPE_ERROR, "Not a hash string.");
|
||||
|
||||
target = rpc::make_target(XmlRpc::call_peer, xmlrpc.get_slot_find_peer()(download, hash));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
::free((void*)str);
|
||||
throw xmlrpc_error(XMLRPC_TYPE_ERROR, "Unsupported target type found.");
|
||||
@@ -496,6 +507,9 @@ XmlRpc::process(const char* inBuffer, uint32_t length, slot_write slotWrite) {
|
||||
|
||||
xmlrpc_mem_block* memblock = xmlrpc_registry_process_call(&localEnv, (xmlrpc_registry*)m_registry, NULL, inBuffer, length);
|
||||
|
||||
if (localEnv.fault_occurred && localEnv.fault_code == XMLRPC_INTERNAL_ERROR)
|
||||
throw torrent::internal_error("Internal error in XMLRPC.");
|
||||
|
||||
bool result = slotWrite((const char*)xmlrpc_mem_block_contents(memblock),
|
||||
xmlrpc_mem_block_size(memblock));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user