2006-08-11 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

To add asynchronous DNS support(libares):

	* src/AbstractCommand.h
	(setNameResolverCheck): New function.
	(disableNameResolverCheck): New function
	(resolveHostname): New function.
	* src/AbstractCommand.cc
	(setNameResolverCheck): New function.
	(disableNameResolverCheck): New function
	(resolveHostname): New function.
	* src/FtpInitiateConnectionCommand.h
	(nameResolver): New function.
	* src/FtpInitiateConnectionCommand.cc
	(Util.h): Included.
	(FtpInitiateConnectionCommand): Call disableReadCheckSocket,
	disableWriteCheckSocket.
	(~FtpInitiateConnectionCommand): Call disableNameResolverCheck.
	(executeInternal): Added async DNS support.
	* src/HttpInitiateConnectionCommand.h
	(nameResolver): New function.
	* src/HttpInitiateConnectionCommand.cc
	(DlRetryEx.h): Included.
	(HttpInitiateConnectionCommand): Call disableReadCheckSocket,
	disableWriteCheckSocket.
	(~HttpInitiateConnectionCommand): Call disableNameResolverCheck.
	(executeInternal): Added async DNS support.
	* src/NameResolver.h: New class. Note: #include <ares.h> is 
surrounded
	by extern "C" declaration.
	* src/NameResolver.cc: New class.
	* src/Util.h:
	(isNumberAndDotsNotation): New function
	* src/Util.cc
	(isNumberAndDotsNotation): New function.
	* src/DownloadEngine.h
	(NameResolver.h): Included.
	(NameResolverEntry): New class.
	(NameResolverEntries): New type definition.
	(addNameResolverCheck): New function.
	(deleteNameResolverCheck): New function.
	* src/DownloadEngine.cc
	(run): Initialize cp with 0.
	(SetDescriptor::operator()): Added for NameResolverEntry.
	(AccumulateActiveUuid::operator()): Added for NameResolverEntry.
	(waitData): Check nameResolver entries.
	(updateFdSet): Update fds in nameResolver entries.
	(addNameResolverCheck): New function.
	(deleteNameResolverCheck): new function.
	
	* src/PeerInteractionCommand.cc
	(executeInternal): Fixed wrong socket handling.

	* src/main.cc
	(main): Fixed the initial value of PREF_LOWEST_SPEED_LIMIT 
option to 0.

	* src/Util.cc
	(fileChecksum): Removed the call to ctx.digestReset().
pull/1/head
Tatsuhiro Tsujikawa 2006-08-11 12:29:55 +00:00
parent 7ca1b43edd
commit f2d4faad08
27 changed files with 703 additions and 66 deletions

View File

@ -1,3 +1,62 @@
2006-08-11 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add asynchronous DNS support(libares):
* src/AbstractCommand.h
(setNameResolverCheck): New function.
(disableNameResolverCheck): New function
(resolveHostname): New function.
* src/AbstractCommand.cc
(setNameResolverCheck): New function.
(disableNameResolverCheck): New function
(resolveHostname): New function.
* src/FtpInitiateConnectionCommand.h
(nameResolver): New function.
* src/FtpInitiateConnectionCommand.cc
(Util.h): Included.
(FtpInitiateConnectionCommand): Call disableReadCheckSocket,
disableWriteCheckSocket.
(~FtpInitiateConnectionCommand): Call disableNameResolverCheck.
(executeInternal): Added async DNS support.
* src/HttpInitiateConnectionCommand.h
(nameResolver): New function.
* src/HttpInitiateConnectionCommand.cc
(DlRetryEx.h): Included.
(HttpInitiateConnectionCommand): Call disableReadCheckSocket,
disableWriteCheckSocket.
(~HttpInitiateConnectionCommand): Call disableNameResolverCheck.
(executeInternal): Added async DNS support.
* src/NameResolver.h: New class. Note: #include <ares.h> is surrounded
by extern "C" declaration.
* src/NameResolver.cc: New class.
* src/Util.h:
(isNumberAndDotsNotation): New function
* src/Util.cc
(isNumberAndDotsNotation): New function.
* src/DownloadEngine.h
(NameResolver.h): Included.
(NameResolverEntry): New class.
(NameResolverEntries): New type definition.
(addNameResolverCheck): New function.
(deleteNameResolverCheck): New function.
* src/DownloadEngine.cc
(run): Initialize cp with 0.
(SetDescriptor::operator()): Added for NameResolverEntry.
(AccumulateActiveUuid::operator()): Added for NameResolverEntry.
(waitData): Check nameResolver entries.
(updateFdSet): Update fds in nameResolver entries.
(addNameResolverCheck): New function.
(deleteNameResolverCheck): new function.
* src/PeerInteractionCommand.cc
(executeInternal): Fixed wrong socket handling.
* src/main.cc
(main): Fixed the initial value of PREF_LOWEST_SPEED_LIMIT option to 0.
* src/Util.cc
(fileChecksum): Removed the call to ctx.digestReset().
2006-08-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* po/ru.po: Azamat sent me Russian translation.
@ -173,6 +232,7 @@
class: stdoutLog, logfile, dir, ufilename, split, daemonMode,
referer, torrentFile, metalinkFile, listenPort, metalinkVersion,
metalinkLanguage, metalinkOs, metalinkServers
To fix the bug that aria2 can not handle http response header properly.
* src/HttpHeader.cc

View File

