mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-14 22:22:31 +00:00
* Don't skip the last line in rc files missing the final
newline. Patch by Jussi Judin under Public Domain. * Added warnings on usage of scgi_port. * Include a file's completed chunks count in the resume data. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@973 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -391,6 +391,7 @@ initialize_command_download() {
|
||||
ADD_CD_VALUE("is_hash_checked", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::is_hash_checked)));
|
||||
ADD_CD_VALUE("is_hash_checking", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::is_hash_checking)));
|
||||
ADD_CD_VALUE("is_multi_file", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::is_multi_file)));
|
||||
ADD_CD_VALUE("is_private", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::is_private)));
|
||||
|
||||
ADD_CD_VARIABLE_STRING_PUBLIC("custom1", "rtorrent", "custom1");
|
||||
ADD_CD_VARIABLE_STRING_PUBLIC("custom2", "rtorrent", "custom2");
|
||||
@@ -449,7 +450,6 @@ initialize_command_download() {
|
||||
ADD_CD_VALUE_UNI("peers_accounted", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::peers_accounted)));
|
||||
|
||||
ADD_CD_VALUE_MEM_BI("peer_exchange", &core::Download::download, &torrent::Download::set_pex_enabled, &torrent::Download::is_pex_enabled);
|
||||
ADD_CD_VALUE_UNI("private", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::is_private)));
|
||||
|
||||
ADD_CD_VALUE_MEM_UNI("up_rate", &torrent::Download::mutable_up_rate, &torrent::Rate::rate);
|
||||
ADD_CD_VALUE_MEM_UNI("up_total", &torrent::Download::mutable_up_rate, &torrent::Rate::total);
|
||||
|
||||
@@ -124,7 +124,7 @@ apply_start_tied() {
|
||||
const std::string& tiedToFile = rpc::call_command_string("d.get_tied_to_file", rpc::make_target(*itr));
|
||||
|
||||
if (!tiedToFile.empty() && fs.update(rak::path_expand(tiedToFile)))
|
||||
control->core()->download_list()->start_normal(*itr);
|
||||
control->core()->download_list()->start_try(*itr);
|
||||
}
|
||||
|
||||
return torrent::Object();
|
||||
@@ -140,7 +140,7 @@ apply_stop_untied() {
|
||||
const std::string& tiedToFile = rpc::call_command_string("d.get_tied_to_file", rpc::make_target(*itr));
|
||||
|
||||
if (!tiedToFile.empty() && !fs.update(rak::path_expand(tiedToFile)))
|
||||
control->core()->download_list()->stop_normal(*itr);
|
||||
control->core()->download_list()->stop_try(*itr);
|
||||
}
|
||||
|
||||
return torrent::Object();
|
||||
@@ -152,7 +152,7 @@ apply_close_untied() {
|
||||
rak::file_stat fs;
|
||||
const std::string& tiedToFile = rpc::call_command_string("d.get_tied_to_file", rpc::make_target(*itr));
|
||||
|
||||
if (!tiedToFile.empty() && !fs.update(rak::path_expand(tiedToFile)))
|
||||
if (rpc::call_command_value("d.get_ignore_commands", rpc::make_target(*itr)) == 0 && !tiedToFile.empty() && !fs.update(rak::path_expand(tiedToFile)))
|
||||
control->core()->download_list()->close(*itr);
|
||||
}
|
||||
|
||||
|
||||
@@ -204,12 +204,16 @@ apply_scgi(const std::string& arg, int type) {
|
||||
sa.sa_inet()->clear();
|
||||
saPtr = &sa;
|
||||
|
||||
control->core()->push_log("The SCGI socket has not been bound to any address and likely poses a security risk.");
|
||||
|
||||
} else if (std::sscanf(arg.c_str(), "%1023[^:]:%i%c", address, &port, &dummy) == 2) {
|
||||
if ((err = rak::address_info::get_address_info(address, PF_INET, SOCK_STREAM, &ai)) != 0)
|
||||
throw torrent::input_error("Could not bind address: " + std::string(rak::address_info::strerror(err)) + ".");
|
||||
|
||||
saPtr = ai->address();
|
||||
|
||||
control->core()->push_log("The SCGI socket is bound to a specific network device yet may still pose a security risk, consider using 'scgi_local'.");
|
||||
|
||||
} else {
|
||||
throw torrent::input_error("Could not parse address.");
|
||||
}
|
||||
|
||||
@@ -162,17 +162,25 @@ parse_command_file(const std::string& path) {
|
||||
try {
|
||||
unsigned int getCount = 0;
|
||||
|
||||
while (file.getline(buffer + getCount, 4096 - getCount).good()) {
|
||||
while (file.good()
|
||||
&& !file.getline(buffer + getCount, 4096 - getCount).fail()) {
|
||||
|
||||
if (file.gcount() == 0)
|
||||
throw torrent::internal_error("parse_command_file(...) file.gcount() == 0.");
|
||||
|
||||
int escaped = parse_count_escaped(buffer + getCount, buffer + getCount + file.gcount() - 1);
|
||||
int lineLength = file.gcount() - 1;
|
||||
// In case we are at the end of the file and the last character is
|
||||
// not a line feed, we'll just increase the read character count so
|
||||
// that the last would also be included in option line.
|
||||
if (file.eof() && file.get() != '\n')
|
||||
lineLength++;
|
||||
|
||||
int escaped = parse_count_escaped(buffer + getCount, buffer + getCount + lineLength);
|
||||
|
||||
lineNumber++;
|
||||
getCount += file.gcount() - 1;
|
||||
getCount += lineLength;
|
||||
|
||||
if (getCount == 4096 - 1)
|
||||
throw torrent::input_error("Exceeded max line lenght.");
|
||||
throw torrent::input_error("Exceeded max line length.");
|
||||
|
||||
if (escaped & 0x1) {
|
||||
// Remove the escape characters and continue reading.
|
||||
|
||||
Reference in New Issue
Block a user