2009-12-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Added --disable-ipv6 option to disable IPv6.
	* doc/aria2c.1.txt
	* src/InitiateConnectionCommand.cc
	* src/NameResolver.cc
	* src/NameResolver.h
	* src/OptionHandlerFactory.cc
	* src/main.cc
	* src/prefs.cc
	* src/prefs.h
	* src/usage_text.h
pull/1/head
Tatsuhiro Tsujikawa 2009-12-05 07:10:23 +00:00
parent a7709947f2
commit 4100ba77c3
12 changed files with 70 additions and 7 deletions

View File

@ -1,3 +1,16 @@
2009-12-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added --disable-ipv6 option to disable IPv6.
* doc/aria2c.1.txt
* src/InitiateConnectionCommand.cc
* src/NameResolver.cc
* src/NameResolver.h
* src/OptionHandlerFactory.cc
* src/main.cc
* src/prefs.cc
* src/prefs.h
* src/usage_text.h
2009-12-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Updated usage text for --bt-prioritize-piece option.

View File

@ -881,6 +881,12 @@ and standard input, standard output and standard error will be redirected to
\fIfalse\fR
.RE
.PP
\fB\-\-disable\-ipv6\fR[=\fItrue\fR|\fIfalse\fR]
.RS 4
Disable IPv6\&. This is useful if you have to use broken DNS and want to avoid terribly slow AAAA record lookup\&. Default:
\fIfalse\fR
.RE
.PP
\fB\-\-enable\-direct\-io\fR[=\fItrue\fR|\fIfalse\fR]
.RS 4
Enable directI/O, which lowers cpu usage while allocating/checking files\&. Turn off if you encounter any error\&. Default:
@ -937,7 +943,7 @@ Bind sockets to given interface\&. You can specify interface name, IP address an
.ps -1
.br
.sp
If an interface has multiple addresses, it is highly recommended to specify IP address explicitly\&.
If an interface has multiple addresses, it is highly recommended to specify IP address explicitly\&. See also \fB\-\-disable\-ipv6\fR\&.
.sp .5v
.RE
.PP

View File

@ -1685,6 +1685,15 @@ writes the piece to the appropriate files.</td>
</p>
</dd>
<dt class="hdlist1">
<strong>--disable-ipv6</strong>[=<em>true</em>|<em>false</em>]
</dt>
<dd>
<p>
Disable IPv6. This is useful if you have to use broken DNS and want
to avoid terribly slow AAAA record lookup. Default: <em>false</em>
</p>
</dd>
<dt class="hdlist1">
<strong>--enable-direct-io</strong>[=<em>true</em>|<em>false</em>]
</dt>
<dd>
@ -1744,7 +1753,7 @@ writes the piece to the appropriate files.</td>
<div class="title">Note</div>
</td>
<td class="content">If an interface has multiple addresses, it is highly recommended to specify
IP address explicitly.</td>
IP address explicitly. See also <strong>--disable-ipv6</strong>.</td>
</tr></table>
</div>
<div class="dlist"><dl>
@ -3448,7 +3457,7 @@ files in the program, then also delete it here.</p></div>
<div id="footnotes"><hr /></div>
<div id="footer">
<div id="footer-text">
Last updated 2009-12-05 15:42:10 JST
Last updated 2009-12-05 16:08:32 JST
</div>
</div>
</body>

View File

@ -608,6 +608,11 @@ Advanced Options
and standard input, standard output and standard error will be
redirected to '/dev/null'. Default: 'false'
*--disable-ipv6*[='true'|'false']::
Disable IPv6. This is useful if you have to use broken DNS and want
to avoid terribly slow AAAA record lookup. Default: 'false'
*--enable-direct-io*[='true'|'false']::
Enable directI/O, which lowers cpu usage while allocating/checking files.
Turn off if you encounter any error.
@ -645,7 +650,7 @@ Advanced Options
[NOTE]
If an interface has multiple addresses, it is highly recommended to specify
IP address explicitly.
IP address explicitly. See also *--disable-ipv6*.
*--log-level*=LEVEL::
Set log level to output.

