Total Pageviews

Tuesday, 4 June 2024

轻量级的基于命令行的下载工具aria2

aria2 is a lightweight multi-protocol & multi-source, cross platform download utility operated in command-line. It supports HTTP/HTTPS, FTP, SFTP, BitTorrent and Metalink.

https://aria2.github.io/

aria2 - The ultra fast download utility

Introduction

aria2 is a utility for downloading files. The supported protocols are HTTP(S), FTP, SFTP, BitTorrent, and Metalink. aria2 can download a file from multiple sources/protocols and tries to utilize your maximum download bandwidth. It supports downloading a file from HTTP(S)/FTP/SFTP and BitTorrent at the same time, while the data downloaded from HTTP(S)/FTP/SFTP is uploaded to the BitTorrent swarm. Using Metalink's chunk checksums, aria2 automatically validates chunks of data while downloading a file like BitTorrent.

The project page is located at https://aria2.github.io/.

See the aria2 Online Manual (Russian translationPortuguese translation) to learn how to use aria2.

Features

Here is a list of features:

  • Command-line interface
  • Download files through HTTP(S)/FTP/SFTP/BitTorrent
  • Segmented downloading
  • Metalink version 4 (RFC 5854) support(HTTP/FTP/SFTP/BitTorrent)
  • Metalink version 3.0 support(HTTP/FTP/SFTP/BitTorrent)
  • Metalink/HTTP (RFC 6249) support
  • HTTP/1.1 implementation
  • HTTP Proxy support
  • HTTP BASIC authentication support
  • HTTP Proxy authentication support
  • Well-known environment variables for proxy: http_proxyhttps_proxyftp_proxyall_proxy and no_proxy
  • HTTP gzip, deflate content encoding support
  • Verify peer using given trusted CA certificate in HTTPS
  • Client certificate authentication in HTTPS
  • Chunked transfer encoding support
  • Load Cookies from the file using the Firefox3 format, Chromium/Google Chrome and the Mozilla/Firefox (1.x/2.x)/Netscape format.
  • Save Cookies in the Mozilla/Firefox (1.x/2.x)/Netscape format.
  • Custom HTTP Header support
  • Persistent Connections support
  • FTP/SFTP through HTTP Proxy
  • Download/Upload speed throttling
  • BitTorrent extensions: Fast extension, DHT, PEX, MSE/PSE, Multi-Tracker, UDP tracker
  • BitTorrent WEB-Seeding. aria2 requests chunk more than piece size to reduce the request overhead. It also supports pipelined requests with piece size.
  • BitTorrent Local Peer Discovery
  • Rename/change the directory structure of BitTorrent downloads completely
  • JSON-RPC (over HTTP and WebSocket)/XML-RPC interface
  • Run as a daemon process
  • Selective download in multi-file torrent/Metalink
  • Chunk checksum validation in Metalink
  • Can disable segmented downloading in Metalink
  • Netrc support
  • Configuration file support
  • Download URIs found in a text file or stdin and the destination directory and output file name can be specified optionally
  • Parameterized URI support
  • IPv6 support with Happy Eyeballs
  • Disk cache to reduce disk activity

Versioning and release schedule

We use 3 numbers for the aria2 version: MAJOR.MINOR.PATCH. We will ship MINOR updates on the 15th of every month. We may skip a release if we have had no changes since the last release. The feature and documentation freeze happens 10 days before the release day (the 5th day of the month) for translation teams. We will raise an issue about the upcoming release around that day.

We may release PATCH releases between regular releases if we have security issues.

The MAJOR version will stay at 1 for the time being.

How to get source code

We maintain the source code at Github: https://github.com/aria2/aria2

To get the latest source code, run the following command:

$ git clone https://github.com/aria2/aria2

This will create an aria2 directory in your current directory and source files are stored there.

Dependency

featuresdependency
HTTPSOSX or GnuTLS or OpenSSL or Windows
SFTPlibssh2

BitTorrent

None. Optional: libnettle+libgmp or libgcrypt or OpenSSL (see note)

Metalinklibxml2 or Expat.

Checksum

None. Optional: OSX or libnettle or libgcrypt or OpenSSL or Windows (see note)

gzip, deflate in HTTPzlib
Async DNSC-Ares
Firefox3/Chromium cookielibsqlite3
XML-RPClibxml2 or Expat.
JSON-RPC over WebSocketlibnettle or libgcrypt or OpenSSL

Note

libxml2 has precedence over Expat if both libraries are installed. If you prefer Expat, run configure with --without-libxml2.

Note

On Apple OSX, OS-level SSL/TLS support will be preferred. Hence neither GnuTLS nor OpenSSL is required on that platform. If you'd like to disable this behavior, run configure with --without-appletls.

GnuTLS has precedence over OpenSSL if both libraries are installed. If you prefer OpenSSL, run configure with --without-gnutls --with-openssl.

On Windows, there is SSL implementation available that is based on the native Windows SSL capabilities (Schannel) and it will be preferred. Hence neither GnuTLS nor OpenSSL is required on that platform. If you'd like to disable this behavior, run configure with --without-wintls.

Note

