2007-03-26 12:16:57 +00:00
|
|
|
/* <!-- copyright */
|
|
|
|
/*
|
|
|
|
* aria2 - The high speed download utility
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Tatsuhiro Tsujikawa
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
* In addition, as a special exception, the copyright holders give
|
|
|
|
* permission to link the code of portions of this program with the
|
|
|
|
* OpenSSL library under certain conditions as described in each
|
|
|
|
* individual source file, and distribute linked combinations
|
|
|
|
* including the two.
|
|
|
|
* You must obey the GNU General Public License in all respects
|
|
|
|
* for all of the code used other than OpenSSL. If you modify
|
|
|
|
* file(s) with this exception, you may extend this exception to your
|
|
|
|
* version of the file(s), but you are not obligated to do so. If you
|
|
|
|
* do not wish to do so, delete this exception statement from your
|
|
|
|
* version. If you delete this exception statement from all source
|
|
|
|
* files in the program, then also delete it here.
|
|
|
|
*/
|
|
|
|
/* copyright --> */
|
|
|
|
#ifndef _D_OPTION_HANDLER_IMPL_H_
|
|
|
|
#define _D_OPTION_HANDLER_IMPL_H_
|
|
|
|
|
|
|
|
#include "OptionHandler.h"
|
2008-11-04 14:08:26 +00:00
|
|
|
|
|
|
|
#include <cstdio>
|
|
|
|
#include <utility>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <numeric>
|
|
|
|
#include <sstream>
|
|
|
|
#include <iterator>
|
|
|
|
|
2007-03-26 12:16:57 +00:00
|
|
|
#include "NameMatchOptionHandler.h"
|
|
|
|
#include "Util.h"
|
2009-05-12 13:51:12 +00:00
|
|
|
#include "DlAbortEx.h"
|
2007-03-26 12:16:57 +00:00
|
|
|
#include "prefs.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
#include "Option.h"
|
2008-04-27 02:22:14 +00:00
|
|
|
#include "StringFormat.h"
|
2008-09-22 09:26:57 +00:00
|
|
|
#include "A2STR.h"
|
2008-11-04 14:08:26 +00:00
|
|
|
#include "Request.h"
|
2009-06-06 12:33:07 +00:00
|
|
|
#include "a2functional.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
|
|
|
|
namespace aria2 {
|
2007-03-26 12:16:57 +00:00
|
|
|
|
|
|
|
class NullOptionHandler : public OptionHandler {
|
2009-02-07 11:00:34 +00:00
|
|
|
private:
|
|
|
|
int _id;
|
2007-03-26 12:16:57 +00:00
|
|
|
public:
|
|
|
|
virtual ~NullOptionHandler() {}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
virtual bool canHandle(const std::string& optName) { return true; }
|
2007-03-26 12:16:57 +00:00
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
virtual void parse(Option& option, const std::string& arg) {}
|
2008-09-22 09:26:57 +00:00
|
|
|
|
|
|
|
virtual bool hasTag(const std::string& tag) const { return false; }
|
|
|
|
|
|
|
|
virtual void addTag(const std::string& tag) {}
|
|
|
|
|
|
|
|
virtual std::string toTagString() const { return A2STR::NIL; }
|
|
|
|
|
|
|
|
virtual const std::string& getName() const { return A2STR::NIL; }
|
|
|
|
|
|
|
|
virtual const std::string& getDescription() const { return A2STR::NIL; }
|
|
|
|
|
|
|
|
virtual const std::string& getDefaultValue() const { return A2STR::NIL; }
|
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const { return A2STR::NIL; }
|
|
|
|
|
|
|
|
virtual bool isHidden() const { return true; }
|
2009-02-07 11:00:34 +00:00
|
|
|
|
2009-03-08 08:19:50 +00:00
|
|
|
virtual void hide() {}
|
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
virtual OptionHandler::ARG_TYPE getArgType() const
|
|
|
|
{
|
|
|
|
return OptionHandler::NO_ARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual int getOptionID() const
|
|
|
|
{
|
|
|
|
return _id;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void setOptionID(int id)
|
|
|
|
{
|
|
|
|
_id = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual char getShortName() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2007-03-26 12:16:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class BooleanOptionHandler : public NameMatchOptionHandler {
|
|
|
|
public:
|
2008-09-22 09:26:57 +00:00
|
|
|
BooleanOptionHandler(const std::string& optName,
|
|
|
|
const std::string& description = NO_DESCRIPTION,
|
2009-02-07 11:00:34 +00:00
|
|
|
const std::string& defaultValue = NO_DEFAULT_VALUE,
|
|
|
|
OptionHandler::ARG_TYPE argType = OptionHandler::REQ_ARG,
|
|
|
|
char shortName = 0):
|
|
|
|
NameMatchOptionHandler(optName, description, defaultValue,
|
|
|
|
argType, shortName) {}
|
2008-09-22 09:26:57 +00:00
|
|
|
|
2007-03-26 12:16:57 +00:00
|
|
|
virtual ~BooleanOptionHandler() {}
|
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
2007-03-26 12:16:57 +00:00
|
|
|
{
|
2009-02-07 11:00:34 +00:00
|
|
|
if(optarg == "true" ||
|
2009-02-11 07:46:15 +00:00
|
|
|
((_argType == OptionHandler::OPT_ARG ||
|
|
|
|
_argType == OptionHandler::NO_ARG)
|
|
|
|
&& optarg.empty())) {
|
2009-02-07 11:00:34 +00:00
|
|
|
option.put(_optName, V_TRUE);
|
2007-03-26 12:16:57 +00:00
|
|
|
} else if(optarg == "false") {
|
2009-02-07 11:00:34 +00:00
|
|
|
option.put(_optName, V_FALSE);
|
2007-03-26 12:16:57 +00:00
|
|
|
} else {
|
2009-06-06 12:33:07 +00:00
|
|
|
std::string msg = _optName;
|
|
|
|
strappend(msg, " ", _("must be either 'true' or 'false'."));
|
2009-05-18 15:07:15 +00:00
|
|
|
throw DL_ABORT_EX(msg);
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
}
|
2008-09-22 09:26:57 +00:00
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const
|
|
|
|
{
|
|
|
|
return "true,false";
|
|
|
|
}
|
2007-03-26 12:16:57 +00:00
|
|
|
};
|
|
|
|
|
2007-11-21 16:14:40 +00:00
|
|
|
class IntegerRangeOptionHandler : public NameMatchOptionHandler {
|
|
|
|
private:
|
|
|
|
int32_t _min;
|
|
|
|
int32_t _max;
|
|
|
|
public:
|
2008-09-22 09:26:57 +00:00
|
|
|
IntegerRangeOptionHandler(const std::string& optName,
|
|
|
|
const std::string& description,
|
|
|
|
const std::string& defaultValue,
|
2009-02-07 11:00:34 +00:00
|
|
|
int32_t min, int32_t max,
|
|
|
|
char shortName = 0):
|
|
|
|
NameMatchOptionHandler(optName, description, defaultValue,
|
|
|
|
OptionHandler::REQ_ARG, shortName),
|
2008-09-22 09:26:57 +00:00
|
|
|
_min(min), _max(max) {}
|
2007-11-21 16:14:40 +00:00
|
|
|
|
|
|
|
virtual ~IntegerRangeOptionHandler() {}
|
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
2007-11-21 16:14:40 +00:00
|
|
|
{
|
|
|
|
IntSequence seq = Util::parseIntRange(optarg);
|
|
|
|
while(seq.hasNext()) {
|
|
|
|
int32_t v = seq.next();
|
|
|
|
if(v < _min || _max < v) {
|
2009-06-06 12:33:07 +00:00
|
|
|
std::string msg = _optName;
|
|
|
|
strappend(msg, " ", _("must be between %s and %s."));
|
2009-05-18 15:07:15 +00:00
|
|
|
throw DL_ABORT_EX
|
2008-04-27 02:22:14 +00:00
|
|
|
(StringFormat(msg.c_str(), Util::itos(_min).c_str(),
|
|
|
|
Util::itos(_max).c_str()).str());
|
2007-11-21 16:14:40 +00:00
|
|
|
}
|
2009-02-07 11:00:34 +00:00
|
|
|
option.put(_optName, optarg);
|
2007-11-21 16:14:40 +00:00
|
|
|
}
|
|
|
|
}
|
2008-09-22 09:26:57 +00:00
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const
|
|
|
|
{
|
|
|
|
return Util::itos(_min)+"-"+Util::itos(_max);
|
|
|
|
}
|
2007-11-21 16:14:40 +00:00
|
|
|
};
|
|
|
|
|
2007-03-26 12:16:57 +00:00
|
|
|
class NumberOptionHandler : public NameMatchOptionHandler {
|
|
|
|
private:
|
|
|
|
int64_t _min;
|
|
|
|
int64_t _max;
|
|
|
|
public:
|
2008-09-22 09:26:57 +00:00
|
|
|
NumberOptionHandler(const std::string& optName,
|
|
|
|
const std::string& description = NO_DESCRIPTION,
|
|
|
|
const std::string& defaultValue = NO_DEFAULT_VALUE,
|
|
|
|
int64_t min = -1,
|
|
|
|
int64_t max = -1,
|
2009-02-07 11:00:34 +00:00
|
|
|
char shortName = 0):
|
|
|
|
NameMatchOptionHandler(optName, description, defaultValue,
|
|
|
|
OptionHandler::REQ_ARG, shortName),
|
2008-09-22 09:26:57 +00:00
|
|
|
_min(min), _max(max) {}
|
2007-03-26 12:16:57 +00:00
|
|
|
|
|
|
|
virtual ~NumberOptionHandler() {}
|
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
2007-03-26 12:16:57 +00:00
|
|
|
{
|
2007-11-21 16:14:40 +00:00
|
|
|
int64_t num = Util::parseLLInt(optarg);
|
2007-03-26 12:16:57 +00:00
|
|
|
parseArg(option, num);
|
|
|
|
}
|
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
void parseArg(Option& option, int64_t number)
|
2007-03-26 12:16:57 +00:00
|
|
|
{
|
|
|
|
if((_min == -1 || _min <= number) && (_max == -1 || number <= _max)) {
|
2009-02-07 11:00:34 +00:00
|
|
|
option.put(_optName, Util::itos(number));
|
2007-03-26 12:16:57 +00:00
|
|
|
} else {
|
2009-06-06 12:33:07 +00:00
|
|
|
std::string msg = _optName;
|
|
|
|
msg += " ";
|
2007-03-26 12:16:57 +00:00
|
|
|
if(_min == -1 && _max != -1) {
|
2008-04-27 02:22:14 +00:00
|
|
|
msg += StringFormat(_("must be smaller than or equal to %s."),
|
|
|
|
Util::itos(_max).c_str()).str();
|
2007-03-26 12:16:57 +00:00
|
|
|
} else if(_min != -1 && _max != -1) {
|
2008-04-27 02:22:14 +00:00
|
|
|
msg += StringFormat(_("must be between %s and %s."),
|
|
|
|
Util::itos(_min).c_str(), Util::itos(_max).c_str()).str();
|
2007-03-26 12:16:57 +00:00
|
|
|
} else if(_min != -1 && _max == -1) {
|
2008-04-27 02:22:14 +00:00
|
|
|
msg += StringFormat(_("must be greater than or equal to %s."),
|
|
|
|
Util::itos(_min).c_str()).str();
|
2007-03-26 12:16:57 +00:00
|
|
|
} else {
|
|
|
|
msg += _("must be a number.");
|
|
|
|
}
|
2009-05-18 15:07:15 +00:00
|
|
|
throw DL_ABORT_EX(msg);
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
}
|
2008-09-22 09:26:57 +00:00
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const
|
|
|
|
{
|
2009-06-06 12:33:07 +00:00
|
|
|
std::string values;
|
|
|
|
if(_min == -1) {
|
|
|
|
values += "*";
|
|
|
|
} else {
|
|
|
|
values += Util::itos(_min);
|
|
|
|
}
|
|
|
|
values += "-";
|
|
|
|
if(_max == -1) {
|
|
|
|
values += "*";
|
|
|
|
} else {
|
|
|
|
values += Util::itos(_max);
|
|
|
|
}
|
|
|
|
return values;
|
2008-09-22 09:26:57 +00:00
|
|
|
}
|
2007-03-26 12:16:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class UnitNumberOptionHandler : public NumberOptionHandler {
|
|
|
|
public:
|
2008-09-22 09:26:57 +00:00
|
|
|
UnitNumberOptionHandler(const std::string& optName,
|
|
|
|
const std::string& description = NO_DESCRIPTION,
|
|
|
|
const std::string& defaultValue = NO_DEFAULT_VALUE,
|
|
|
|
int64_t min = -1,
|
|
|
|
int64_t max = -1,
|
2009-02-07 11:00:34 +00:00
|
|
|
char shortName = 0):
|
|
|
|
NumberOptionHandler(optName, description, defaultValue, min, max,
|
|
|
|
shortName) {}
|
2007-03-26 12:16:57 +00:00
|
|
|
|
|
|
|
virtual ~UnitNumberOptionHandler() {}
|
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
2007-03-26 12:16:57 +00:00
|
|
|
{
|
|
|
|
int64_t num = Util::getRealSize(optarg);
|
|
|
|
NumberOptionHandler::parseArg(option, num);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class FloatNumberOptionHandler : public NameMatchOptionHandler {
|
|
|
|
private:
|
|
|
|
double _min;
|
|
|
|
double _max;
|
|
|
|
public:
|
2008-09-22 09:26:57 +00:00
|
|
|
FloatNumberOptionHandler(const std::string& optName,
|
|
|
|
const std::string& description = NO_DESCRIPTION,
|
|
|
|
const std::string& defaultValue = NO_DEFAULT_VALUE,
|
2009-02-07 11:00:34 +00:00
|
|
|
double min = -1, double max = -1,
|
|
|
|
char shortName = 0):
|
|
|
|
NameMatchOptionHandler(optName, description, defaultValue,
|
|
|
|
OptionHandler::REQ_ARG, shortName),
|
2008-09-22 09:26:57 +00:00
|
|
|
_min(min), _max(max) {}
|
2007-03-26 12:16:57 +00:00
|
|
|
|
|
|
|
virtual ~FloatNumberOptionHandler() {}
|
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
2007-03-26 12:16:57 +00:00
|
|
|
{
|
|
|
|
double number = strtod(optarg.c_str(), 0);
|
|
|
|
if((_min < 0 || _min <= number) && (_max < 0 || number <= _max)) {
|
2009-02-07 11:00:34 +00:00
|
|
|
option.put(_optName, optarg);
|
2007-03-26 12:16:57 +00:00
|
|
|
} else {
|
2009-06-06 12:33:07 +00:00
|
|
|
std::string msg = _optName;
|
|
|
|
msg += " ";
|
2007-03-26 12:16:57 +00:00
|
|
|
if(_min < 0 && _max >= 0) {
|
2008-04-27 02:22:14 +00:00
|
|
|
msg += StringFormat(_("must be smaller than or equal to %.1f."),
|
|
|
|
_max).str();
|
2007-03-26 12:16:57 +00:00
|
|
|
} else if(_min >= 0 && _max >= 0) {
|
2008-04-27 02:22:14 +00:00
|
|
|
msg += StringFormat(_("must be between %.1f and %.1f."),
|
|
|
|
_min, _max).str();
|
2007-03-26 12:16:57 +00:00
|
|
|
} else if(_min >= 0 && _max < 0) {
|
2008-04-27 02:22:14 +00:00
|
|
|
msg += StringFormat(_("must be greater than or equal to %.1f."),
|
|
|
|
_min).str();
|
2007-03-26 12:16:57 +00:00
|
|
|
} else {
|
|
|
|
msg += _("must be a number.");
|
|
|
|
}
|
2009-05-18 15:07:15 +00:00
|
|
|
throw DL_ABORT_EX(msg);
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
}
|
2008-09-22 09:26:57 +00:00
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const
|
|
|
|
{
|
|
|
|
std::string valuesString;
|
|
|
|
if(_min < 0) {
|
|
|
|
valuesString += "*";
|
|
|
|
} else {
|
|
|
|
char buf[11];
|
|
|
|
snprintf(buf, sizeof(buf), "%.1f", _min);
|
|
|
|
valuesString += buf;
|
|
|
|
}
|
|
|
|
valuesString += "-";
|
|
|
|
if(_max < 0) {
|
|
|
|
valuesString += "*";
|
|
|
|
} else {
|
|
|
|
char buf[11];
|
|
|
|
snprintf(buf, sizeof(buf), "%.1f", _max);
|
|
|
|
valuesString += buf;
|
|
|
|
}
|
|
|
|
return valuesString;
|
|
|
|
}
|
2007-03-26 12:16:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class DefaultOptionHandler : public NameMatchOptionHandler {
|
2008-09-22 09:26:57 +00:00
|
|
|
private:
|
|
|
|
std::string _possibleValuesString;
|
2007-03-26 12:16:57 +00:00
|
|
|
public:
|
2008-09-22 09:26:57 +00:00
|
|
|
DefaultOptionHandler(const std::string& optName,
|
|
|
|
const std::string& description = NO_DESCRIPTION,
|
|
|
|
const std::string& defaultValue = NO_DEFAULT_VALUE,
|
|
|
|
const std::string& possibleValuesString = A2STR::NIL,
|
2009-02-07 11:00:34 +00:00
|
|
|
OptionHandler::ARG_TYPE argType = OptionHandler::REQ_ARG,
|
|
|
|
char shortName = 0):
|
|
|
|
NameMatchOptionHandler(optName, description, defaultValue, argType,
|
|
|
|
shortName),
|
2008-09-22 09:26:57 +00:00
|
|
|
_possibleValuesString(possibleValuesString) {}
|
2007-03-26 12:16:57 +00:00
|
|
|
|
|
|
|
virtual ~DefaultOptionHandler() {}
|
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
2007-03-26 12:16:57 +00:00
|
|
|
{
|
2009-02-07 11:00:34 +00:00
|
|
|
option.put(_optName, optarg);
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
2008-09-22 09:26:57 +00:00
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const
|
|
|
|
{
|
|
|
|
return _possibleValuesString;
|
|
|
|
}
|
2007-03-26 12:16:57 +00:00
|
|
|
};
|
|
|
|
|
2008-04-20 06:30:44 +00:00
|
|
|
class CumulativeOptionHandler : public NameMatchOptionHandler {
|
|
|
|
private:
|
|
|
|
std::string _delim;
|
2008-09-22 09:26:57 +00:00
|
|
|
|
|
|
|
std::string _possibleValuesString;
|
2008-04-20 06:30:44 +00:00
|
|
|
public:
|
|
|
|
CumulativeOptionHandler(const std::string& optName,
|
2008-09-22 09:26:57 +00:00
|
|
|
const std::string& description,
|
|
|
|
const std::string& defaultValue,
|
|
|
|
const std::string& delim,
|
2009-02-07 11:00:34 +00:00
|
|
|
const std::string& possibleValuesString = A2STR::NIL,
|
|
|
|
OptionHandler::ARG_TYPE argType =
|
|
|
|
OptionHandler::REQ_ARG,
|
|
|
|
char shortName = 0):
|
|
|
|
NameMatchOptionHandler(optName, description, defaultValue, argType,
|
|
|
|
shortName),
|
2008-09-22 09:26:57 +00:00
|
|
|
_delim(delim),
|
|
|
|
_possibleValuesString(possibleValuesString) {}
|
2008-04-20 06:30:44 +00:00
|
|
|
|
|
|
|
virtual ~CumulativeOptionHandler() {}
|
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
2008-04-20 06:30:44 +00:00
|
|
|
{
|
2009-02-07 11:00:34 +00:00
|
|
|
std::string value = option.get(_optName);
|
2009-06-06 12:33:07 +00:00
|
|
|
strappend(value, optarg, _delim);
|
2009-02-07 11:00:34 +00:00
|
|
|
option.put(_optName, value);
|
2008-04-20 06:30:44 +00:00
|
|
|
}
|
2008-09-22 09:26:57 +00:00
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const
|
|
|
|
{
|
|
|
|
return _possibleValuesString;
|
|
|
|
}
|
2008-04-20 06:30:44 +00:00
|
|
|
};
|
|
|
|
|
2009-03-07 03:10:53 +00:00
|
|
|
class IndexOutOptionHandler : public NameMatchOptionHandler {
|
|
|
|
private:
|
|
|
|
public:
|
|
|
|
IndexOutOptionHandler(const std::string& optName,
|
|
|
|
const std::string& description,
|
|
|
|
char shortName = 0):
|
|
|
|
NameMatchOptionHandler(optName, description, NO_DEFAULT_VALUE,
|
|
|
|
OptionHandler::REQ_ARG, shortName) {}
|
|
|
|
|
|
|
|
virtual ~IndexOutOptionHandler() {}
|
|
|
|
|
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
|
|
|
{
|
|
|
|
// See optarg is in the fomrat of "INDEX=PATH"
|
|
|
|
Util::parseIndexPath(optarg);
|
|
|
|
std::string value = option.get(_optName);
|
2009-06-06 12:33:07 +00:00
|
|
|
strappend(value, optarg, "\n");
|
2009-03-07 03:10:53 +00:00
|
|
|
option.put(_optName, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const
|
|
|
|
{
|
|
|
|
return "INDEX=PATH";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2007-03-26 12:16:57 +00:00
|
|
|
class ParameterOptionHandler : public NameMatchOptionHandler {
|
|
|
|
private:
|
2008-02-08 15:53:45 +00:00
|
|
|
std::deque<std::string> _validParamValues;
|
2007-03-26 12:16:57 +00:00
|
|
|
public:
|
2008-09-22 09:26:57 +00:00
|
|
|
ParameterOptionHandler(const std::string& optName,
|
|
|
|
const std::string& description,
|
|
|
|
const std::string& defaultValue,
|
2009-02-07 11:00:34 +00:00
|
|
|
const std::deque<std::string>& validParamValues,
|
|
|
|
char shortName = 0):
|
|
|
|
NameMatchOptionHandler(optName, description, defaultValue,
|
|
|
|
OptionHandler::REQ_ARG, shortName),
|
2008-09-22 09:26:57 +00:00
|
|
|
_validParamValues(validParamValues) {}
|
2007-03-26 12:16:57 +00:00
|
|
|
|
2008-09-22 09:26:57 +00:00
|
|
|
ParameterOptionHandler(const std::string& optName,
|
|
|
|
const std::string& description,
|
|
|
|
const std::string& defaultValue,
|
2009-02-07 11:00:34 +00:00
|
|
|
const std::string& validParamValue,
|
|
|
|
char shortName = 0):
|
|
|
|
NameMatchOptionHandler(optName, description, defaultValue,
|
|
|
|
OptionHandler::REQ_ARG, shortName)
|
2007-03-26 12:16:57 +00:00
|
|
|
{
|
|
|
|
_validParamValues.push_back(validParamValue);
|
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
ParameterOptionHandler(const std::string& optName,
|
2008-09-22 09:26:57 +00:00
|
|
|
const std::string& description,
|
|
|
|
const std::string& defaultValue,
|
2008-02-08 15:53:45 +00:00
|
|
|
const std::string& validParamValue1,
|
2009-02-07 11:00:34 +00:00
|
|
|
const std::string& validParamValue2,
|
|
|
|
char shortName = 0):
|
|
|
|
NameMatchOptionHandler(optName, description, defaultValue,
|
|
|
|
OptionHandler::REQ_ARG, shortName)
|
2007-03-26 12:16:57 +00:00
|
|
|
{
|
|
|
|
_validParamValues.push_back(validParamValue1);
|
|
|
|
_validParamValues.push_back(validParamValue2);
|
|
|
|
}
|
2007-11-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten to add content-type support.
* src/DownloadHandler.{h, cc}
* src/BtPostDownloadHandler.{h, cc}
* test/BtPostDownloadHandlerTest.cc
* src/MetalinkPostDownloadHandler.{h, cc}
* test/MetalinkPostDownloadHandlerTest.cc
* src/PostDownloadHandler.{h, cc}
* src/DownloadHandlerConstants.{h, cc}
* src/RequestGroup.cc
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
* src/SingleFileDownloadContext.{h, cc}
* src/RequestGroup.h
* src/RequestGroupCriteria.h
* src/ContentTypeRequestGroupCriteria.h
Added 'mem' option value for --follow-metalink,
--follow-torrent.
If it is give, metalink/torrent file is not written to the disk,
but
just is kept in memory. Parsing is occurred on memory.
* src/MetalinkHelper.{h, cc}
* src/MetalinkProcessor.h
* src/Xml2MetalinkProcessor.{h, cc}
* test/Xml2MetalinkProcessorTest.cc
* src/DownloadHandlerFactory.{h, cc}
* test/DownloadHandlerFactoryTest.cc
* src/PreDownloadHandler.{h, cc}
* src/OptionHandlerFactory.cc
* src/DefaultBtContext.{h, cc}
* test/DefaultBtContextTest.cc
* src/version_usage.cc
* src/Metalink2RequestGroup.{h, cc}
* src/RequestGroup.{h, cc}
* src/a2functional.h
* test/a2functionalTest.cc
* src/MemoryBufferPreDownloadHandler.{h, cc}
* src/OptionHandlerImpl.h
* src/prefs.h
* src/Util.{h, cc}
* test/UtilTest.cc
Keep DownloadResult rather than RequestGroup after downloads to
reduce
memory usage.
* src/RequestGroupMan.{h, cc}
* src/DownloadEngine.cc
* src/BtDependency.{h, cc}: Changed the type of dependee from
WeakHandle to SharedHandle because WeakHandle could be null.
* src/RequestGroup.{h, cc}
* src/DownloadEngineFactory.cc
* src/DownloadResult.h
Set totalLength after download finished
* src/UnknownLengthPieceStorage.{h, cc}
Keep torrent file specified in metalink in memory.
* src/Metalink2RequestGroup.cc
* src/BtDependency.cc
* src/TrueRequestGroupCriteria.h
Fixed the bug: seekg is used where seekp should be used.
* src/ByteArrayDiskWriter.cc
* test/ByteArraydiskWriterTest.cc
2007-11-27 12:27:10 +00:00
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
ParameterOptionHandler(const std::string& optName,
|
2008-09-22 09:26:57 +00:00
|
|
|
const std::string& description,
|
|
|
|
const std::string& defaultValue,
|
2008-02-08 15:53:45 +00:00
|
|
|
const std::string& validParamValue1,
|
|
|
|
const std::string& validParamValue2,
|
2009-02-07 11:00:34 +00:00
|
|
|
const std::string& validParamValue3,
|
|
|
|
char shortName = 0):
|
|
|
|
NameMatchOptionHandler(optName, description, defaultValue,
|
|
|
|
OptionHandler::REQ_ARG, shortName)
|
2007-11-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten to add content-type support.
* src/DownloadHandler.{h, cc}
* src/BtPostDownloadHandler.{h, cc}
* test/BtPostDownloadHandlerTest.cc
* src/MetalinkPostDownloadHandler.{h, cc}
* test/MetalinkPostDownloadHandlerTest.cc
* src/PostDownloadHandler.{h, cc}
* src/DownloadHandlerConstants.{h, cc}
* src/RequestGroup.cc
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
* src/SingleFileDownloadContext.{h, cc}
* src/RequestGroup.h
* src/RequestGroupCriteria.h
* src/ContentTypeRequestGroupCriteria.h
Added 'mem' option value for --follow-metalink,
--follow-torrent.
If it is give, metalink/torrent file is not written to the disk,
but
just is kept in memory. Parsing is occurred on memory.
* src/MetalinkHelper.{h, cc}
* src/MetalinkProcessor.h
* src/Xml2MetalinkProcessor.{h, cc}
* test/Xml2MetalinkProcessorTest.cc
* src/DownloadHandlerFactory.{h, cc}
* test/DownloadHandlerFactoryTest.cc
* src/PreDownloadHandler.{h, cc}
* src/OptionHandlerFactory.cc
* src/DefaultBtContext.{h, cc}
* test/DefaultBtContextTest.cc
* src/version_usage.cc
* src/Metalink2RequestGroup.{h, cc}
* src/RequestGroup.{h, cc}
* src/a2functional.h
* test/a2functionalTest.cc
* src/MemoryBufferPreDownloadHandler.{h, cc}
* src/OptionHandlerImpl.h
* src/prefs.h
* src/Util.{h, cc}
* test/UtilTest.cc
Keep DownloadResult rather than RequestGroup after downloads to
reduce
memory usage.
* src/RequestGroupMan.{h, cc}
* src/DownloadEngine.cc
* src/BtDependency.{h, cc}: Changed the type of dependee from
WeakHandle to SharedHandle because WeakHandle could be null.
* src/RequestGroup.{h, cc}
* src/DownloadEngineFactory.cc
* src/DownloadResult.h
Set totalLength after download finished
* src/UnknownLengthPieceStorage.{h, cc}
Keep torrent file specified in metalink in memory.
* src/Metalink2RequestGroup.cc
* src/BtDependency.cc
* src/TrueRequestGroupCriteria.h
Fixed the bug: seekg is used where seekp should be used.
* src/ByteArrayDiskWriter.cc
* test/ByteArraydiskWriterTest.cc
2007-11-27 12:27:10 +00:00
|
|
|
{
|
|
|
|
_validParamValues.push_back(validParamValue1);
|
|
|
|
_validParamValues.push_back(validParamValue2);
|
|
|
|
_validParamValues.push_back(validParamValue3);
|
|
|
|
}
|
2007-03-26 12:16:57 +00:00
|
|
|
|
|
|
|
virtual ~ParameterOptionHandler() {}
|
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
2007-03-26 12:16:57 +00:00
|
|
|
{
|
2008-02-08 15:53:45 +00:00
|
|
|
std::deque<std::string>::const_iterator itr =
|
|
|
|
std::find(_validParamValues.begin(), _validParamValues.end(), optarg);
|
2007-03-26 12:16:57 +00:00
|
|
|
if(itr == _validParamValues.end()) {
|
2009-06-06 12:33:07 +00:00
|
|
|
std::string msg = _optName;
|
|
|
|
strappend(msg, " ", _("must be one of the following:"));
|
2007-03-26 12:16:57 +00:00
|
|
|
if(_validParamValues.size() == 0) {
|
|
|
|
msg += "''";
|
|
|
|
} else {
|
2008-02-08 15:53:45 +00:00
|
|
|
for(std::deque<std::string>::const_iterator itr = _validParamValues.begin();
|
2007-03-26 12:16:57 +00:00
|
|
|
itr != _validParamValues.end(); ++itr) {
|
2009-06-06 12:33:07 +00:00
|
|
|
strappend(msg, "'", *itr, "' ");
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
}
|
2009-05-18 15:07:15 +00:00
|
|
|
throw DL_ABORT_EX(msg);
|
2007-03-26 12:16:57 +00:00
|
|
|
} else {
|
2009-02-07 11:00:34 +00:00
|
|
|
option.put(_optName, optarg);
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
}
|
2008-09-22 09:26:57 +00:00
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const
|
|
|
|
{
|
|
|
|
std::stringstream s;
|
|
|
|
std::copy(_validParamValues.begin(), _validParamValues.end(),
|
|
|
|
std::ostream_iterator<std::string>(s, ","));
|
|
|
|
return Util::trim(s.str(), ", ");
|
|
|
|
}
|
2007-03-26 12:16:57 +00:00
|
|
|
};
|
|
|
|
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
class HostPortOptionHandler : public NameMatchOptionHandler {
|
|
|
|
private:
|
2008-02-08 15:53:45 +00:00
|
|
|
std::string _hostOptionName;
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
std::string _portOptionName;
|
2007-03-26 12:16:57 +00:00
|
|
|
public:
|
2008-02-08 15:53:45 +00:00
|
|
|
HostPortOptionHandler(const std::string& optName,
|
2008-09-22 09:26:57 +00:00
|
|
|
const std::string& description,
|
|
|
|
const std::string& defaultValue,
|
2008-02-08 15:53:45 +00:00
|
|
|
const std::string& hostOptionName,
|
2009-02-07 11:00:34 +00:00
|
|
|
const std::string& portOptionName,
|
|
|
|
char shortName = 0):
|
|
|
|
NameMatchOptionHandler(optName, description, defaultValue,
|
|
|
|
OptionHandler::REQ_ARG, shortName),
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
_hostOptionName(hostOptionName),
|
|
|
|
_portOptionName(portOptionName) {}
|
2007-03-26 12:16:57 +00:00
|
|
|
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
virtual ~HostPortOptionHandler() {}
|
2007-03-26 12:16:57 +00:00
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
2007-03-26 12:16:57 +00:00
|
|
|
{
|
2008-02-08 15:53:45 +00:00
|
|
|
std::pair<std::string, std::string> proxy = Util::split(optarg, ":");
|
2007-11-21 16:14:40 +00:00
|
|
|
int32_t port = Util::parseInt(proxy.second);
|
2007-03-26 12:16:57 +00:00
|
|
|
if(proxy.first.empty() || proxy.second.empty() ||
|
2007-07-23 13:04:48 +00:00
|
|
|
port <= 0 || 65535 < port) {
|
2009-05-18 15:07:15 +00:00
|
|
|
throw DL_ABORT_EX(_("unrecognized proxy format"));
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
2009-02-07 11:00:34 +00:00
|
|
|
option.put(_optName, optarg);
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
setHostAndPort(option, proxy.first, port);
|
|
|
|
}
|
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
void setHostAndPort(Option& option, const std::string& hostname, uint16_t port)
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
{
|
2009-02-07 11:00:34 +00:00
|
|
|
option.put(_hostOptionName, hostname);
|
|
|
|
option.put(_portOptionName, Util::uitos(port));
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
}
|
2008-09-22 09:26:57 +00:00
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const
|
|
|
|
{
|
|
|
|
return "HOST:PORT";
|
|
|
|
}
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
};
|
|
|
|
|
2008-11-04 14:08:26 +00:00
|
|
|
class HttpProxyOptionHandler : public NameMatchOptionHandler {
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
public:
|
2008-02-08 15:53:45 +00:00
|
|
|
HttpProxyOptionHandler(const std::string& optName,
|
2008-09-22 09:26:57 +00:00
|
|
|
const std::string& description,
|
2009-02-07 11:00:34 +00:00
|
|
|
const std::string& defaultValue,
|
|
|
|
char shortName = 0)
|
2008-11-04 14:08:26 +00:00
|
|
|
:
|
2009-02-07 11:00:34 +00:00
|
|
|
NameMatchOptionHandler(optName, description, defaultValue,
|
|
|
|
OptionHandler::REQ_ARG, shortName)
|
2008-09-22 09:26:57 +00:00
|
|
|
{}
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
|
|
|
|
virtual ~HttpProxyOptionHandler() {}
|
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
{
|
2008-11-04 14:08:26 +00:00
|
|
|
Request req;
|
|
|
|
std::string url;
|
|
|
|
if(Util::startsWith(optarg, "http://")) {
|
|
|
|
url = optarg;
|
|
|
|
} else {
|
|
|
|
url = "http://"+optarg;
|
|
|
|
}
|
|
|
|
if(req.setUrl(url)) {
|
2009-02-07 11:00:34 +00:00
|
|
|
option.put(_optName, url);
|
2008-11-04 14:08:26 +00:00
|
|
|
} else {
|
2009-05-18 15:07:15 +00:00
|
|
|
throw DL_ABORT_EX(_("unrecognized proxy format"));
|
2008-11-04 14:08:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const
|
|
|
|
{
|
|
|
|
return "[http://][USER:PASSWORD@]HOST[:PORT]";
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
} // namespace aria2
|
|
|
|
|
2007-03-26 12:16:57 +00:00
|
|
|
#endif // _D_OPTION_HANDLER_IMPL_H_
|