View File

@ -98,6 +98,9 @@ bool InitiateConnectionCommand::executeInternal() {
{
NameResolver res;
res.setSocktype(SOCK_STREAM);
if(e->option->getAsBool(PREF_DISABLE_IPV6)) {
res.setFamily(AF_INET);
}
res.resolve(addrs, hostname);
}
logger->info(MSG_NAME_RESOLUTION_COMPLETE, cuid,

View File

@ -33,15 +33,17 @@
*/
/* copyright --> */
#include "NameResolver.h"
#include <cstring>
#include "DlAbortEx.h"
#include "message.h"
#include "StringFormat.h"
#include "util.h"
#include <cstring>
namespace aria2 {
NameResolver::NameResolver():_socktype(0) {}
NameResolver::NameResolver():_socktype(0), _family(AF_UNSPEC) {}
void NameResolver::resolve(std::deque<std::string>& resolvedAddresses,
const std::string& hostname)
@ -49,7 +51,7 @@ void NameResolver::resolve(std::deque<std::string>& resolvedAddresses,
struct addrinfo hints;
struct addrinfo* res;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_family = _family;
hints.ai_socktype = _socktype;
hints.ai_flags = 0;
hints.ai_protocol = 0;

View File

@ -44,6 +44,7 @@ namespace aria2 {
class NameResolver {
private:
int _socktype;
int _family;
public:
NameResolver();
@ -55,6 +56,12 @@ public:
// specify SOCK_STREAM or SOCK_DGRAM
void setSocktype(int socktype);
// specify protocol family
void setFamily(int family)
{
_family = family;
}
};
} // namespace aria2

View File

@ -153,6 +153,15 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
op->addTag(TAG_FILE);
handlers.push_back(op);
}
{
SharedHandle<OptionHandler> op(new BooleanOptionHandler
(PREF_DISABLE_IPV6,
TEXT_DISABLE_IPV6,
V_FALSE,
OptionHandler::OPT_ARG));
op->addTag(TAG_ADVANCED);
handlers.push_back(op);
}
{
SharedHandle<NumberOptionHandler> op(new NumberOptionHandler
(PREF_DNS_TIMEOUT,

View File

@ -208,6 +208,9 @@ downloadresultcode::RESULT main(int argc, char* argv[])
MessageDigestHelper::staticSHA1DigestInit();
#endif // ENABLE_MESSAGE_DIGEST
if(op->getAsBool(PREF_DISABLE_IPV6)) {
SocketCore::setProtocolFamily(AF_INET);
}
// Bind interface
if(!op->get(PREF_INTERFACE).empty()) {
std::string interface = op->get(PREF_INTERFACE);

View File

@ -174,6 +174,8 @@ const std::string PREF_ON_DOWNLOAD_ERROR("on-download-error");
const std::string PREF_XML_RPC_LISTEN_ALL("xml-rpc-listen-all");
// value: string
const std::string PREF_INTERFACE("interface");
// value: true | false
const std::string PREF_DISABLE_IPV6("disable-ipv6");
/**
* FTP related preferences

View File

@ -178,6 +178,8 @@ extern const std::string PREF_ON_DOWNLOAD_ERROR;
extern const std::string PREF_XML_RPC_LISTEN_ALL;
// value: string
extern const std::string PREF_INTERFACE;
// value: true | false
extern const std::string PREF_DISABLE_IPV6;
/**
* FTP related preferences

View File

@ -579,3 +579,5 @@ _(" --bt-prioritize-piece=head[=SIZE],tail[=SIZE] Try to download first and last
#define TEXT_INTERFACE \
_(" --interface=INTERFACE Bind sockets to given interface. You can specify\n"\
" interface name, IP address and hostname.")
#define TEXT_DISABLE_IPV6 \
_(" --disable-ipv6[=true|false] Disable IPv6.")