On Apple OSX, the OS-level checksum support will be preferred, unless aria2 is configured with --without-appletls.

libnettle has precedence over libgcrypt if both libraries are installed. If you prefer libgcrypt, run configure with --without-libnettle --with-libgcrypt. If OpenSSL is selected over GnuTLS, neither libnettle nor libgcrypt will be used.

If none of the optional dependencies are installed, an internal implementation that only supports md5 and sha1 will be used.

On Windows, there is SSL implementation available that is based on the native Windows capabilities and it will be preferred, unless aria2 is configured with --without-wintls.

A user can have one of the following configurations for SSL and crypto libraries:

  • OpenSSL
  • GnuTLS + libgcrypt
  • GnuTLS + libnettle
  • Apple TLS (OSX only)
  • Windows TLS (Windows only)

You can disable BitTorrent and Metalink support by providing --disable-bittorrent and --disable-metalink to the configure script respectively.

To enable async DNS support, you need c-ares.

How to build

aria2 is primarily written in C++. Initially, it was written based on C++98/C++03 standard features. We are now migrating aria2 to the C++11 standard. The current source code requires a C++11 aware compiler. For well-known compilers, such as g++ and clang, the -std=c++11 or -std=c++0x flag must be supported.

To build aria2 from the source package, you need the following development packages (package name may vary depending on the distribution you use):

  • libgnutls-dev (Required for HTTPS, BitTorrent, Checksum support)
  • nettle-dev (Required for BitTorrent, Checksum support)
  • libgmp-dev (Required for BitTorrent)
  • libssh2-1-dev (Required for SFTP support)
  • libc-ares-dev (Required for async DNS support)
  • libxml2-dev (Required for Metalink support)
  • zlib1g-dev (Required for gzip, deflate decoding support in HTTP)
  • libsqlite3-dev (Required for Firefox3/Chromium cookie support)
  • pkg-config (Required to detect installed libraries)

You can use libgcrypt-dev instead of nettle-dev and libgmp-dev:

  • libgpg-error-dev (Required for BitTorrent, Checksum support)
  • libgcrypt-dev (Required for BitTorrent, Checksum support)

You can use libssl-dev instead of libgnutls-dev, nettle-dev, libgmp-dev, libgpg-error-dev and libgcrypt-dev:

  • libssl-dev (Required for HTTPS, BitTorrent, Checksum support)

You can use libexpat1-dev instead of libxml2-dev:

  • libexpat1-dev (Required for Metalink support)

On Fedora you need the following packages: gcc, gcc-c++, kernel-devel, libgcrypt-devel, libxml2-devel, openssl-devel, gettext-devel, cppunit

If you downloaded source code from a git repository, you have to install the following packages to get autoconf macros:

  • libxml2-dev
  • libcppunit-dev
  • autoconf
  • automake
  • autotools-dev
  • autopoint
  • libtool

And run the following command to generate configure script and other files necessary to build the program:

$ autoreconf -i

Also, you need Sphinx to build the man page.

If you are building aria2 for Mac OS X, take a look at the makerelease-osx.mk GNU Make makefile.

The quickest way to build aria2 is first to run configure script:

$ ./configure

To build statically linked aria2, use ARIA2_STATIC=yes command-line option:

$ ./configure ARIA2_STATIC=yes

After configuration is done, run make to compile the program:

$ make

See Cross-compiling Windows binary to create a Windows binary. See Cross-compiling Android binary to create an Android binary.

The configure script checks available libraries and enables as many features as possible except for experimental features not enabled by default.

Since 1.1.0, aria2 checks the certificate of HTTPS servers by default. If you build with OpenSSL or the recent version of GnuTLS which has gnutls_certificate_set_x509_system_trust() function and the library is properly configured to locate the system-wide CA certificates store, aria2 will automatically load those certificates at the startup. If it is not the case, I recommend supplying the path to the CA bundle file. For example, in Debian the path to CA bundle file is '/etc/ssl/certs/ca-certificates.crt' (in ca-certificates package). This may vary depending on your distribution. You can give it to configure script using --with-ca-bundle option:

$ ./configure --with-ca-bundle='/etc/ssl/certs/ca-certificates.crt'
$ make

Without --with-ca-bundle option, you will encounter the error when accessing HTTPS servers because the certificate cannot be verified without the CA bundle. In such a case, you can specify the CA bundle file using aria2's --ca-certificate option. If you don't have the CA bundle file installed, then the last resort is to disable the certificate validation using --check-certificate=false.

Using the native OSX (AppleTLS) and/or Windows (WinTLS) implementation will automatically use the system certificate store, so --with-ca-bundle is not necessary and will be ignored when using these implementations.

By default, the bash_completion file named aria2c is installed to the directory $prefix/share/doc/aria2/bash_completion. To change the install directory of the file, use --with-bashcompletiondir option.

After a make, the executable is located at src/aria2c.

aria2 uses CppUnit for automated unit testing. To run the unit test:

$ make check

Cross-compiling Windows binary