@ -49,11 +49,11 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \
$(top_srcdir)/m4/inttypes-pri.m4 $(top_srcdir)/m4/inttypes.m4 \
$(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/nls.m4 \
$(top_srcdir)/m4/openssl.m4 $(top_srcdir)/m4/po.m4 \
$(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/stdint_h.m4 \
$(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/ulonglong.m4 \
$(top_srcdir)/configure.ac
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libares.m4 \
$(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/openssl.m4 \
$(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
$(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \
$(top_srcdir)/m4/ulonglong.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
@ -121,6 +121,8 @@ EXEEXT = @EXEEXT@
GENCAT = @GENCAT@
GLIBC21 = @GLIBC21@
GMSGFMT = @GMSGFMT@
HAVE_LIBARES_FALSE = @HAVE_LIBARES_FALSE@
HAVE_LIBARES_TRUE = @HAVE_LIBARES_TRUE@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
@ -131,6 +133,8 @@ INTLLIBS = @INTLLIBS@
INTLOBJS = @INTLOBJS@
INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@
LDFLAGS = @LDFLAGS@
LIBARES_CPPFLAGS = @LIBARES_CPPFLAGS@
LIBARES_LIBS = @LIBARES_LIBS@
LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@

1
TODO
View File

@ -12,4 +12,3 @@
* Query resource by location
* List available os, version, etc for metalink
* ipv6(RFC2428 for ftp)
* async DNS using ares or c-ares

1
aclocal.m4 vendored
View File

@ -1400,6 +1400,7 @@ m4_include([m4/lcmessage.m4])
m4_include([m4/lib-ld.m4])
m4_include([m4/lib-link.m4])
m4_include([m4/lib-prefix.m4])
m4_include([m4/libares.m4])
m4_include([m4/nls.m4])
m4_include([m4/openssl.m4])
m4_include([m4/po.m4])

View File

@ -105,6 +105,9 @@
/* Define if your <locale.h> file defines LC_MESSAGES. */
#undef HAVE_LC_MESSAGES
/* Define to 1 if you have libares. */
#undef HAVE_LIBARES
/* Define to 1 if you have libgcrypt. */
#undef HAVE_LIBGCRYPT

164
configure vendored
View File

@ -311,7 +311,7 @@ ac_includes_default="\
# include <unistd.h>
#endif"
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CPPUNIT_CONFIG CPPUNIT_CFLAGS CPPUNIT_LIBS localedir CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CC CFLAGS ac_ct_CC CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE RANLIB ac_ct_RANLIB YACC XML2_CONFIG XML_CPPFLAGS XML_LIBS LIBGNUTLS_CONFIG LIBGNUTLS_CFLAGS LIBGNUTLS_LIBS LIBGCRYPT_CONFIG LIBGCRYPT_CFLAGS LIBGCRYPT_LIBS OPENSSL_LIBS OPENSSL_CFLAGS ENABLE_BITTORRENT_TRUE ENABLE_BITTORRENT_FALSE ENABLE_METALINK_TRUE ENABLE_METALINK_FALSE ALLOCA CPP EGREP MKINSTALLDIRS USE_NLS MSGFMT GMSGFMT XGETTEXT MSGMERGE build build_cpu build_vendor build_os host host_cpu host_vendor host_os GLIBC21 LIBICONV LTLIBICONV INTLBISON BUILD_INCLUDED_LIBINTL USE_INCLUDED_LIBINTL CATOBJEXT DATADIRNAME INSTOBJEXT GENCAT INTLOBJS INTL_LIBTOOL_SUFFIX_PREFIX INTLLIBS LIBINTL LTLIBINTL POSUB LIBOBJS LTLIBOBJS'
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CPPUNIT_CONFIG CPPUNIT_CFLAGS CPPUNIT_LIBS localedir CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CC CFLAGS ac_ct_CC CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE RANLIB ac_ct_RANLIB YACC XML2_CONFIG XML_CPPFLAGS XML_LIBS LIBGNUTLS_CONFIG LIBGNUTLS_CFLAGS LIBGNUTLS_LIBS LIBGCRYPT_CONFIG LIBGCRYPT_CFLAGS LIBGCRYPT_LIBS OPENSSL_LIBS OPENSSL_CFLAGS LIBARES_LIBS LIBARES_CPPFLAGS ENABLE_BITTORRENT_TRUE ENABLE_BITTORRENT_FALSE ENABLE_METALINK_TRUE ENABLE_METALINK_FALSE HAVE_LIBARES_TRUE HAVE_LIBARES_FALSE ALLOCA CPP EGREP MKINSTALLDIRS USE_NLS MSGFMT GMSGFMT XGETTEXT MSGMERGE build build_cpu build_vendor build_os host host_cpu host_vendor host_os GLIBC21 LIBICONV LTLIBICONV INTLBISON BUILD_INCLUDED_LIBINTL USE_INCLUDED_LIBINTL CATOBJEXT DATADIRNAME INSTOBJEXT GENCAT INTLOBJS INTL_LIBTOOL_SUFFIX_PREFIX INTLLIBS LIBINTL LTLIBINTL POSUB LIBOBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@ -877,12 +877,14 @@ Optional Packages:
--with-gnutls use gnutls library if installed. Default: yes
--with-openssl use openssl library if installed. Default: yes
--with-libxml2 use libxml2 library if installed. Default: yes
--with-ares use ares library if installed. Default: yes
--with-xml-prefix=PFX Prefix where libxml is installed (optional)
--with-xml-exec-prefix=PFX Exec prefix where libxml is installed (optional)
--with-libgnutls-prefix=PFX Prefix where libgnutls is installed (optional)
--with-libgcrypt-prefix=PFX
prefix where LIBGCRYPT is installed (optional)
--with-openssl-prefix=PREFIX Prefix where OpenSSL installed (optional)
--with-libares-prefix=PREFIX Prefix where libares installed (optional)
--with-gnu-ld assume the C compiler uses GNU ld default=no
--with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib
--without-libiconv-prefix don't search for libiconv in includedir and libdir
@ -1948,6 +1950,14 @@ else
with_libxml2=yes
fi;
# Check whether --with-ares or --without-ares was given.
if test "${with_ares+set}" = set; then
withval="$with_ares"
with_libares=$withval
else
with_libares=yes
fi;
# Check whether --enable-bittorrent or --disable-bittorrent was given.
if test "${enable_bittorrent+set}" = set; then
enableval="$enable_bittorrent"
@ -4620,6 +4630,115 @@ _ACEOF
fi
fi
LIBS=$LIBS_save
CPPFLAGS=$CPPFLAGS_save
fi
if test "x$with_libares" = "xyes"; then
# Check whether --with-libares-prefix or --without-libares-prefix was given.
if test "${with_libares_prefix+set}" = set; then
withval="$with_libares_prefix"
libares_prefix=$withval
else
libares_prefix=""
fi;
if test "x$libares_prefix" = "x"; then
libares_prefix="/usr/local"
fi
libares_prefix_lib=$libares_prefix/lib
libares_prefix_include=$libares_prefix/include
LIBS_save=$LIBS
CPPFLAGS_save=$CPPFLAGS
LIBS="-L$libares_prefix_lib $LIBS"
CPPFLAGS="-I$libares_prefix_include $CPPFLAGS"
echo "$as_me:$LINENO: checking for ares_init in -lares" >&5
echo $ECHO_N "checking for ares_init in -lares... $ECHO_C" >&6
if test "${ac_cv_lib_ares_ares_init+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lares $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char ares_init ();
int
main ()
{
ares_init ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_lib_ares_ares_init=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_ares_ares_init=no
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:$LINENO: result: $ac_cv_lib_ares_ares_init" >&5
echo "${ECHO_T}$ac_cv_lib_ares_ares_init" >&6
if test $ac_cv_lib_ares_ares_init = yes; then
have_libares=yes
fi
if test "x$have_libares" = "xyes"; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_LIBARES 1
_ACEOF
LIBARES_LIBS="-L$libares_prefix_lib -lares"
LIBARES_CPPFLAGS="-I$libares_prefix_include"
fi
LIBS=$LIBS_save
CPPFLAGS=$CPPFLAGS_save
@ -4701,6 +4820,30 @@ fi
fi
if test "x$have_libares" = "xyes"; then
if true; then
HAVE_LIBARES_TRUE=
HAVE_LIBARES_FALSE='#'
else
HAVE_LIBARES_TRUE='#'
HAVE_LIBARES_FALSE=
fi
else
if false; then
HAVE_LIBARES_TRUE=
HAVE_LIBARES_FALSE='#'
else
HAVE_LIBARES_TRUE='#'
HAVE_LIBARES_FALSE=
fi
fi
# Checks for header files.
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
@ -5308,6 +5451,7 @@ _ACEOF
fi
#AC_HEADER_STDC
echo "$as_me:$LINENO: checking for ANSI C header files" >&5
echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
if test "${ac_cv_header_stdc+set}" = set; then
@ -11672,6 +11816,20 @@ echo "$as_me: error: conditional \"ENABLE_METALINK\" was never defined.
Usually this means the macro was only invoked conditionally." >&2;}
{ (exit 1); exit 1; }; }
fi
if test -z "${HAVE_LIBARES_TRUE}" && test -z "${HAVE_LIBARES_FALSE}"; then
{ { echo "$as_me:$LINENO: error: conditional \"HAVE_LIBARES\" was never defined.
Usually this means the macro was only invoked conditionally." >&5
echo "$as_me: error: conditional \"HAVE_LIBARES\" was never defined.
Usually this means the macro was only invoked conditionally." >&2;}
{ (exit 1); exit 1; }; }
fi
if test -z "${HAVE_LIBARES_TRUE}" && test -z "${HAVE_LIBARES_FALSE}"; then
{ { echo "$as_me:$LINENO: error: conditional \"HAVE_LIBARES\" was never defined.
Usually this means the macro was only invoked conditionally." >&5
echo "$as_me: error: conditional \"HAVE_LIBARES\" was never defined.
Usually this means the macro was only invoked conditionally." >&2;}
{ (exit 1); exit 1; }; }
fi
: ${CONFIG_STATUS=./config.status}
ac_clean_files_save=$ac_clean_files
@ -12279,10 +12437,14 @@ s,@LIBGCRYPT_CFLAGS@,$LIBGCRYPT_CFLAGS,;t t
s,@LIBGCRYPT_LIBS@,$LIBGCRYPT_LIBS,;t t
s,@OPENSSL_LIBS@,$OPENSSL_LIBS,;t t
s,@OPENSSL_CFLAGS@,$OPENSSL_CFLAGS,;t t
s,@LIBARES_LIBS@,$LIBARES_LIBS,;t t
s,@LIBARES_CPPFLAGS@,$LIBARES_CPPFLAGS,;t t
s,@ENABLE_BITTORRENT_TRUE@,$ENABLE_BITTORRENT_TRUE,;t t
s,@ENABLE_BITTORRENT_FALSE@,$ENABLE_BITTORRENT_FALSE,;t t
s,@ENABLE_METALINK_TRUE@,$ENABLE_METALINK_TRUE,;t t
s,@ENABLE_METALINK_FALSE@,$ENABLE_METALINK_FALSE,;t t
s,@HAVE_LIBARES_TRUE@,$HAVE_LIBARES_TRUE,;t t
s,@HAVE_LIBARES_FALSE@,$HAVE_LIBARES_FALSE,;t t
s,@ALLOCA@,$ALLOCA,;t t
s,@CPP@,$CPP,;t t
s,@EGREP@,$EGREP,;t t

View File

@ -16,6 +16,7 @@ AC_SUBST(localedir)
AC_ARG_WITH([gnutls], [ --with-gnutls use gnutls library if installed. Default: yes], [with_gnutls=$withval], [with_gnutls=yes])
AC_ARG_WITH([openssl], [ --with-openssl use openssl library if installed. Default: yes], [with_openssl=$withval], [with_openssl=yes])
AC_ARG_WITH([libxml2], [ --with-libxml2 use libxml2 library if installed. Default: yes], [with_libxml2=$withval], [with_libxml2=yes])
AC_ARG_WITH([ares], [ --with-ares use ares library if installed. Default: yes], [with_libares=$withval], [with_libares=yes])
AC_ARG_ENABLE([bittorrent], [ --enable-bittorrent enable BitTorrent support. Default: yes], [enable_bittorrent=$enableval], [enable_bittorrent=yes])
AC_ARG_ENABLE([metalink], [ --enable-metalink enable Metalink support. Default: yes], [enable_metalink=$enableval], [enable_metalink=yes])
@ -53,6 +54,10 @@ if test "x$with_openssl" = "xyes" && test "x$have_libgnutls" != "xyes"; then
AM_PATH_OPENSSL
fi
if test "x$with_libares" = "xyes"; then
AM_PATH_LIBARES
fi
# Define variables based on the result of the checks for libraries.
if test "x$have_libgnutls" = "xyes" || test "x$have_openssl" = "xyes"; then
AC_DEFINE([ENABLE_SSL], [1], [Define to 1 if ssl support is enabled.])
@ -77,9 +82,15 @@ else
AM_CONDITIONAL([ENABLE_METALINK], false)
fi
if test "x$have_libares" = "xyes"; then
AM_CONDITIONAL([HAVE_LIBARES], true)
else
AM_CONDITIONAL([HAVE_LIBARES], false)
fi
# Checks for header files.
AC_FUNC_ALLOCA
AC_HEADER_STDC
#AC_HEADER_STDC
AC_CHECK_HEADERS([argz.h arpa/inet.h fcntl.h inttypes.h langinfo.h libintl.h limits.h locale.h malloc.h netdb.h netinet/in.h stddef.h stdint.h stdio_ext.h stdlib.h string.h strings.h sys/param.h sys/socket.h sys/time.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.

View File

@ -44,11 +44,11 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \
$(top_srcdir)/m4/inttypes-pri.m4 $(top_srcdir)/m4/inttypes.m4 \
$(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/nls.m4 \
$(top_srcdir)/m4/openssl.m4 $(top_srcdir)/m4/po.m4 \
$(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/stdint_h.m4 \
$(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/ulonglong.m4 \
$(top_srcdir)/configure.ac
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libares.m4 \
$(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/openssl.m4 \
$(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
$(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \
$(top_srcdir)/m4/ulonglong.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@ -95,6 +95,8 @@ EXEEXT = @EXEEXT@
GENCAT = @GENCAT@
GLIBC21 = @GLIBC21@
GMSGFMT = @GMSGFMT@
HAVE_LIBARES_FALSE = @HAVE_LIBARES_FALSE@
HAVE_LIBARES_TRUE = @HAVE_LIBARES_TRUE@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
@ -105,6 +107,8 @@ INTLLIBS = @INTLLIBS@
INTLOBJS = @INTLOBJS@
INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@
LDFLAGS = @LDFLAGS@
LIBARES_CPPFLAGS = @LIBARES_CPPFLAGS@
LIBARES_LIBS = @LIBARES_LIBS@
LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@

33
m4/libares.m4 Normal file
View File

@ -0,0 +1,33 @@
AC_DEFUN([AM_PATH_LIBARES],
[
AC_ARG_WITH([libares-prefix],
[ --with-libares-prefix=PREFIX Prefix where libares installed (optional)],
[libares_prefix=$withval],
[libares_prefix=""])
if test "x$libares_prefix" = "x"; then
libares_prefix="/usr/local"
fi
libares_prefix_lib=$libares_prefix/lib
libares_prefix_include=$libares_prefix/include
LIBS_save=$LIBS
CPPFLAGS_save=$CPPFLAGS
LIBS="-L$libares_prefix_lib $LIBS"
CPPFLAGS="-I$libares_prefix_include $CPPFLAGS"
AC_CHECK_LIB([ares], [ares_init], [have_libares=yes])
if test "x$have_libares" = "xyes"; then
AC_DEFINE([HAVE_LIBARES], [1], [Define to 1 if you have libares.])
LIBARES_LIBS="-L$libares_prefix_lib -lares"
LIBARES_CPPFLAGS="-I$libares_prefix_include"
AC_SUBST(LIBARES_LIBS)
AC_SUBST(LIBARES_CPPFLAGS)
fi
LIBS=$LIBS_save
CPPFLAGS=$CPPFLAGS_save
])

View File

@ -519,9 +519,12 @@ msgid ""
" value must be greater than or equal to\n"
" 1024. Default: 1M"
msgstr ""
" --min-segment-size=SIZE[K|M] 最小のセグメント・サイズを指定します. K または M\n"
" を付加することができます (1K = 1024, 1M = 1024K).\n"
" 1024 以上の値を指定してください. デフォルト値: 1M"
" --min-segment-size=SIZE[K|M] 最小のセグメント・サイズを指定します. K または "
"M\n"
" を付加することができます (1K = 1024, 1M = "
"1024K).\n"
" 1024 以上の値を指定してください. デフォルト値: "
"1M"
#: src/main.cc:126
msgid ""
@ -660,10 +663,14 @@ msgid ""
"download.\n"
" Default: 0"
msgstr ""
" --lowest-speed-limit ここで指定するダウンロード速度を下回った場合, ダ\n"
" ウンロードを中止します. 0 を指定すると, 速度の判\n"
" 定を行いません. K や M を --min-segment-size オプ\n"
" ションと同じ用法で使用できます. このオプションは,\n"
" --lowest-speed-limit ここで指定するダウンロード速度を下回った場合, "
"ダ\n"
" ウンロードを中止します. 0 を指定すると, 速度の"
"判\n"
" 定を行いません. K や M を --min-segment-size オ"
"プ\n"
" ションと同じ用法で使用できます. このオプション"
"は,\n"
" BitTorrent ダウンロードには影響しません.\n"
" デフォルト値: 0"

View File

@ -169,3 +169,34 @@ void AbstractCommand::setWriteCheckSocket(const SocketHandle& socket) {
}
}
}
#ifdef HAVE_LIBARES
void AbstractCommand::setNameResolverCheck(const NameResolverHandle& resolver) {
e->addNameResolverCheck(resolver, getUuid());
}
void AbstractCommand::disableNameResolverCheck(const NameResolverHandle& resolver) {
e->deleteNameResolverCheck(resolver, getUuid());
}
bool AbstractCommand::resolveHostname(const string& hostname,
const NameResolverHandle& resolver) {
switch(resolver->getStatus()) {
case NameResolver::STATUS_READY:
logger->info("CUID#%d - Resolving hostname %s", cuid, hostname.c_str());
resolver->resolve(hostname);
setNameResolverCheck(resolver);
return false;
case NameResolver::STATUS_SUCCESS:
logger->info("CUID#%d - Name resolution complete: %s -> %s", cuid,
hostname.c_str(), resolver->getAddrString().c_str());
return true;
break;
case NameResolver::STATUS_ERROR:
throw new DlRetryEx("CUID#%d - Name resolution failed:%s", cuid,
resolver->getError().c_str());
default:
return false;
}
}
#endif // HAVE_LIBARES

View File

@ -46,6 +46,11 @@ protected:
void setWriteCheckSocket(const SocketHandle& socket);
void disableReadCheckSocket();
void disableWriteCheckSocket();
#ifdef HAVE_LIBARES
void setNameResolverCheck(const NameResolverHandle& resolver);
void disableNameResolverCheck(const NameResolverHandle& resolver);
bool resolveHostname(const string& hostname, const NameResolverHandle& nameResolver);
#endif // HAVE_LIBARES
void setTimeout(int timeout) { this->timeout = timeout; }
private:
bool checkSocketIsReadable;

View File

@ -65,6 +65,7 @@ public:
void DownloadEngine::run() {
initStatistics();
Time cp;
cp.setTimeInSec(0);
CommandUuids activeUuids;
while(!commands.empty()) {
if(cp.elapsed(1)) {
@ -135,6 +136,14 @@ public:
*max_ptr = fd;
}
}
#ifdef HAVE_LIBARES
void operator()(const NameResolverEntry& entry) {
int tempFd = entry.nameResolver->getFds(rfds_ptr, wfds_ptr);
if(*max_ptr < tempFd) {
*max_ptr = tempFd;
}
}
#endif // HAVE_LIBARES
};
class AccumulateActiveUuid {
@ -170,6 +179,19 @@ public:
}
*/
}
#ifdef HAVE_LIBARES
void operator()(const NameResolverEntry& entry) {
entry.nameResolver->process(rfds_ptr, wfds_ptr);
switch(entry.nameResolver->getStatus()) {
case NameResolver::STATUS_SUCCESS:
case NameResolver::STATUS_ERROR:
activeUuids_ptr->push_back(entry.commandUuid);
break;
default:
break;
}
}
#endif // HAVE_LIBARES
};
void DownloadEngine::waitData(CommandUuids& activeUuids) {
@ -187,7 +209,10 @@ void DownloadEngine::waitData(CommandUuids& activeUuids) {
if(retval > 0) {
for_each(socketEntries.begin(), socketEntries.end(),
AccumulateActiveUuid(&activeUuids, &rfds, &wfds));
#ifdef HAVE_LIBARES
for_each(nameResolverEntries.begin(), nameResolverEntries.end(),
AccumulateActiveUuid(&activeUuids, &rfds, &wfds));
#endif // HAVE_LIBARES
sort(activeUuids.begin(), activeUuids.end());
activeUuids.erase(unique(activeUuids.begin(),
activeUuids.end()),
@ -199,6 +224,10 @@ void DownloadEngine::updateFdSet() {
fdmax = 0;
FD_ZERO(&rfdset);
FD_ZERO(&wfdset);
#ifdef HAVE_LIBARES
for_each(nameResolverEntries.begin(), nameResolverEntries.end(),
SetDescriptor(&fdmax, &rfdset, &wfdset));
#endif // HAVE_LIBARES
for_each(socketEntries.begin(), socketEntries.end(),
SetDescriptor(&fdmax, &rfdset, &wfdset));
}
@ -250,3 +279,35 @@ bool DownloadEngine::deleteSocketForWriteCheck(const SocketHandle& socket,
SocketEntry entry(socket, commandUuid, SocketEntry::TYPE_WR);
return deleteSocket(entry);
}
#ifdef HAVE_LIBARES
bool DownloadEngine::addNameResolverCheck(const NameResolverHandle& resolver,
const CommandUuid& uuid) {
NameResolverEntry entry(resolver, uuid);
NameResolverEntries::iterator itr = find(nameResolverEntries.begin(),
nameResolverEntries.end(),
entry);
if(itr == nameResolverEntries.end()) {
nameResolverEntries.push_back(entry);
updateFdSet();
return true;
} else {
return false;
}
}
bool DownloadEngine::deleteNameResolverCheck(const NameResolverHandle& resolver,
const CommandUuid& uuid) {
NameResolverEntry entry(resolver, uuid);
NameResolverEntries::iterator itr = find(nameResolverEntries.begin(),
nameResolverEntries.end(),
entry);
if(itr == nameResolverEntries.end()) {
return false;
} else {
nameResolverEntries.erase(itr);
updateFdSet();
return true;
}
}
#endif // HAVE_LIBARES

View File

@ -28,6 +28,9 @@
#include "common.h"
#include "Logger.h"
#include "Option.h"
#ifdef HAVE_LIBARES
# include "NameResolver.h"
#endif // HAVE_LIBARES
typedef deque<SocketHandle> Sockets;
typedef deque<Command*> Commands;
@ -59,10 +62,34 @@ public:
typedef deque<SocketEntry> SocketEntries;
#ifdef HAVE_LIBARES
class NameResolverEntry {
public:
NameResolverHandle nameResolver;
CommandUuid commandUuid;
public:
NameResolverEntry(const NameResolverHandle& nameResolver,
const CommandUuid& commandUuid):
nameResolver(nameResolver), commandUuid(commandUuid) {}
~NameResolverEntry() {}
bool operator==(const NameResolverEntry& entry) {
return nameResolver == entry.nameResolver &&
commandUuid == entry.commandUuid;
}
};
typedef deque<NameResolverEntry> NameResolverEntries;
#endif // HAVE_LIBARES
class DownloadEngine {
private:
void waitData(CommandUuids& activeUuids);
SocketEntries socketEntries;
#ifdef HAVE_LIBARES
NameResolverEntries nameResolverEntries;
#endif // HAVE_LIBARES
fd_set rfdset;
fd_set wfdset;
int fdmax;
@ -81,7 +108,7 @@ public:
Commands commands;
SegmentMan* segmentMan;
const Option* option;
DownloadEngine();
virtual ~DownloadEngine();
@ -99,7 +126,12 @@ public:
const CommandUuid& commandUuid);
bool deleteSocketForWriteCheck(const SocketHandle& socket,
const CommandUuid& command);
#ifdef HAVE_LIBARES
bool addNameResolverCheck(const NameResolverHandle& resolver,
const CommandUuid& uuid);
bool deleteNameResolverCheck(const NameResolverHandle& resolver,
const CommandUuid& uuid);
#endif // HAVE_LIBARES
};
#endif // _D_DOWNLOAD_ENGINE_H_

View File

@ -26,10 +26,22 @@
#include "DlAbortEx.h"
#include "message.h"
#include "prefs.h"
#include "Util.h"
FtpInitiateConnectionCommand::FtpInitiateConnectionCommand(int cuid, Request* req, DownloadEngine* e):AbstractCommand(cuid, req, e) {}
FtpInitiateConnectionCommand::FtpInitiateConnectionCommand(int cuid,
Request* req,
DownloadEngine* e)
:AbstractCommand(cuid, req, e)
{
disableReadCheckSocket();
disableWriteCheckSocket();
}
FtpInitiateConnectionCommand::~FtpInitiateConnectionCommand() {}
FtpInitiateConnectionCommand::~FtpInitiateConnectionCommand() {
#ifdef HAVE_LIBARES
disableNameResolverCheck(nameResolver);
#endif // HAVE_LIBARES
}
bool FtpInitiateConnectionCommand::executeInternal(Segment segment) {
if(!e->segmentMan->downloadStarted) {
@ -43,13 +55,28 @@ bool FtpInitiateConnectionCommand::executeInternal(Segment segment) {
e->segmentMan->diskWriter->initAndOpenFile(e->segmentMan->getFilePath());
}
}
string hostname;
if(useHttpProxy()) {
hostname = e->option->get(PREF_HTTP_PROXY_HOST);
} else {
hostname = req->getHost();
}
#ifdef HAVE_LIBARES
if(!Util::isNumbersAndDotsNotation(hostname)) {
if(resolveHostname(hostname, nameResolver)) {
hostname = nameResolver->getAddrString();
} else {
e->commands.push_back(this);
return false;
}
}
#endif // HAVE_LIBARES
Command* command;
if(useHttpProxy()) {
logger->info(MSG_CONNECTING_TO_SERVER, cuid,
e->option->get(PREF_HTTP_PROXY_HOST).c_str(),
e->option->getAsInt(PREF_HTTP_PROXY_PORT));
socket->establishConnection(e->option->get(PREF_HTTP_PROXY_HOST),
socket->establishConnection(hostname,
e->option->getAsInt(PREF_HTTP_PROXY_PORT));
if(useHttpProxyGet()) {
@ -63,7 +90,7 @@ bool FtpInitiateConnectionCommand::executeInternal(Segment segment) {
} else {
logger->info(MSG_CONNECTING_TO_SERVER, cuid, req->getHost().c_str(),
req->getPort());
socket->establishConnection(req->getHost(), req->getPort());
socket->establishConnection(hostname, req->getPort());
command = new FtpNegotiationCommand(cuid, req, e, socket);
}
e->commands.push_back(command);

View File

@ -26,6 +26,9 @@
class FtpInitiateConnectionCommand : public AbstractCommand {
private:
#ifdef HAVE_LIBARES
NameResolverHandle nameResolver;
#endif // HAVE_LIBARES
bool useHttpProxy() const;
bool useHttpProxyGet() const;
bool useHttpProxyConnect() const;

View File

@ -24,23 +24,48 @@
#include "HttpProxyRequestCommand.h"
#include "Util.h"
#include "DlAbortEx.h"
#include "DlRetryEx.h"
#include "message.h"
#include "prefs.h"
HttpInitiateConnectionCommand::HttpInitiateConnectionCommand(int cuid,
Request* req,
DownloadEngine* e):AbstractCommand(cuid, req, e) {}
DownloadEngine* e):
AbstractCommand(cuid, req, e)
{
disableReadCheckSocket();
disableWriteCheckSocket();
}
HttpInitiateConnectionCommand::~HttpInitiateConnectionCommand() {}
HttpInitiateConnectionCommand::~HttpInitiateConnectionCommand() {
#ifdef HAVE_LIBARES
disableNameResolverCheck(nameResolver);
#endif // HAVE_LIBARES
}
bool HttpInitiateConnectionCommand::executeInternal(Segment segment) {
// socket->establishConnection(...);
string hostname;
if(useProxy()) {
hostname = e->option->get(PREF_HTTP_PROXY_HOST);
} else {
hostname = req->getHost();
}
#ifdef HAVE_LIBARES
if(!Util::isNumbersAndDotsNotation(hostname)) {
if(resolveHostname(hostname, nameResolver)) {
hostname = nameResolver->getAddrString();
} else {
e->commands.push_back(this);
return false;
}
}
#endif // HAVE_LIBARES
Command* command;
if(useProxy()) {
logger->info(MSG_CONNECTING_TO_SERVER, cuid,
e->option->get(PREF_HTTP_PROXY_HOST).c_str(),
e->option->getAsInt(PREF_HTTP_PROXY_PORT));
socket->establishConnection(e->option->get(PREF_HTTP_PROXY_HOST),
socket->establishConnection(hostname,
e->option->getAsInt(PREF_HTTP_PROXY_PORT));
if(useProxyTunnel()) {
command = new HttpProxyRequestCommand(cuid, req, e, socket);
@ -53,7 +78,7 @@ bool HttpInitiateConnectionCommand::executeInternal(Segment segment) {
} else {
logger->info(MSG_CONNECTING_TO_SERVER, cuid, req->getHost().c_str(),
req->getPort());
socket->establishConnection(req->getHost(), req->getPort());
socket->establishConnection(hostname, req->getPort());
command = new HttpRequestCommand(cuid, req, e, socket);
}
e->commands.push_back(command);

View File

@ -26,6 +26,9 @@
class HttpInitiateConnectionCommand : public AbstractCommand {
private:
#ifdef HAVE_LIBARES
NameResolverHandle nameResolver;
#endif // HAVE_LIBARES
bool useProxy();
bool useProxyGet();
bool useProxyTunnel();

View File

@ -57,6 +57,10 @@ SRCS = Socket.h\
RequestInfo.h\
UrlRequestInfo.cc UrlRequestInfo.h
if HAVE_LIBARES
SRCS += NameResolver.cc NameResolver.h
endif # HAVE_LIBARES
if ENABLE_BITTORRENT
SRCS += MetaEntry.h\
Data.cc Data.h\
@ -127,9 +131,10 @@ endif # ENABLE_METALINK
noinst_LIBRARIES = libaria2c.a
libaria2c_a_SOURCES = $(SRCS)
aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\
@LIBGCRYPT_LIBS@ @OPENSSL_LIBS@ @XML_LIBS@
@LIBGCRYPT_LIBS@ @OPENSSL_LIBS@ @XML_LIBS@ @LIBARES_LIBS@
#aria2c_LDFLAGS = -pg
AM_CPPFLAGS = -Wall\
-I../lib -I../intl -I$(top_srcdir)/intl\
@LIBGNUTLS_CFLAGS@ @LIBGCRYPT_CFLAGS@ @OPENSSL_CFLAGS@ @XML_CPPFLAGS@\
-D_FILE_OFFSET_BITS=64 -DLOCALEDIR=\"$(localedir)\" @DEFS@# -pg
@LIBARES_CPPFLAGS@\
-D_FILE_OFFSET_BITS=64 -DLOCALEDIR=\"$(localedir)\" @DEFS@ # -pg

View File

@ -38,7 +38,8 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
bin_PROGRAMS = aria2c$(EXEEXT)
@ENABLE_BITTORRENT_TRUE@am__append_1 = MetaEntry.h\
@HAVE_LIBARES_TRUE@am__append_1 = NameResolver.cc NameResolver.h
@ENABLE_BITTORRENT_TRUE@am__append_2 = MetaEntry.h\
@ENABLE_BITTORRENT_TRUE@ Data.cc Data.h\
@ENABLE_BITTORRENT_TRUE@ Dictionary.cc Dictionary.h\
@ENABLE_BITTORRENT_TRUE@ List.cc List.h\
@ -94,7 +95,7 @@ bin_PROGRAMS = aria2c$(EXEEXT)
@ENABLE_BITTORRENT_TRUE@ HaveEraseCommand.cc HaveEraseCommand.h\
@ENABLE_BITTORRENT_TRUE@ TorrentRequestInfo.cc TorrentRequestInfo.h
@ENABLE_METALINK_TRUE@am__append_2 = Metalinker.cc Metalinker.h\
@ENABLE_METALINK_TRUE@am__append_3 = Metalinker.cc Metalinker.h\
@ENABLE_METALINK_TRUE@ MetalinkEntry.cc MetalinkEntry.h\
@ENABLE_METALINK_TRUE@ MetalinkResource.cc MetalinkResource.h\
@ENABLE_METALINK_TRUE@ MetalinkProcessor.h\
@ -110,11 +111,11 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \
$(top_srcdir)/m4/inttypes-pri.m4 $(top_srcdir)/m4/inttypes.m4 \
$(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/nls.m4 \
$(top_srcdir)/m4/openssl.m4 $(top_srcdir)/m4/po.m4 \
$(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/stdint_h.m4 \
$(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/ulonglong.m4 \
$(top_srcdir)/configure.ac
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libares.m4 \
$(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/openssl.m4 \
$(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
$(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \
$(top_srcdir)/m4/ulonglong.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@ -159,10 +160,11 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
LogFactory.cc LogFactory.h NullLogger.h TimeA2.cc TimeA2.h \
SharedHandle.h FeatureConfig.cc FeatureConfig.h \
DownloadEngineFactory.cc DownloadEngineFactory.h RequestInfo.h \
UrlRequestInfo.cc UrlRequestInfo.h MetaEntry.h Data.cc Data.h \
Dictionary.cc Dictionary.h List.cc List.h MetaFileUtil.cc \
MetaFileUtil.h MetaEntryVisitor.h ShaVisitor.cc ShaVisitor.h \
TorrentMan.cc TorrentMan.h PeerConnection.cc PeerConnection.h \
UrlRequestInfo.cc UrlRequestInfo.h NameResolver.cc \
NameResolver.h MetaEntry.h Data.cc Data.h Dictionary.cc \
Dictionary.h List.cc List.h MetaFileUtil.cc MetaFileUtil.h \
MetaEntryVisitor.h ShaVisitor.cc ShaVisitor.h TorrentMan.cc \
TorrentMan.h PeerConnection.cc PeerConnection.h \
PeerMessageUtil.cc PeerMessageUtil.h PeerAbstractCommand.cc \
PeerAbstractCommand.h PeerInitiateConnectionCommand.cc \
PeerInitiateConnectionCommand.h PeerInteractionCommand.cc \
@ -199,7 +201,8 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
MetalinkResource.cc MetalinkResource.h MetalinkProcessor.h \
Xml2MetalinkProcessor.cc Xml2MetalinkProcessor.h \
MetalinkRequestInfo.cc MetalinkRequestInfo.h
@ENABLE_BITTORRENT_TRUE@am__objects_1 = Data.$(OBJEXT) \
@HAVE_LIBARES_TRUE@am__objects_1 = NameResolver.$(OBJEXT)
@ENABLE_BITTORRENT_TRUE@am__objects_2 = Data.$(OBJEXT) \
@ENABLE_BITTORRENT_TRUE@ Dictionary.$(OBJEXT) List.$(OBJEXT) \
@ENABLE_BITTORRENT_TRUE@ MetaFileUtil.$(OBJEXT) \
@ENABLE_BITTORRENT_TRUE@ ShaVisitor.$(OBJEXT) \
@ -248,12 +251,12 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
@ENABLE_BITTORRENT_TRUE@ PeerMessageFactory.$(OBJEXT) \
@ENABLE_BITTORRENT_TRUE@ HaveEraseCommand.$(OBJEXT) \
@ENABLE_BITTORRENT_TRUE@ TorrentRequestInfo.$(OBJEXT)
@ENABLE_METALINK_TRUE@am__objects_2 = Metalinker.$(OBJEXT) \
@ENABLE_METALINK_TRUE@am__objects_3 = Metalinker.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ MetalinkEntry.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ MetalinkResource.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ Xml2MetalinkProcessor.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ MetalinkRequestInfo.$(OBJEXT)
am__objects_3 = SocketCore.$(OBJEXT) Command.$(OBJEXT) \
am__objects_4 = SocketCore.$(OBJEXT) Command.$(OBJEXT) \
AbstractCommand.$(OBJEXT) \
InitiateConnectionCommandFactory.$(OBJEXT) \
DownloadCommand.$(OBJEXT) \
@ -277,8 +280,9 @@ am__objects_3 = SocketCore.$(OBJEXT) Command.$(OBJEXT) \
File.$(OBJEXT) Option.$(OBJEXT) Base64.$(OBJEXT) \
CookieBox.$(OBJEXT) LogFactory.$(OBJEXT) TimeA2.$(OBJEXT) \
FeatureConfig.$(OBJEXT) DownloadEngineFactory.$(OBJEXT) \
UrlRequestInfo.$(OBJEXT) $(am__objects_1) $(am__objects_2)
am_libaria2c_a_OBJECTS = $(am__objects_3)
UrlRequestInfo.$(OBJEXT) $(am__objects_1) $(am__objects_2) \
$(am__objects_3)
am_libaria2c_a_OBJECTS = $(am__objects_4)
libaria2c_a_OBJECTS = $(am_libaria2c_a_OBJECTS)
am__installdirs = "$(DESTDIR)$(bindir)"
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
@ -341,6 +345,8 @@ EXEEXT = @EXEEXT@
GENCAT = @GENCAT@
GLIBC21 = @GLIBC21@
GMSGFMT = @GMSGFMT@
HAVE_LIBARES_FALSE = @HAVE_LIBARES_FALSE@
HAVE_LIBARES_TRUE = @HAVE_LIBARES_TRUE@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
@ -351,6 +357,8 @@ INTLLIBS = @INTLLIBS@
INTLOBJS = @INTLOBJS@
INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@
LDFLAGS = @LDFLAGS@
LIBARES_CPPFLAGS = @LIBARES_CPPFLAGS@
LIBARES_LIBS = @LIBARES_LIBS@
LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
@ -469,17 +477,18 @@ SRCS = Socket.h SocketCore.cc SocketCore.h Command.cc Command.h \
SharedHandle.h FeatureConfig.cc FeatureConfig.h \
DownloadEngineFactory.cc DownloadEngineFactory.h RequestInfo.h \
UrlRequestInfo.cc UrlRequestInfo.h $(am__append_1) \
$(am__append_2)
$(am__append_2) $(am__append_3)
noinst_LIBRARIES = libaria2c.a
libaria2c_a_SOURCES = $(SRCS)
aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\
@LIBGCRYPT_LIBS@ @OPENSSL_LIBS@ @XML_LIBS@
@LIBGCRYPT_LIBS@ @OPENSSL_LIBS@ @XML_LIBS@ @LIBARES_LIBS@
#aria2c_LDFLAGS = -pg
AM_CPPFLAGS = -Wall\
-I../lib -I../intl -I$(top_srcdir)/intl\
@LIBGNUTLS_CFLAGS@ @LIBGCRYPT_CFLAGS@ @OPENSSL_CFLAGS@ @XML_CPPFLAGS@\
-D_FILE_OFFSET_BITS=64 -DLOCALEDIR=\"$(localedir)\" @DEFS@# -pg
@LIBARES_CPPFLAGS@\
-D_FILE_OFFSET_BITS=64 -DLOCALEDIR=\"$(localedir)\" @DEFS@ # -pg
all: all-am
@ -611,6 +620,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Metalinker.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MultiDiskAdaptor.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MultiDiskWriter.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NameResolver.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NotInterestedMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Option.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Peer.Po@am__quote@

33
src/NameResolver.cc Normal file
View File

@ -0,0 +1,33 @@
/* <!-- copyright */
/*
* aria2 - a simple utility for downloading files faster
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* copyright --> */
#include "NameResolver.h"
void callback(void* arg, int status, struct hostent* host) {
NameResolver* resolverPtr = (NameResolver*)arg;
if(status != ARES_SUCCESS) {
resolverPtr->error = ares_strerror(status, 0);
resolverPtr->status = NameResolver::STATUS_ERROR;
return;
}
memcpy(&resolverPtr->addr, *host->h_addr_list, sizeof(struct in_addr));
resolverPtr->status = NameResolver::STATUS_SUCCESS;
}

102
src/NameResolver.h Normal file
View File

@ -0,0 +1,102 @@
/* <!-- copyright */
/*
* aria2 - a simple utility for downloading files faster
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* copyright --> */
#ifndef _D_NAME_RESOLVER_H_
#define _D_NAME_RESOLVER_H_
#include "common.h"
#include "SharedHandle.h"
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <ares.h>
#ifdef __cplusplus
} /* end of extern "C" */
#endif
class NameResolver {
friend void callback(void* arg, int status, struct hostent* host);
public:
enum STATUS {
STATUS_READY,
STATUS_QUERYING,
STATUS_SUCCESS,
STATUS_ERROR,
};
private:
STATUS status;
ares_channel channel;
struct in_addr addr;
string error;
public:
NameResolver():
status(STATUS_READY)
{
ares_init(&channel);
}
~NameResolver() {
ares_destroy(channel);
}
void resolve(const string& name) {
status = STATUS_QUERYING;
ares_gethostbyname(channel, name.c_str(), AF_INET, callback, this);
}
string getAddrString() const {
return inet_ntoa(addr);
}
const struct in_addr& getAddr() const {
return addr;
}
const string& getError() const {
return error;
}
STATUS getStatus() const {
return status;
}
int getFds(fd_set* rfdsPtr, fd_set* wfdsPtr) const {
return ares_fds(channel, rfdsPtr, wfdsPtr);
}
void process(fd_set* rfdsPtr, fd_set* wfdsPtr) {
ares_process(channel, rfdsPtr, wfdsPtr);
}
bool operator==(const NameResolver& resolver) {
return this == &resolver;
}
};
typedef SharedHandle<NameResolver> NameResolverHandle;
#endif // _D_NAME_RESOLVER_H_

View File

@ -60,17 +60,19 @@ PeerInteractionCommand::~PeerInteractionCommand() {
}
bool PeerInteractionCommand::executeInternal() {
if(sequence == INITIATOR_SEND_HANDSHAKE) {
socket->setBlockingMode();
setReadCheckSocket(socket);
setTimeout(e->option->getAsInt(PREF_TIMEOUT));
}
disableWriteCheckSocket();
setUploadLimitCheck(false);
setNoCheck(false);
switch(sequence) {
case INITIATOR_SEND_HANDSHAKE:
if(!socket->isWritable(0)) {
setWriteCheckSocket(socket);
break;
}
socket->setBlockingMode();
setReadCheckSocket(socket);
setTimeout(e->option->getAsInt(PREF_TIMEOUT));
peerInteraction->sendHandshake();
sequence = INITIATOR_WAIT_HANDSHAKE;
break;

View File

@ -376,7 +376,6 @@ void Util::fileChecksum(const string& filename, unsigned char* digest,
MessageDigestContext::DigestAlgo algo) {
MessageDigestContext ctx(algo);
ctx.digestInit();
ctx.digestReset();
int BUFLEN = 4096;
char buf[BUFLEN];
@ -531,3 +530,12 @@ string Util::toLower(const string& src) {
for_each(temp.begin(), temp.end(), LowerCase());
return temp;
}
bool Util::isNumbersAndDotsNotation(const string& name) {
struct sockaddr_in sockaddr;
if(inet_aton(name.c_str(), &sockaddr.sin_addr)) {
return true;
} else {
return false;
}
}

View File

@ -107,6 +107,8 @@ public:
static string toUpper(const string& src);
static string toLower(const string& src);
static bool isNumbersAndDotsNotation(const string& name);
};
#endif // _D_UTIL_H_

View File

@ -292,7 +292,7 @@ int main(int argc, char* argv[]) {
op->put(PREF_AUTO_SAVE_INTERVAL, "60");
op->put(PREF_DIRECT_FILE_MAPPING, V_TRUE);
op->put(PREF_UPLOAD_LIMIT, "0");
op->put(PREF_LOWEST_SPEED_LIMIT, "4000");
op->put(PREF_LOWEST_SPEED_LIMIT, "0");
while(1) {
int optIndex = 0;
int lopt;

View File

@ -45,11 +45,11 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \
$(top_srcdir)/m4/inttypes-pri.m4 $(top_srcdir)/m4/inttypes.m4 \
$(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/nls.m4 \
$(top_srcdir)/m4/openssl.m4 $(top_srcdir)/m4/po.m4 \
$(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/stdint_h.m4 \
$(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/ulonglong.m4 \
$(top_srcdir)/configure.ac
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libares.m4 \
$(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/openssl.m4 \
$(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
$(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \
$(top_srcdir)/m4/ulonglong.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@ -128,6 +128,8 @@ EXEEXT = @EXEEXT@
GENCAT = @GENCAT@
GLIBC21 = @GLIBC21@
GMSGFMT = @GMSGFMT@
HAVE_LIBARES_FALSE = @HAVE_LIBARES_FALSE@
HAVE_LIBARES_TRUE = @HAVE_LIBARES_TRUE@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
@ -138,6 +140,8 @@ INTLLIBS = @INTLLIBS@
INTLOBJS = @INTLOBJS@
INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@
LDFLAGS = @LDFLAGS@
LIBARES_CPPFLAGS = @LIBARES_CPPFLAGS@
LIBARES_LIBS = @LIBARES_LIBS@
LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@