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"
|
|
|
|
#include "NameMatchOptionHandler.h"
|
|
|
|
#include "Util.h"
|
|
|
|
#include "FatalException.h"
|
|
|
|
#include "prefs.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
#include "Option.h"
|
|
|
|
#include <utility>
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
namespace aria2 {
|
2007-03-26 12:16:57 +00:00
|
|
|
|
|
|
|
class NullOptionHandler : public OptionHandler {
|
|
|
|
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
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
virtual void parse(Option* option, const std::string& arg) {}
|
2007-03-26 12:16:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class BooleanOptionHandler : public NameMatchOptionHandler {
|
|
|
|
public:
|
2008-02-08 15:53:45 +00:00
|
|
|
BooleanOptionHandler(const std::string& optName):NameMatchOptionHandler(optName) {}
|
2007-03-26 12:16:57 +00:00
|
|
|
virtual ~BooleanOptionHandler() {}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
virtual void parseArg(Option* option, const std::string& optarg)
|
2007-03-26 12:16:57 +00:00
|
|
|
{
|
|
|
|
if(optarg == "true") {
|
|
|
|
option->put(_optName, V_TRUE);
|
|
|
|
} else if(optarg == "false") {
|
|
|
|
option->put(_optName, V_FALSE);
|
|
|
|
} else {
|
2008-02-08 15:53:45 +00:00
|
|
|
std::string msg = _optName+" "+_("must be either 'true' or 'false'.");
|
2007-03-26 12:16:57 +00:00
|
|
|
throw new FatalException(msg.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2007-11-21 16:14:40 +00:00
|
|
|
class IntegerRangeOptionHandler : public NameMatchOptionHandler {
|
|
|
|
private:
|
|
|
|
int32_t _min;
|
|
|
|
int32_t _max;
|
|
|
|
public:
|
2008-02-08 15:53:45 +00:00
|
|
|
IntegerRangeOptionHandler(const std::string& optName, int32_t min, int32_t max):NameMatchOptionHandler(optName), _min(min), _max(max) {}
|
2007-11-21 16:14:40 +00:00
|
|
|
|
|
|
|
virtual ~IntegerRangeOptionHandler() {}
|
|
|
|
|
2008-02-08 15:53:45 +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) {
|
2008-02-08 15:53:45 +00:00
|
|
|
std::string msg = _optName+" "+_("must be between %s and %s.");
|
2008-02-24 09:43:31 +00:00
|
|
|
throw new FatalException(msg.c_str(), Util::itos(_min).c_str(), Util::itos(_max).c_str());
|
2007-11-21 16:14:40 +00:00
|
|
|
}
|
|
|
|
option->put(_optName, optarg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2007-03-26 12:16:57 +00:00
|
|
|
class NumberOptionHandler : public NameMatchOptionHandler {
|
|
|
|
private:
|
|
|
|
int64_t _min;
|
|
|
|
int64_t _max;
|
|
|
|
public:
|
2008-02-08 15:53:45 +00:00
|
|
|
NumberOptionHandler(const std::string& optName, int64_t min = -1, int64_t max = -1):NameMatchOptionHandler(optName), _min(min), _max(max) {}
|
2007-03-26 12:16:57 +00:00
|
|
|
|
|
|
|
virtual ~NumberOptionHandler() {}
|
|
|
|
|
2008-02-08 15:53:45 +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);
|
|
|
|
}
|
|
|
|
|
|
|
|
void parseArg(Option* option, int64_t number)
|
|
|
|
{
|
|
|
|
if((_min == -1 || _min <= number) && (_max == -1 || number <= _max)) {
|
2008-02-24 09:43:31 +00:00
|
|
|
option->put(_optName, Util::itos(number));
|
2007-03-26 12:16:57 +00:00
|
|
|
} else {
|
2008-02-08 15:53:45 +00:00
|
|
|
std::string msg = _optName+" ";
|
2007-03-26 12:16:57 +00:00
|
|
|
if(_min == -1 && _max != -1) {
|
2007-07-23 13:04:48 +00:00
|
|
|
msg += _("must be smaller than or equal to %s.");
|
2008-02-24 09:43:31 +00:00
|
|
|
throw new FatalException(msg.c_str(), Util::itos(_max).c_str());
|
2007-03-26 12:16:57 +00:00
|
|
|
} else if(_min != -1 && _max != -1) {
|
2007-07-23 13:04:48 +00:00
|
|
|
msg += _("must be between %s and %s.");
|
2008-02-24 09:43:31 +00:00
|
|
|
throw new FatalException(msg.c_str(), Util::itos(_min).c_str(), Util::itos(_max).c_str());
|
2007-03-26 12:16:57 +00:00
|
|
|
} else if(_min != -1 && _max == -1) {
|
2007-07-23 13:04:48 +00:00
|
|
|
msg += _("must be greater than or equal to %s.");
|
2008-02-24 09:43:31 +00:00
|
|
|
throw new FatalException(msg.c_str(), Util::itos(_min).c_str());
|
2007-03-26 12:16:57 +00:00
|
|
|
} else {
|
|
|
|
msg += _("must be a number.");
|
|
|
|
throw new FatalException(msg.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class UnitNumberOptionHandler : public NumberOptionHandler {
|
|
|
|
public:
|
2008-02-08 15:53:45 +00:00
|
|
|
UnitNumberOptionHandler(const std::string& optName, int64_t min = -1, int64_t max = -1):NumberOptionHandler(optName, min, max) {}
|
2007-03-26 12:16:57 +00:00
|
|
|
|
|
|
|
virtual ~UnitNumberOptionHandler() {}
|
|
|
|
|
2008-02-08 15:53:45 +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-02-08 15:53:45 +00:00
|
|
|
FloatNumberOptionHandler(const std::string& optName, double min = -1, double max = -1):NameMatchOptionHandler(optName), _min(min), _max(max) {}
|
2007-03-26 12:16:57 +00:00
|
|
|
|
|
|
|
virtual ~FloatNumberOptionHandler() {}
|
|
|
|
|
2008-02-08 15:53:45 +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)) {
|
|
|
|
option->put(_optName, optarg);
|
|
|
|
} else {
|
2008-02-08 15:53:45 +00:00
|
|
|
std::string msg = _optName+" ";
|
2007-03-26 12:16:57 +00:00
|
|
|
if(_min < 0 && _max >= 0) {
|
|
|
|
msg += _("must be smaller than or equal to %.1f.");
|
|
|
|
throw new FatalException(msg.c_str(), _max);
|
|
|
|
} else if(_min >= 0 && _max >= 0) {
|
|
|
|
msg += _("must be between %.1f and %.1f.");
|
|
|
|
throw new FatalException(msg.c_str(), _min, _max);
|
|
|
|
} else if(_min >= 0 && _max < 0) {
|
|
|
|
msg += _("must be greater than or equal to %.1f.");
|
|
|
|
throw new FatalException(msg.c_str(), _min);
|
|
|
|
} else {
|
|
|
|
msg += _("must be a number.");
|
|
|
|
throw new FatalException(msg.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class DefaultOptionHandler : public NameMatchOptionHandler {
|
|
|
|
public:
|
2008-02-08 15:53:45 +00:00
|
|
|
DefaultOptionHandler(const std::string& optName):NameMatchOptionHandler(optName) {}
|
2007-03-26 12:16:57 +00:00
|
|
|
|
|
|
|
virtual ~DefaultOptionHandler() {}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
virtual void parseArg(Option* option, const std::string& optarg)
|
2007-03-26 12:16:57 +00:00
|
|
|
{
|
|
|
|
option->put(_optName, optarg);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
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-02-08 15:53:45 +00:00
|
|
|
ParameterOptionHandler(const std::string& optName, const std::deque<std::string>& validParamValues):
|
2007-03-26 12:16:57 +00:00
|
|
|
NameMatchOptionHandler(optName), _validParamValues(validParamValues) {}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
ParameterOptionHandler(const std::string& optName, const std::string& validParamValue):
|
2007-03-26 12:16:57 +00:00
|
|
|
NameMatchOptionHandler(optName)
|
|
|
|
{
|
|
|
|
_validParamValues.push_back(validParamValue);
|
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
ParameterOptionHandler(const std::string& optName,
|
|
|
|
const std::string& validParamValue1,
|
|
|
|
const std::string& validParamValue2):
|
2007-03-26 12:16:57 +00:00
|
|
|
NameMatchOptionHandler(optName)
|
|
|
|
{
|
|
|
|
_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,
|
|
|
|
const std::string& validParamValue1,
|
|
|
|
const std::string& validParamValue2,
|
|
|
|
const std::string& validParamValue3):
|
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
|
|
|
NameMatchOptionHandler(optName)
|
|
|
|
{
|
|
|
|
_validParamValues.push_back(validParamValue1);
|
|
|
|
_validParamValues.push_back(validParamValue2);
|
|
|
|
_validParamValues.push_back(validParamValue3);
|
|
|
|
}
|
2007-03-26 12:16:57 +00:00
|
|
|
|
|
|
|
virtual ~ParameterOptionHandler() {}
|
|
|
|
|
2008-02-08 15:53:45 +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()) {
|
2008-02-08 15:53:45 +00:00
|
|
|
std::string msg = _optName+" "+_("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) {
|
|
|
|
msg += "'"+*itr+"' ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
throw new FatalException(msg.c_str());
|
|
|
|
} else {
|
|
|
|
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
|
|
|
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,
|
|
|
|
const std::string& hostOptionName,
|
|
|
|
const std::string& portOptionName):
|
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
|
|
|
NameMatchOptionHandler(optName),
|
|
|
|
_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
|
|
|
|
2008-02-08 15:53:45 +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) {
|
2007-03-26 12:16:57 +00:00
|
|
|
throw new FatalException(_("unrecognized proxy format"));
|
|
|
|
}
|
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
|
|
|
option->put(_optName, optarg);
|
|
|
|
setHostAndPort(option, proxy.first, port);
|
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +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
|
|
|
{
|
|
|
|
option->put(_hostOptionName, hostname);
|
|
|
|
option->put(_portOptionName, Util::uitos(port));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class HttpProxyOptionHandler : public HostPortOptionHandler {
|
|
|
|
public:
|
2008-02-08 15:53:45 +00:00
|
|
|
HttpProxyOptionHandler(const std::string& optName,
|
|
|
|
const std::string& hostOptionName,
|
|
|
|
const std::string& portOptionName):
|
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
|
|
|
HostPortOptionHandler(optName, hostOptionName, portOptionName) {}
|
|
|
|
|
|
|
|
virtual ~HttpProxyOptionHandler() {}
|
|
|
|
|
2008-02-08 15:53:45 +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
|
|
|
{
|
|
|
|
HostPortOptionHandler::parseArg(option, optarg);
|
2007-03-26 12:16:57 +00:00
|
|
|
option->put(PREF_HTTP_PROXY_ENABLED, V_TRUE);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class LogOptionHandler : public NameMatchOptionHandler {
|
|
|
|
public:
|
2008-02-08 15:53:45 +00:00
|
|
|
LogOptionHandler(const std::string& optName):NameMatchOptionHandler(optName) {}
|
2007-03-26 12:16:57 +00:00
|
|
|
|
|
|
|
virtual ~LogOptionHandler() {}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
virtual void parseArg(Option* option, const std::string& optarg)
|
2007-03-26 12:16:57 +00:00
|
|
|
{
|
|
|
|
if("-" == optarg) {
|
|
|
|
option->put(PREF_STDOUT_LOG, V_TRUE);
|
|
|
|
} else {
|
|
|
|
option->put(PREF_LOG, optarg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
} // namespace aria2
|
|
|
|
|
2007-03-26 12:16:57 +00:00
|
|
|
#endif // _D_OPTION_HANDLER_IMPL_H_
|