In this section, we describe how to build a Windows binary using a mingw-w64 (http://mingw-w64.org/doku.php) cross-compiler on Debian Linux. The MinGW (http://www.mingw.org/) may not be able to build aria2.

The easiest way to build Windows binary is using Dockerfile.mingw. See Dockerfile.mingw how to build a binary. If you cannot use Dockerfile, then continue to read the following paragraphs.

Basically, after compiling and installing depended libraries, you can do cross-compile just passing appropriate --host option and specifying CPPFLAGSLDFLAGS, and PKG_CONFIG_LIBDIR variables to configure. For convenience and to lower our own development cost, we provide an easier way to configure the build settings.

mingw-config script is a configure script wrapper for mingw-w64. We use it to create official Windows build. This script assumes the following libraries have been built for cross-compile:

  • c-ares
  • expat
  • sqlite3
  • zlib
  • libssh2
  • cppunit

Some environment variables can be adjusted to change build settings:

HOST

cross-compile to build programs to run on HOST. It defaults to i686-w64-mingw32. To build a 64bit binary, specify x86_64-w64-mingw32.

PREFIX

Prefix to the directory where dependent libraries are installed. It defaults to /usr/local/$HOST-I$PREFIX/include will be added to CPPFLAGS-L$PREFIX/lib will be added to LDFLAGS$PREFIX/lib/pkgconfig will be set to PKG_CONFIG_LIBDIR.

For example, to build a 64bit binary do this:

$ HOST=x86_64-w64-mingw32 ./mingw-config

If you want libaria2 dll with --enable-libaria2, then don't use ARIA2_STATIC=yes and prepare the DLL version of external libraries.

Cross-compiling Android binary

In this section, we describe how to build Android binary using Android NDK cross-compiler on Debian Linux.

At the time of this writing, Android NDK r21e should compile aria2 without errors.

android-config script is a configure script wrapper for Android build. We use it to create an official Android build. This script assumes the following libraries have been built for cross-compile:

  • c-ares
  • openssl
  • expat
  • zlib
  • libssh2

When building the above libraries, make sure that disable shared library and enable only static library. We are going to link those libraries statically.

android-config assumes that $ANDROID_HOME and $NDK environment variables are defined.

We currently use Android NDK r21e. $NDK should point to the directory to Android NDK. The build tools will be found under $NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/.

All the dependent libraries must be installed under $ANDROID_HOME/usr/local.

After android-config, run make to compile sources.

Building documentation

Sphinx is used to building the documentation. aria2 man pages will be build when you run make if they are not up-to-date. You can also build an HTML version of the aria2 man page by make html. The HTML version manual is also available online (Russian translationPortuguese translation).

BitTorrent

About file names

The file name of the downloaded file is determined as follows:

single-file mode

If "name" key is present in .torrent file, the file name is the value of "name" key. Otherwise, the file name is the base name of .torrent file appended by ".file". For example, .torrent file is "test.torrent", then file name is "test.torrent.file". The directory to store the downloaded file can be specified by -d option.

multi-file mode

The complete directory/file structure mentioned in .torrent file is created. The directory to store the top directory of downloaded files can be specified by -d option.

Before download starts, a complete directory structure is created if needed. By default, aria2 opens at most 100 files mentioned in .torrent file, and directly writes to and reads from these files. The number of files to open simultaneously can be controlled by --bt-max-open-files option.

DHT

aria2 supports mainline compatible DHT. By default, the routing table for IPv4 DHT is saved to $XDG_CACHE_HOME/aria2/dht.dat and the routing table for IPv6 DHT is saved to $XDG_CACHE_HOME/aria2/dht6.dat unless files exist at $HOME/.aria2/dht.dat or $HOME/.aria2/dht6.dat. aria2 uses the same port number to listen on for both IPv4 and IPv6 DHT.

UDP tracker

UDP tracker support is enabled when IPv4 DHT is enabled. The port number of the UDP tracker is shared with DHT. Use --dht-listen-port option to change the port number.

Other things should be noted

  • -o option is used to change the file name of .torrent file itself, not a file name of a file in .torrent file. For this purpose, use --index-out option instead.
  • The port numbers that aria2 uses by default are 6881-6999 for TCP and UDP.
  • aria2 doesn't configure port-forwarding automatically. Please configure your router or firewall manually.
  • The maximum number of peers is 55. This limit may be exceeded when the download rate is low. This download rate can be adjusted using --bt-request-peer-speed-limit option.
  • As of release 0.10.0, aria2 stops sending request messages after selective download completes.

The current implementation supports HTTP(S)/FTP/SFTP/BitTorrent. The other P2P protocols are ignored. Both Metalink4 (RFC 5854) and Metalink version 3.0 documents are supported.

For checksum verification, md5, sha-1, sha-224, sha-256, sha-384, and sha-512 are supported. If multiple hash algorithms are provided, aria2 uses a stronger one. If whole file checksum verification fails, aria2 doesn't retry the download and just exits with a non-zero return code.

The supported user preferences are version, language, location, protocol, and os.

If chunk checksums are provided in the Metalink file, aria2 automatically validates chunks of data during download. This behavior can be turned off by a command-line option.

If a signature is included in a Metalink file, aria2 saves it as a file after the completion of the download. The file name is download file name + ".sig". If the same file already exists, the signature file is not saved.

In Metalink4, a multi-file torrent could appear in metalink:metaurl element. Since aria2 cannot download 2 same torrents at the same time, aria2 groups files in metalink:file element which has the same BitTorrent metaurl, and downloads them from a single BitTorrent swarm. This is a basically multi-file torrent download with file selection, so the adjacent files which are not in Metalink document but share the same piece with the selected file are also created.

If relative URI is specified in metalink:url or metalink:metaurl element, aria2 uses the URI of Metalink file as base URI to resolve the relative URI. If relative URI is found in the Metalink file which is read from the local disk, aria2 uses the value of --metalink-base-uri option as base URI. If this option is not specified, the relative URI will be ignored.

Metalink/HTTP

The current implementation only uses rel=duplicate links. aria2 understands Digest header fields and check whether it matches the digest value from other sources. If it differs, drop the connection. aria2 also uses this digest value to perform checksum verification after the download is finished. aria2 recognizes geo value. To tell aria2 which location you prefer, you can use --metalink-location option.

netrc

netrc support is enabled by default for HTTP(S)/FTP/SFTP. To disable netrc support, specify -n command-line option. Your .netrc file should have correct permissions(600).

WebSocket

The WebSocket server embedded in aria2 implements the specification defined in RFC 6455. The supported protocol version is 13.

libaria2

The libaria2 is a C++ library that offers aria2 functionality to the client code. Currently, libaria2 is not built by default. To enable libaria2, use --enable-libaria2 configure option. By default, only the shared library is built. To build a static library, use --enable-static configure option as well. See libaria2 documentation to know how to use API.

References


from https://github.com/aria2/aria2

下载地址:
https://github.com/aria2/aria2/releases/download/release-1.37.0/aria2-1.37.0-win-64bit-build1.zip
-------------------------

使用Aria2离线下载

Aria2是一个开源的下载工具,可用于macos/linux/windows平台,你可以使用它在上述系统中命令行界面上作为下载工具,也可以配合图形工具作为离线下载工具。

Aria2是开源的软件,所以各种平台都有相应的版本,软件官网:https://aria2.github.io/

通用安装方式:
macOS:

brew install aria2

Debian/Ubuntu

apt install aria2

Windows 下载页面:
https://github.com/aria2/aria2/releases/latest
根据你自己的系统选择win-32bit或者win-64bit即可。

Windows使用步骤:

先解压aria2c.exe到Windows目录,解压到其他目录也是可以的,放在Windows目录的好处是你可以随时运行cmd,在cmd里面直接执行“aria2c 下载网址”来进行文件下载。

下面是配置范例(文件名aria2.conf,请修改对应目录路径,范例是linux的路径):

# 下载目录。可使用绝对路径或相对路径, 默认: 当前启动位置
dir=/downloads

# 磁盘缓存, 0 为禁用缓存,默认:16M
# 磁盘缓存的作用是把下载的数据块临时存储在内存中,然后集中写入硬盘,以减少磁盘 I/O ,提升读写性能,延长硬盘寿命。
# 建议在有足够的内存空闲情况下适当增加,但不要超过剩余可用内存空间大小。
# 此项值仅决定上限,实际对内存的占用取决于网速(带宽)和设备性能等其它因素。
disk-cache=256M

# 文件预分配方式, 可选:none, prealloc, trunc, falloc, 默认:prealloc
# 预分配对于机械硬盘可有效降低磁盘碎片、提升磁盘读写性能、延长磁盘寿命。
# 机械硬盘使用 ext4(具有扩展支持),btrfs,xfs 或 NTFS(仅 MinGW 编译版本)等文件系统建议设置为 falloc
# 若无法下载,提示 fallocate failed.cause:Operation not supported 则说明不支持,请设置为 none
# prealloc 分配速度慢, trunc 无实际作用,不推荐使用。
# 固态硬盘不需要预分配,只建议设置为 none ,否则可能会导致双倍文件大小的数据写入,从而影响寿命。
file-allocation=none

# 文件预分配大小限制。小于此选项值大小的文件不预分配空间,单位 K 或 M,默认:5M
no-file-allocation-limit=64M

# 断点续传
continue=true

# 始终尝试断点续传,无法断点续传则终止下载,默认:true
always-resume=false

# 不支持断点续传的 URI 数值,当 always-resume=false 时生效。
# 达到这个数值从将头开始下载,值为 0 时所有 URI 不支持断点续传时才从头开始下载。
max-resume-failure-tries=0

# 获取服务器文件时间,默认:false
remote-time=true


## 进度保存设置 ##

# 从会话文件中读取下载任务
input-file=/root/.aria2/aria2.session

# 会话文件保存路径
# Aria2 退出时或指定的时间间隔会保存`错误/未完成`的下载任务到会话文件
save-session=/root/.aria2/aria2.session

# 任务状态改变后保存会话的间隔时间(秒), 0 为仅在进程正常退出时保存, 默认:0
# 为了及时保存任务状态、防止任务丢失,此项值只建议设置为 1
save-session-interval=1

# 自动保存任务进度到控制文件(*.aria2)的间隔时间(秒),0 为仅在进程正常退出时保存,默认:60
# 此项值也会间接影响从内存中把缓存的数据写入磁盘的频率
# 想降低磁盘 IOPS (每秒读写次数)则提高间隔时间
# 想在意外非正常退出时尽量保存更多的下载进度则降低间隔时间
# 非正常退出:进程崩溃、系统崩溃、SIGKILL 信号、设备断电等
auto-save-interval=30

# 强制保存,即使任务已完成也保存信息到会话文件, 默认:false
# 开启后会在任务完成后保留 .aria2 文件,文件被移除且任务存在的情况下重启后会重新下载。
# 关闭后已完成的任务列表会在重启后清空。
force-save=false


## 下载连接设置 ##

# 文件未找到重试次数,默认:0 (禁用)
# 重试时同时会记录重试次数,所以也需要设置 max-tries 这个选项
max-file-not-found=10

# 最大尝试次数,0 表示无限,默认:5
max-tries=0

# 重试等待时间(秒), 默认:0 (禁用)
retry-wait=10

# 连接超时时间(秒)。默认:60
connect-timeout=20

# 超时时间(秒)。默认:60
timeout=10

# 最大同时下载任务数, 运行时可修改, 默认:5
max-concurrent-downloads=8

# 单服务器最大连接线程数, 任务添加时可指定, 默认:1
# 最大值为 16 (增强版无限制), 且受限于单任务最大连接线程数(split)所设定的值。
max-connection-per-server=16

# 单任务最大连接线程数, 任务添加时可指定, 默认:5
split=64

# 文件最小分段大小, 添加时可指定, 取值范围 1M-1024M (增强版最小值为 1K), 默认:20M
# 比如此项值为 10M, 当文件为 20MB 会分成两段并使用两个来源下载, 文件为 15MB 则只使用一个来源下载。
# 理论上值越小使用下载分段就越多,所能获得的实际线程数就越大,下载速度就越快,但受限于所下载文件服务器的策略。
min-split-size=10M

# HTTP/FTP 下载分片大小,所有分割都必须是此项值的倍数,最小值为 1M (增强版为 1K),默认:1M
piece-length=1M

# 允许分片大小变化。默认:false
# false:当分片大小与控制文件中的不同时将会中止下载
# true:丢失部分下载进度继续下载
allow-piece-length-change=true

# 最低下载速度限制。当下载速度低于或等于此选项的值时关闭连接(增强版本为重连),此选项与 BT 下载无关。单位 K 或 M ,默认:0 (无限制)
lowest-speed-limit=0

# 全局最大下载速度限制, 运行时可修改, 默认:0 (无限制)
max-overall-download-limit=0

# 单任务下载速度限制, 默认:0 (无限制)
max-download-limit=0

# 禁用 IPv6, 默认:false
disable-ipv6=false

# GZip 支持,默认:false
http-accept-gzip=true

# URI 复用,默认: true
reuse-uri=true

# 禁用 netrc 支持,默认:false
no-netrc=true

# 允许覆盖,当相关控制文件(.aria2)不存在时从头开始重新下载。默认:false
allow-overwrite=false

# 文件自动重命名,此选项仅在 HTTP(S)/FTP 下载中有效。新文件名在名称之后扩展名之前加上一个点和一个数字(1..9999)。默认:true
auto-file-renaming=true

# 使用 UTF-8 处理 Content-Disposition ,默认:false
content-disposition-default-utf8=true

# 最低 TLS 版本,可选:TLSv1.1、TLSv1.2、TLSv1.3 默认:TLSv1.2
min-tls-version=TLSv1.2


## BT/PT 下载设置 ##

# BT 监听端口(TCP), 默认:6881-6999
# 直通外网的设备,比如 VPS ,务必配置防火墙和安全组策略允许此端口入站
# 内网环境的设备,比如 NAS ,除了防火墙设置,还需在路由器设置外网端口转发到此端口
listen-port=6881

# DHT 网络与 UDP tracker 监听端口(UDP), 默认:6881-6999
# 因协议不同,可以与 BT 监听端口使用相同的端口,方便配置防火墙和端口转发策略。
dht-listen-port=6881

# 启用 IPv4 DHT 功能, PT 下载(私有种子)会自动禁用, 默认:true
enable-dht=true

# 启用 IPv6 DHT 功能, PT 下载(私有种子)会自动禁用,默认:false
# 在没有 IPv6 支持的环境开启可能会导致 DHT 功能异常
enable-dht6=true

# 指定 BT 和 DHT 网络中的 IP 地址
# 使用场景:在家庭宽带没有公网 IP 的情况下可以把 BT 和 DHT 监听端口转发至具有公网 IP 的服务器,在此填写服务器的 IP ,可以提升 BT 下载速率。
#bt-external-ip=

# IPv4 DHT 文件路径,默认:$HOME/.aria2/dht.dat
dht-file-path=/root/.aria2/dht.dat

# IPv6 DHT 文件路径,默认:$HOME/.aria2/dht6.dat
dht-file-path6=/root/.aria2/dht6.dat

# IPv4 DHT 网络引导节点
dht-entry-point=dht.transmissionbt.com:6881

# IPv6 DHT 网络引导节点
dht-entry-point6=dht.transmissionbt.com:6881

# 本地节点发现, PT 下载(私有种子)会自动禁用 默认:false
bt-enable-lpd=true

# 指定用于本地节点发现的接口,可能的值:接口,IP地址
# 如果未指定此选项,则选择默认接口。
#bt-lpd-interface=

# 启用节点交换, PT 下载(私有种子)会自动禁用, 默认:true
enable-peer-exchange=true

# BT 下载最大连接数(单任务),运行时可修改。0 为不限制,默认:55
# 理想情况下连接数越多下载越快,但在实际情况是只有少部分连接到的做种者上传速度快,其余的上传慢或者不上传。
# 如果不限制,当下载非常热门的种子或任务数非常多时可能会因连接数过多导致进程崩溃或网络阻塞。
# 进程崩溃:如果设备 CPU 性能一般,连接数过多导致 CPU 占用过高,因资源不足 Aria2 进程会强制被终结。
# 网络阻塞:在内网环境下,即使下载没有占满带宽也会导致其它设备无法正常上网。因远古低性能路由器的转发性能瓶颈导致。
bt-max-peers=128

# BT 下载期望速度值(单任务),运行时可修改。单位 K 或 M 。默认:50K
# BT 下载速度低于此选项值时会临时提高连接数来获得更快的下载速度,不过前提是有更多的做种者可供连接。
# 实测临时提高连接数没有上限,但不会像不做限制一样无限增加,会根据算法进行合理的动态调节。
bt-request-peer-speed-limit=10M

# 全局最大上传速度限制, 运行时可修改, 默认:0 (无限制)
# 设置过低可能影响 BT 下载速度
max-overall-upload-limit=2M

# 单任务上传速度限制, 默认:0 (无限制)
max-upload-limit=0

# 最小分享率。当种子的分享率达到此选项设置的值时停止做种, 0 为一直做种, 默认:1.0
# 强烈建议您将此选项设置为大于等于 1.0
seed-ratio=1.0

# 最小做种时间(分钟)。设置为 0 时将在 BT 任务下载完成后停止做种。
seed-time=0

# 做种前检查文件哈希, 默认:true
bt-hash-check-seed=true

# 继续之前的BT任务时, 无需再次校验, 默认:false
bt-seed-unverified=false

# BT tracker 服务器连接超时时间(秒)。默认:60
# 建立连接后,此选项无效,将使用 bt-tracker-timeout 选项的值
bt-tracker-connect-timeout=10

# BT tracker 服务器超时时间(秒)。默认:60
bt-tracker-timeout=10

# BT 服务器连接间隔时间(秒)。默认:0 (自动)
#bt-tracker-interval=0

# BT 下载优先下载文件开头或结尾
bt-prioritize-piece=head=32M,tail=32M

# 保存通过 WebUI(RPC) 上传的种子文件(.torrent),默认:true
# 所有涉及种子文件保存的选项都建议开启,不保存种子文件有任务丢失的风险。
# 通过 RPC 自定义临时下载目录可能不会保存种子文件。
rpc-save-upload-metadata=true

# 下载种子文件(.torrent)自动开始下载, 默认:true,可选:false|mem
# true:保存种子文件
# false:仅下载种子文件
# mem:将种子保存在内存中
follow-torrent=true

# 种子文件下载完后暂停任务,默认:false
# 在开启 follow-torrent 选项后下载种子文件或磁力会自动开始下载任务进行下载,而同时开启当此选项后会建立相关任务并暂停。
pause-metadata=false

# 保存磁力链接元数据为种子文件(.torrent), 默认:false
bt-save-metadata=false

# 加载已保存的元数据文件(.torrent),默认:false
bt-load-saved-metadata=true

# 删除 BT 下载任务中未选择文件,默认:false
bt-remove-unselected-file=true

# BT强制加密, 默认: false
# 启用后将拒绝旧的 BT 握手协议并仅使用混淆握手及加密。可以解决部分运营商对 BT 下载的封锁,且有一定的防版权投诉与迅雷吸血效果。
# 此选项相当于后面两个选项(bt-require-crypto=true, bt-min-crypto-level=arc4)的快捷开启方式,但不会修改这两个选项的值。
bt-force-encryption=true

# BT加密需求,默认:false
# 启用后拒绝与旧的 BitTorrent 握手协议(\19BitTorrent protocol)建立连接,始终使用混淆处理握手。
#bt-require-crypto=true

# BT最低加密等级,可选:plain(明文),arc4(加密),默认:plain
#bt-min-crypto-level=arc4

# 分离仅做种任务,默认:false
# 从正在下载的任务中排除已经下载完成且正在做种的任务,并开始等待列表中的下一个任务。
bt-detach-seed-only=true


## 客户端伪装 ##

# 自定义 User Agent
user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36

# BT 客户端伪装
# PT 下载需要保持 user-agent 和 peer-agent 两个参数一致
# 部分 PT 站对 Aria2 有特殊封禁机制,客户端伪装不一定有效,且有封禁账号的风险。
#user-agent=Deluge 1.3.15
peer-agent=Deluge 1.3.15
peer-id-prefix=-DE13F0-


## 执行额外命令 ##

# 下载停止后执行的命令
# 从 正在下载 到 删除、错误、完成 时触发。暂停被标记为未开始下载,故与此项无关。
on-download-stop=/root/.aria2/delete.sh

# 下载完成后执行的命令
# 此项未定义则执行 下载停止后执行的命令 (on-download-stop)
on-download-complete=/root/.aria2/clean.sh

# 下载错误后执行的命令
# 此项未定义则执行 下载停止后执行的命令 (on-download-stop)
#on-download-error=

# 下载暂停后执行的命令
#on-download-pause=

# 下载开始后执行的命令
#on-download-start=

# BT 下载完成后执行的命令
#on-bt-download-complete=


## RPC 设置 ##

# 启用 JSON-RPC/XML-RPC 服务器, 默认:false
enable-rpc=true

# 接受所有远程请求, 默认:false
rpc-allow-origin-all=true

# 允许外部访问, 默认:false
rpc-listen-all=true

# RPC 监听端口, 默认:6800
rpc-listen-port=6800

# RPC 密钥
rpc-secret=JK&DEW56

# RPC 最大请求大小
rpc-max-request-size=10M

# RPC 服务 SSL/TLS 加密, 默认:false
# 启用加密后必须使用 https 或者 wss 协议连接
# 不推荐开启,建议使用 web server 反向代理,比如 Nginx、Caddy ,灵活性更强。
#rpc-secure=false

# 在 RPC 服务中启用 SSL/TLS 加密时的证书文件(.pem/.crt)
#rpc-certificate=/root/.aria2/xxx.pem

# 在 RPC 服务中启用 SSL/TLS 加密时的私钥文件(.key)
#rpc-private-key=/root/.aria2/xxx.key

# 事件轮询方式, 可选:epoll, kqueue, port, poll, select, 不同系统默认值不同
#event-poll=select


## 高级选项 ##

# 启用异步 DNS 功能。默认:true
#async-dns=true

# 指定异步 DNS 服务器列表,未指定则从 /etc/resolv.conf 中读取。
#async-dns-server=119.29.29.29,223.5.5.5,8.8.8.8,1.1.1.1

# 指定单个网络接口,可能的值:接口,IP地址,主机名
# 如果接口具有多个 IP 地址,则建议指定 IP 地址。
# 已知指定网络接口会影响依赖本地 RPC 的连接的功能场景,即通过 localhost 和 127.0.0.1 无法与 Aria2 服务端进行讯通。
#interface=

# 指定多个网络接口,多个值之间使用逗号(,)分隔。
# 使用 interface 选项时会忽略此项。
#multiple-interface=


## 日志设置 ##

# 日志文件保存路径,忽略或设置为空为不保存,默认:不保存
#log=

# 日志级别,可选 debug, info, notice, warn, error 。默认:debug
#log-level=warn

# 控制台日志级别,可选 debug, info, notice, warn, error ,默认:notice
console-log-level=notice

# 安静模式,禁止在控制台输出日志,默认:false
quiet=false

# 下载进度摘要输出间隔时间(秒),0 为禁止输出。默认:60
summary-interval=0


## 增强扩展设置(非官方) ##

# 仅适用于 myfreeer/aria2-build-msys2 (Windows) 和 P3TERX/Aria2-Pro-Core (GNU/Linux) 项目所构建的增强版本

# 在服务器返回 HTTP 400 Bad Request 时重试,仅当 retry-wait > 0 时有效,默认 false
#retry-on-400=true

# 在服务器返回 HTTP 403 Forbidden 时重试,仅当 retry-wait > 0 时有效,默认 false
#retry-on-403=true

# 在服务器返回 HTTP 406 Not Acceptable 时重试,仅当 retry-wait > 0 时有效,默认 false
#retry-on-406=true

# 在服务器返回未知状态码时重试,仅当 retry-wait > 0 时有效,默认 false
#retry-on-unknown=true

# 是否发送 Want-Digest HTTP 标头。默认:false (不发送)
# 部分网站会把此标头作为特征来检测和屏蔽 Aria2
#http-want-digest=false


## BitTorrent trackers ##
bt-tracker=http://1337.abcvg.info:80/announce,http://fxtt.ru:80/announce,http://milanesitracker.tekcities.com:80/announce,http://nyaa.tracker.wf:7777/announce,http://open.acgnxtracker.com:80/announce,http://opentracker.xyz:80/announce,http://share.camoe.cn:8080/announce,http://t.acg.rip:6699/announce,http://t.nyaatracker.com:80/announce,http://t.overflow.biz:6969/announce,http://tr.cili001.com:8070/announce,http://tracker.bt4g.com:2095/announce,http://tracker.dler.org:6969/announce,http://tracker.edkj.club:6969/announce,http://tracker.files.fm:6969/announce,http://tracker.gbitt.info:80/announce,http://tracker.ipv6tracker.ru:80/announce,http://tracker.logirl.moe:17052/announce,http://tracker.mywaifu.best:6969/announce,http://tracker.noobsubs.net:80/announce,http://tracker.openbittorrent.com:80/announce,http://tracker1.itzmx.com:8080/announce,http://tracker2.itzmx.com:6961/announce,http://tracker3.itzmx.com:6961/announce,https://carbon-bonsai-621.appspot.com:443/announce,https://opentracker.i2p.rocks:443/announce,https://tr.abiir.top:443/announce,https://tr.burnabyhighstar.com:443/announce,https://tr.ready4.icu:443/announce,https://tracker.babico.name.tr:443/announce,https://tracker.baka.ink:443/announce,https://tracker.dmhy.pw:443/announce,https://tracker.imgoingto.icu:443/announce,https://tracker.lilithraws.cf:443/announce,https://tracker.nanoha.org:443/announce,https://tracker.tamersunion.org:443/announce,https://tracker1.loli.co.nz:443/announce,https://trackme.theom.nz:443/announce,udp://9.rarbg.com:2810/announce,udp://960303.xyz:6969/announce,udp://exodus.desync.com:6969/announce,udp://fe.dealclub.de:6969/announce,udp://ipv4.tracker.harry.lu:80/announce,udp://ipv6.babico.name.tr:8000/announce,udp://mirror.aptus.co.tz:6969/announce,udp://movies.zsw.ca:6969/announce,udp://oldboystudy.com:6969/announce,udp://open.demonii.com:1337/announce,udp://open.dstud.io:6969/announce,udp://open.free-tracker.ga:6969/announce,udp://open.publictracker.xyz:6969/announce,udp://open.stealth.si:80/announce,udp://open.tracker.cl:1337/announce,udp://open.tracker.ink:6969/announce,udp://open.xxtor.com:3074/announce,udp://opentor.org:2710/announce,udp://opentracker.i2p.rocks:6969/announce,udp://p4p.arenabg.com:1337/announce,udp://run.publictracker.xyz:6969/announce,udp://thetracker.org:80/announce,udp://torrentclub.space:6969/announce,udp://tracker.0x.tf:6969/announce,udp://tracker.altrosky.nl:6969/announce,udp://tracker.auctor.tv:6969/announce,udp://tracker.beeimg.com:6969/announce,udp://tracker.birkenwald.de:6969/announce,udp://tracker.bitsearch.to:1337/announce,udp://tracker.cyberia.is:6969/announce,udp://tracker.dump.cl:6969/announce,udp://tracker.jordan.im:6969/announce,udp://tracker.leech.ie:1337/announce,udp://tracker.moeking.me:6969/announce,udp://tracker.monitorit4.me:6969/announce,udp://tracker.openbittorrent.com:6969/announce,udp://tracker.opentrackr.org:1337/announce,udp://tracker.pomf.se:80/announce,udp://tracker.publictracker.xyz:6969/announce,udp://tracker.theoks.net:6969/announce,udp://tracker.tiny-vps.com:6969/announce,udp://tracker.torrent.eu.org:451/announce,udp://tracker.zerobytes.xyz:1337/announce,udp://tracker1.bt.moack.co.kr:80/announce,udp://tracker1.myporn.club:9337/announce,udp://tracker2.dler.com:80/announce,udp://tracker4.itzmx.com:2710/announce,udp://tracker6.lelux.fi:6969/announce,udp://u4.trakx.crim.ist:1337/announce,udp://v2.iperson.xyz:6969/announce,udp://vibe.sleepyinternetfun.xyz:1738/announce,udp://www.torrent.eu.org:451/announce,udp://zecircle.xyz:6969/announce,ws://hub.bugout.link:80/announce,wss://tracker.openwebtorrent.com:443/announce
JSON

可以根据自己需要自行修改,里面有些文件是需要自己新建的,用记事本新建一个空白的文件就可以了,不需要可注释掉。

测试配置是否正确:
运行cmd,执行

C:\Windows\aria2c.exe —conf-path=D:\Downlo~1\Aria2\aria2.conf

然后就可以测试使用rpc通信来实现远程离线下载,推荐一个目前我觉得挺好的图形界面,AriaNG,支持macOS和Windows。

下载地址:

https://github.com/mayswind/AriaNg-Native/releases/latest

软件可管理多个远程下载,只需要设置好RPC参数即可。

如果有出现错误提示,按提示修改即可,如果系统有使用防火墙,记得把aria2c.exe加入防火墙例外名单。

上面这些测试都完成,现在需要解决aria2启动问题,每次如果都要开cmd然后输入命令的话很不方便,而且还要长期开着一个窗口也不美观。解决方法如下:

新建一个runaria2.vbs,放到开始菜单的启动文件夹中,让它开机自动运行,vbs文件内容如下:

CreateObject("WScript.Shell").Run "C:\Windows\aria2c.exe —conf-path=D:\Downlo~1\Aria2\aria2.conf",0

这样就完成了所有配置了。

如果不想使用电脑端管理的话,也可以用手机的app来管理下载任务,使用app你可以从手机直接操作电脑远程离线下载,对应的app可以在应用商店上都可以找到。

参考来源:

https://github.com/P3TERX/aria2.conf

 --------------

相关帖子:
https://briteming.blogspot.com/2018/01/dockeraria2ariangfilerunnextcloudbt.html

No comments:

Post a Comment