mirror of
https://github.com/sirpdboy/sirpdboy-package.git
synced 2025-01-08 11:57:57 +08:00
up aria2 1.36
This commit is contained in:
parent
985fe07cdd
commit
da0b1d8560
@ -7,12 +7,12 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=aria2
|
||||
PKG_VERSION:=1.35.0
|
||||
PKG_RELEASE:=4
|
||||
PKG_VERSION:=1.36.0
|
||||
PKG_RELEASE:=21
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||
PKG_SOURCE_URL:=https://github.com/aria2/aria2/releases/download/release-$(PKG_VERSION)/
|
||||
PKG_HASH:=1e2b7fd08d6af228856e51c07173cfcf987528f1ac97e04c5af4a47642617dfd
|
||||
PKG_HASH:=skip
|
||||
PKG_INSTALL:=1
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
@ -90,6 +90,20 @@ define Package/aria2/conffiles
|
||||
/etc/config/aria2
|
||||
endef
|
||||
|
||||
define Download/aria2.conf
|
||||
URL:=https://github.com/P3TERX/aria2.conf/archive
|
||||
URL_FILE:=master.zip
|
||||
FILE:=aria2.conf
|
||||
HASH:=skip
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
$(call Build/Prepare/Default)
|
||||
unzip $(DL_DIR)/aria2.conf -d $(PKG_BUILD_DIR)/
|
||||
sed -i '/rpc-secret/d' $(PKG_BUILD_DIR)/aria2.conf-master/*
|
||||
endef
|
||||
|
||||
|
||||
define Package/aria2/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/aria2c $(1)/usr/bin
|
||||
@ -99,6 +113,10 @@ define Package/aria2/install
|
||||
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) ./files/aria2.conf $(1)/etc/config/aria2
|
||||
|
||||
$(INSTALL_DIR) $(1)/usr/share/aria2
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/aria2.conf-master/* $(1)/usr/share/aria2/
|
||||
endef
|
||||
|
||||
$(eval $(call Download,aria2.conf))
|
||||
$(eval $(call BuildPackage,aria2))
|
||||
|
@ -15,13 +15,9 @@ config aria2 'main'
|
||||
option bt_enable_lpd 'true'
|
||||
option enable_dht 'true'
|
||||
option follow_torrent 'true'
|
||||
option quiet 'false'
|
||||
option file_allocation 'none'
|
||||
option save_session_interval '30'
|
||||
option enable_logging '0'
|
||||
option rpc_auth_method 'none'
|
||||
option rpc_secure 'false'
|
||||
option enable_proxy '0'
|
||||
option check_certificate 'true'
|
||||
option enable_dht6 'false'
|
||||
option enable_peer_exchange 'true'
|
||||
|
||||
option split '128'
|
||||
option min_split_size '100K'
|
||||
option max_connection_per_server '128'
|
||||
list extra_settings 'dht-file-path=/usr/share/aria2/dht.dat'
|
||||
|
@ -20,15 +20,10 @@ _make_dir() {
|
||||
local d
|
||||
for d in "$@"; do
|
||||
if [ ! -d "$d" ]; then
|
||||
if mkdir -p "$d" 2>/dev/null; then
|
||||
_info "成功创建<code>"$d"</code>目录。"
|
||||
return 0
|
||||
else
|
||||
_info "无法创建<code>"$d"</code>目录。"
|
||||
return 1
|
||||
fi
|
||||
mkdir -p "$d" 2>/dev/null || return 1
|
||||
fi
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
@ -38,6 +33,7 @@ _create_file() {
|
||||
|
||||
_change_owner() {
|
||||
local u="$1"; shift
|
||||
|
||||
local d
|
||||
for d in "$@"; do
|
||||
if [ -f "$d" ]; then
|
||||
@ -46,6 +42,7 @@ _change_owner() {
|
||||
chown -R "$u" "$d" 2>/dev/null || return 1
|
||||
fi
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
@ -68,131 +65,125 @@ append_options() {
|
||||
local o; local v
|
||||
for o in "$@"; do
|
||||
v="$(eval echo "\$$o")"
|
||||
[ -n "$v" ] && echo "${o//_/-}=$v" >>"$config_file_tmp"
|
||||
[ -n "$v" ] && \
|
||||
echo "${o//_/-}=$v" >>"$config_file_tmp"
|
||||
done
|
||||
}
|
||||
|
||||
append_setting() {
|
||||
local s="$1"
|
||||
[ -n "$s" ] && echo "$s" >>"$config_file_tmp"
|
||||
[ -n "$s" ] && \
|
||||
echo "$s" >>"$config_file_tmp"
|
||||
}
|
||||
|
||||
append_header() {
|
||||
local h="$1"
|
||||
[ -n "$h" ] && echo "header=\"$h\"" >>"$config_file_tmp"
|
||||
[ -n "$h" ] && \
|
||||
echo "header=\"$h\"" >>"$config_file_tmp"
|
||||
}
|
||||
|
||||
aria2_validate() {
|
||||
uci_load_validate "$NAME" aria2 "$1" "$2" \
|
||||
'dir:string' \
|
||||
'log:string' \
|
||||
'user:string' \
|
||||
'split:uinteger' \
|
||||
'enabled:bool:0' \
|
||||
'enable_Pro:bool' \
|
||||
'rpc_user:string' \
|
||||
'all_proxy:string' \
|
||||
'seed_time:ufloat' \
|
||||
'certificate:file' \
|
||||
'timeout:uinteger' \
|
||||
'private_key:file' \
|
||||
'seed_ratio:ufloat' \
|
||||
'rpc_secret:string' \
|
||||
'user_agent:string' \
|
||||
'rpc_passwd:string' \
|
||||
'enable_proxy:bool' \
|
||||
'disk_cache:string' \
|
||||
'listen_port:string' \
|
||||
'max_tries:uinteger' \
|
||||
'enable_logging:bool' \
|
||||
'ca_certificate:file' \
|
||||
'retry_wait:uinteger' \
|
||||
'rpc_certificate:file' \
|
||||
'rpc_private_key:file' \
|
||||
'all_proxy_user:string' \
|
||||
'min_split_size:string' \
|
||||
'peer_id_prefix:string' \
|
||||
'bt_max_peers:uinteger' \
|
||||
'dht_listen_port:string' \
|
||||
'enable_proxy:bool' \
|
||||
'config_dir:string:/var/etc/aria2' \
|
||||
'user:string' \
|
||||
'all_proxy:string' \
|
||||
'all_proxy_passwd:string' \
|
||||
'max_upload_limit:string' \
|
||||
'bt_tracker:list(string)' \
|
||||
'bt_stop_timeout:uinteger' \
|
||||
'pause:or("true","false")' \
|
||||
'connect_timeout:uinteger' \
|
||||
'max_download_limit:string' \
|
||||
'lowest_speed_limit:string' \
|
||||
'bt_max_open_files:uinteger' \
|
||||
'bt_prioritize_piece:string' \
|
||||
'Pro:string:/usr/share/aria2' \
|
||||
'force_save:or("true","false")' \
|
||||
'rpc_secure:or("true","false")' \
|
||||
'save_session_interval:uinteger' \
|
||||
'enable_dht6:or("true","false")' \
|
||||
'disable_ipv6:or("true","false")' \
|
||||
'max_overall_upload_limit:string' \
|
||||
'all_proxy_user:string' \
|
||||
'auto_save_interval:range(0,600)' \
|
||||
'bt_enable_lpd:or("true","false")' \
|
||||
'config_dir:string:/var/etc/aria2' \
|
||||
'http_no_cache:or("true","false")' \
|
||||
'max_concurrent_downloads:uinteger' \
|
||||
'rpc_listen_port:range(1024,65535)' \
|
||||
'pause_metadata:or("true","false")' \
|
||||
'max_overall_download_limit:string' \
|
||||
'enable_dht:or("true","false"):true' \
|
||||
'check_integrity:or("true","false")' \
|
||||
'bt_request_peer_speed_limit:string' \
|
||||
'max_connection_per_server:uinteger' \
|
||||
'bt_save_metadata:or("true","false")' \
|
||||
'http_accept_gzip:or("true","false")' \
|
||||
'bt_seed_unverified:or("true","false")' \
|
||||
'bt_detach_seed_only:or("true","false")' \
|
||||
'follow_torrent:or("true","false","mem")' \
|
||||
'enable_peer_exchange:or("true","false")' \
|
||||
'bt_load_saved_metadata:or("true","false")' \
|
||||
'check_certificate:or("true","false"):true' \
|
||||
'bt_prioritize_piece:string' \
|
||||
'bt_max_open_files:uinteger' \
|
||||
'bt_max_peers:uinteger' \
|
||||
'bt_remove_unselected_file:or("true","false")' \
|
||||
'rpc_auth_method:or("none","user_pass","token")' \
|
||||
'log_level:or("debug","info","notice","warn","error")' \
|
||||
'bt_request_peer_speed_limit:string' \
|
||||
'bt_save_metadata:or("true","false")' \
|
||||
'bt_seed_unverified:or("true","false")' \
|
||||
'bt_stop_timeout:uinteger' \
|
||||
'bt_tracker:list(string)' \
|
||||
'ca_certificate:file' \
|
||||
'certificate:file' \
|
||||
'check_certificate:or("true","false"):true' \
|
||||
'check_integrity:or("true","false")' \
|
||||
'connect_timeout:uinteger' \
|
||||
'dht_listen_port:string' \
|
||||
'dir:string' \
|
||||
'disable_ipv6:or("true","false")' \
|
||||
'disk_cache:string' \
|
||||
'enable_dht:or("true","false"):true' \
|
||||
'enable_dht6:or("true","false")' \
|
||||
'enable_peer_exchange:or("true","false")' \
|
||||
'event_poll:or("epoll","kqueue","port","poll","select")' \
|
||||
'file_allocation:or("none","prealloc","trunc","falloc")'
|
||||
'file_allocation:or("none","prealloc","trunc","falloc")' \
|
||||
'follow_torrent:or("true","false","mem")' \
|
||||
'force_save:or("true","false")' \
|
||||
'http_accept_gzip:or("true","false")' \
|
||||
'http_no_cache:or("true","false")' \
|
||||
'listen_port:string' \
|
||||
'log:string' \
|
||||
'log_level:or("debug","info","notice","warn","error")' \
|
||||
'lowest_speed_limit:string' \
|
||||
'max_concurrent_downloads:uinteger' \
|
||||
'max_connection_per_server:uinteger' \
|
||||
'max_download_limit:string' \
|
||||
'max_overall_download_limit:string' \
|
||||
'max_overall_upload_limit:string' \
|
||||
'max_tries:uinteger' \
|
||||
'max_upload_limit:string' \
|
||||
'min_split_size:string' \
|
||||
'pause:or("true","false")' \
|
||||
'pause_metadata:or("true","false")' \
|
||||
'peer_id_prefix:string' \
|
||||
'private_key:file' \
|
||||
'retry_wait:uinteger' \
|
||||
'rpc_auth_method:or("none","user_pass","token")' \
|
||||
'rpc_certificate:file' \
|
||||
'rpc_listen_port:range(1024,65535)' \
|
||||
'rpc_passwd:string' \
|
||||
'rpc_private_key:file' \
|
||||
'rpc_secret:string' \
|
||||
'rpc_secure:or("true","false")' \
|
||||
'rpc_user:string' \
|
||||
'save_session_interval:uinteger' \
|
||||
'seed_ratio:ufloat' \
|
||||
'seed_time:ufloat' \
|
||||
'split:uinteger' \
|
||||
'timeout:uinteger' \
|
||||
'user_agent:string'
|
||||
}
|
||||
|
||||
aria2_start() {
|
||||
local section="$1"
|
||||
[ "$2" = "0" ] || { _info "验证失败。"; return 1; }
|
||||
[ "$enabled" = "1" ] || { _info "实例 \"$section\" 已禁用。"; return 1; }
|
||||
if [ "$enable_Pro" == 1 ]; then
|
||||
a="$Pro"
|
||||
_make_dir "$Pro"
|
||||
else
|
||||
_make_dir "$config_dir"
|
||||
a="$config_dir"
|
||||
[ -d "$Pro" ] && rm -rf "$Pro" && _info "扩展功能已关闭,删除原来的$Pro目录"
|
||||
if [ ! -f "$a"/dht.dat ] && [ ."$enable_dht" = ."true" ]; then
|
||||
dht_file="$a/dht.dat"
|
||||
_create_file "$dht_file" || {
|
||||
_info "无法创建DHT文件: $dht_file"
|
||||
return 1; }
|
||||
append_setting "enable-dht=true"
|
||||
append_setting "dht-file-path=$dht_file"
|
||||
fi
|
||||
fi
|
||||
[ -n "$dir" ] && _make_dir "$dir" || { _info "请设置下载目录。"; return 1; }
|
||||
aria2_start() {
|
||||
local section="$1"
|
||||
[ "$2" = "0" ] || { _err "Validation failed."; return 1; }
|
||||
|
||||
config_file="$a/$NAME.conf.$section"
|
||||
config_file_tmp="$a/$NAME.conf.tmp"
|
||||
session_file="$a/$NAME.session"
|
||||
[ "$enabled" = "1" ] || { _info "Instance \"$section\" disabled."; return 1; }
|
||||
[ -n "$dir" ] || { _err "Please set download dir."; return 1; }
|
||||
[ -d "$dir" ] || _make_dir "$dir" || {
|
||||
_err "Can't create download dir: $dir"
|
||||
return 1
|
||||
}
|
||||
|
||||
config_file="$config_dir/$NAME.conf.$section"
|
||||
config_file_tmp="$config_dir/$NAME.conf.tmp"
|
||||
session_file="$config_dir/$NAME.session.$section"
|
||||
|
||||
_make_dir "$config_dir" || {
|
||||
_err "Can't create config dir: $config_dir"
|
||||
return 1
|
||||
}
|
||||
|
||||
_create_file "$session_file" "$config_file" "$config_file_tmp" || {
|
||||
_info "无法创建$session_file, $config_file, $config_file_tmp的目录。"
|
||||
return 1; }
|
||||
_err "Can't create files: $session_file, $config_file, $config_file_tmp"
|
||||
return 1
|
||||
}
|
||||
|
||||
# 创建tmp文件
|
||||
# create tmp file
|
||||
cat >"$config_file_tmp" <<-EOF
|
||||
|
||||
#===以下是系统生成,对此文件修改将无法正常运行===#
|
||||
|
||||
# Auto generated file, changes to this file will be lost.
|
||||
EOF
|
||||
|
||||
append_setting "dir=$dir"
|
||||
@ -202,7 +193,7 @@ aria2_validate() {
|
||||
append_setting "quiet=true"
|
||||
append_setting "continue=true"
|
||||
append_setting "input-file=$session_file"
|
||||
append_setting "save-session=$a/$NAME.session"
|
||||
append_setting "save-session=$session_file"
|
||||
|
||||
if [ -z "$enable_logging" ]; then
|
||||
append_options "log" "log_level"
|
||||
@ -212,9 +203,14 @@ aria2_validate() {
|
||||
local log_dir
|
||||
log_dir="$(dirname "$log")"
|
||||
|
||||
_make_dir "$log_dir"
|
||||
_make_dir "$log_dir" || {
|
||||
_err "Can't create log dir: $log_dir"
|
||||
return 1
|
||||
}
|
||||
|
||||
# create or clear log file
|
||||
echo >"$log"
|
||||
|
||||
append_setting "log=$log"
|
||||
append_options "log_level"
|
||||
fi
|
||||
@ -237,7 +233,7 @@ aria2_validate() {
|
||||
append_setting "rpc-user=$rpc_user"
|
||||
append_setting "rpc-passwd=$rpc_passwd"
|
||||
else
|
||||
_info "建议设置RPC密码。"
|
||||
_info "It is recommended to set RPC secret."
|
||||
fi
|
||||
elif [ "$rpc_auth_method" = "token" ]; then
|
||||
if [ -n "$rpc_secret" ]; then
|
||||
@ -250,7 +246,7 @@ aria2_validate() {
|
||||
append_setting "rpc-user=$rpc_user"
|
||||
append_setting "rpc-passwd=$rpc_passwd"
|
||||
else
|
||||
_info "请设置RPC用户。"
|
||||
_info "Please set RPC user."
|
||||
unset_auth_method
|
||||
fi
|
||||
fi
|
||||
@ -267,11 +263,24 @@ aria2_validate() {
|
||||
append_setting "check-certificate=false"
|
||||
fi
|
||||
|
||||
if [ ."$enable_dht" = ."true" ]; then
|
||||
dht_file="$config_dir/dht.dat.$section"
|
||||
_create_file "$dht_file" || {
|
||||
_err "Can't create DHT file: $dht_file"
|
||||
return 1
|
||||
}
|
||||
|
||||
append_setting "enable-dht=true"
|
||||
append_setting "dht-file-path=$dht_file"
|
||||
fi
|
||||
|
||||
if [ ."$enable_dht6" = ."true" ] && [ ."$disable_ipv6" != ."true" ]; then
|
||||
dht6_file="$a/dht6.dat"
|
||||
dht6_file="$config_dir/dht6.dat.$section"
|
||||
_create_file "$dht6_file" || {
|
||||
_info "无法创建DHT6文件:$dht6_file"
|
||||
return 1; }
|
||||
_err "Can't create DHT6 file: $dht6_file"
|
||||
return 1
|
||||
}
|
||||
|
||||
append_setting "enable-dht6=true"
|
||||
append_setting "dht-file-path6=$dht6_file"
|
||||
fi
|
||||
@ -285,59 +294,42 @@ aria2_validate() {
|
||||
bt_tracker_list="$bt_tracker_list,$t"
|
||||
fi
|
||||
done
|
||||
|
||||
append_setting "bt-tracker=$bt_tracker_list"
|
||||
fi
|
||||
|
||||
append_options "auto_save_interval" "bt_enable_lpd" "bt_max_open_files" "bt_max_peers" \
|
||||
"bt_remove_unselected_file" "bt_request_peer_speed_limit" "pause" "bt_prioritize_piece" \
|
||||
"bt_remove_unselected_file" "bt_request_peer_speed_limit" "bt_prioritize_piece" \
|
||||
"bt_stop_timeout" "bt_detach_seed_only" "bt_save_metadata" "bt_load_saved_metadata" \
|
||||
"bt_seed_unverified" "certificate" "check_integrity" "connect_timeout" "dht_listen_port" \
|
||||
"disable_ipv6" "disk_cache" "enable_peer_exchange" "event_poll" "file_allocation" \
|
||||
"follow_torrent" "force_save" "http_accept_gzip" "http_no_cache" "listen_port" "split" \
|
||||
"lowest_speed_limit" "max_concurrent_downloads" "max_connection_per_server" "user_agent" \
|
||||
"follow_torrent" "force_save" "http_accept_gzip" "http_no_cache" "listen_port" \
|
||||
"lowest_speed_limit" "max_concurrent_downloads" "max_connection_per_server" \
|
||||
"max_download_limit" "max_overall_download_limit" "max_overall_upload_limit" "max_tries" \
|
||||
"max_upload_limit" "min_split_size" "pause_metadata" "peer_id_prefix" "private_key" \
|
||||
"retry_wait" "rpc_listen_port" "save_session_interval" "seed_ratio" "seed_time" "timeout"
|
||||
"max_upload_limit" "min_split_size" "pause" "pause_metadata" "peer_id_prefix" "private_key" \
|
||||
"retry_wait" "rpc_listen_port" "save_session_interval" "seed_ratio" "seed_time" "split" "timeout" \
|
||||
"user_agent"
|
||||
|
||||
config_list_foreach "$section" "header" append_header
|
||||
config_list_foreach "$section" "extra_settings" append_setting
|
||||
|
||||
# Download_Pro_conf
|
||||
if [ "$enable_Pro" = "1" ]; then
|
||||
cd $Pro
|
||||
if for i in aria2.conf clean.sh delete.sh tracker.sh dht.dat; do
|
||||
if [ ! -s $i ]; then
|
||||
wget -N -t2 -T3 https://raw.githubusercontent.com/P3TERX/aria2.conf/master/$i || \
|
||||
wget -N -t2 -T3 https://cdn.jsdelivr.net/gh/P3TERX/aria2.conf/$i || \
|
||||
curl -fsSLO https://p3terx.github.io/aria2.conf/$i || \
|
||||
curl -fsSLO https://gh.p3terx.workers.dev/aria2.conf/master/$i
|
||||
[ -s $i ] && _info "附加功能脚本[ $i ]文件下载成功 !" || _info "[ $i ] 配置文件下载失败 !"
|
||||
fi
|
||||
done
|
||||
sed -i -e 's|NLOAD_PATH=.*|NLOAD_PATH='"'$dir'"'|g' -e 's|dir=.*|dir='"$dir"'|g' \
|
||||
-e 's|/root/.aria2|'"$Pro"'|g' -e 's|#!.*|#!/bin/sh|g' -e '/et=P3TERX/d' \
|
||||
-e 's|${F.*X}||g' -e 's|${G.*EFIX}||g' -e 's|${R.*EFIX}||g' -e 's|${Y.*EFIX}||g' \
|
||||
-e 's|${L.*EFIX}||g' "$Pro"/* 2>/dev/null; then
|
||||
_info "Aria2加强配置下载完成!"; fi
|
||||
chmod +x *.sh && sh ./tracker.sh
|
||||
cat aria2.conf > "$config_file"
|
||||
sed '/^$/d' "$config_file_tmp" >> "$config_file"
|
||||
else
|
||||
sed '/^$/d' "$config_file_tmp" > "$config_file"
|
||||
fi
|
||||
|
||||
cd /usr/share/aria2 && sh ./tracker.sh >/dev/null 2>&1 &
|
||||
cat /usr/share/aria2/aria2.conf > "$config_file"
|
||||
echo '' >> "$config_file"
|
||||
sed '/^$/d' "$config_file_tmp" >> "$config_file"
|
||||
rm -f "$config_file_tmp"
|
||||
|
||||
_reset_dir_mode "$config_dir"
|
||||
_change_file_mode 600 "$config_file"
|
||||
|
||||
if [ -n "$user" ]; then
|
||||
if ( user_exists "$user" && _change_owner "$user" "$a" "$log" ); then
|
||||
_info "Aria2将以<code>"$user"</code>的用户身份运行。"
|
||||
if ( user_exists "$user" && _change_owner "$user" "$config_dir" "$log" ); then
|
||||
_info "Aria2 will run with user '$user'."
|
||||
if [ "$user" != "root" ]; then
|
||||
_info "请确保用户$user具有下载目录$dir的写入权限。"
|
||||
_info "Please make sure user '$user' has write access to download dir: $dir"
|
||||
fi
|
||||
else
|
||||
_info "设置$user用户运行失败,使用默认用户。"
|
||||
_info "Setting run user to '$user' failed, default user will be used."
|
||||
user=
|
||||
fi
|
||||
fi
|
||||
@ -355,10 +347,9 @@ aria2_validate() {
|
||||
procd_set_param user "$user"
|
||||
|
||||
procd_add_jail "$NAME.$section" log
|
||||
procd_add_jail_mount "$config_file"
|
||||
procd_add_jail_mount_rw "$dir" "$a" "$log"
|
||||
procd_add_jail_mount "$ca_certificate" "$certificate" "$rpc_certificate" "$rpc_private_key"
|
||||
procd_add_jail_mount_rw "$dir" "$config_dir" "$log"
|
||||
procd_close_instance
|
||||
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
|
123
aria2/patches/0004-Disable-auto-added-Want-Digest-header.patch
Normal file
123
aria2/patches/0004-Disable-auto-added-Want-Digest-header.patch
Normal file
@ -0,0 +1,123 @@
|
||||
From b938aa51e50852d1b185db3188357073ad374416 Mon Sep 17 00:00:00 2001
|
||||
From: myfreeer <myfreeer@users.noreply.github.com>
|
||||
Date: Sun, 13 Dec 2020 15:40:56 +0800
|
||||
Subject: [PATCH] option: add option to disable Want-Digest header
|
||||
|
||||
Sending this HTTP header should be optional.
|
||||
Should close https://github.com/myfreeer/aria2-build-msys2/issues/10
|
||||
|
||||
--http-want-digest[=true|false] Send Want-Digest HTTP requser header
|
||||
with only limited hash algorithms:
|
||||
SHA-512, SHA-256, and SHA-1.
|
||||
The Want-Digest HTTP header is primarily used
|
||||
in a HTTP request, to ask the responder to
|
||||
provide a digest of the requested resource
|
||||
using the Digest response header
|
||||
|
||||
Possible Values: true, false
|
||||
Default: false
|
||||
Tags: #advanced, #http
|
||||
---
|
||||
src/AbstractProxyRequestCommand.cc | 1 +
|
||||
src/HttpRequestCommand.cc | 1 +
|
||||
src/OptionHandlerFactory.cc | 12 ++++++++++++
|
||||
src/prefs.cc | 2 ++
|
||||
src/prefs.h | 2 ++
|
||||
src/usage_text.h | 8 ++++++++
|
||||
6 files changed, 26 insertions(+)
|
||||
|
||||
diff --git a/src/AbstractProxyRequestCommand.cc b/src/AbstractProxyRequestCommand.cc
|
||||
index bd2bcb3..1feed07 100644
|
||||
--- a/src/AbstractProxyRequestCommand.cc
|
||||
+++ b/src/AbstractProxyRequestCommand.cc
|
||||
@@ -72,6 +72,7 @@ bool AbstractProxyRequestCommand::executeInternal()
|
||||
if (httpConnection_->sendBufferIsEmpty()) {
|
||||
auto httpRequest = make_unique<HttpRequest>();
|
||||
httpRequest->setUserAgent(getOption()->get(PREF_USER_AGENT));
|
||||
+ httpRequest->setNoWantDigest(!getOption()->getAsBool(PREF_HTTP_WANT_DIGEST));
|
||||
httpRequest->setRequest(getRequest());
|
||||
httpRequest->setProxyRequest(proxyRequest_);
|
||||
|
||||
diff --git a/src/HttpRequestCommand.cc b/src/HttpRequestCommand.cc
|
||||
index a2b8e7e..8c50153 100644
|
||||
--- a/src/HttpRequestCommand.cc
|
||||
+++ b/src/HttpRequestCommand.cc
|
||||
@@ -90,6 +90,7 @@ createHttpRequest(const std::shared_ptr<Request>& req,
|
||||
{
|
||||
auto httpRequest = make_unique<HttpRequest>();
|
||||
httpRequest->setUserAgent(option->get(PREF_USER_AGENT));
|
||||
+ httpRequest->setNoWantDigest(!option->getAsBool(PREF_HTTP_WANT_DIGEST));
|
||||
httpRequest->setRequest(req);
|
||||
httpRequest->setFileEntry(fileEntry);
|
||||
httpRequest->setSegment(segment);
|
||||
diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc
|
||||
index a058eb9..9ff615a 100644
|
||||
--- a/src/OptionHandlerFactory.cc
|
||||
+++ b/src/OptionHandlerFactory.cc
|
||||
@@ -1106,6 +1106,18 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
|
||||
op->setChangeOptionForReserved(true);
|
||||
handlers.push_back(op);
|
||||
}
|
||||
+ {
|
||||
+ OptionHandler* op(
|
||||
+ new BooleanOptionHandler(PREF_HTTP_WANT_DIGEST,
|
||||
+ TEXT_HTTP_WANT_DIGEST,
|
||||
+ A2_V_FALSE, OptionHandler::OPT_ARG));
|
||||
+ op->addTag(TAG_ADVANCED);
|
||||
+ op->addTag(TAG_HTTP);
|
||||
+ op->setInitialOption(true);
|
||||
+ op->setChangeGlobalOption(true);
|
||||
+ op->setChangeOptionForReserved(true);
|
||||
+ handlers.push_back(op);
|
||||
+ }
|
||||
{
|
||||
OptionHandler* op(new BooleanOptionHandler(
|
||||
PREF_ENABLE_HTTP_KEEP_ALIVE, TEXT_ENABLE_HTTP_KEEP_ALIVE, A2_V_TRUE,
|
||||
diff --git a/src/prefs.cc b/src/prefs.cc
|
||||
index 9793706..bdb33e2 100644
|
||||
--- a/src/prefs.cc
|
||||
+++ b/src/prefs.cc
|
||||
@@ -437,6 +437,8 @@ PrefPtr PREF_HTTP_ACCEPT_GZIP = makePref("http-accept-gzip");
|
||||
// value: true | false
|
||||
PrefPtr PREF_CONTENT_DISPOSITION_DEFAULT_UTF8 =
|
||||
makePref("content-disposition-default-utf8");
|
||||
+// values: true | false
|
||||
+PrefPtr PREF_HTTP_WANT_DIGEST = makePref("http-want-digest");
|
||||
|
||||
/**
|
||||
* Proxy related preferences
|
||||
diff --git a/src/prefs.h b/src/prefs.h
|
||||
index f014d9c..c88f2d0 100644
|
||||
--- a/src/prefs.h
|
||||
+++ b/src/prefs.h
|
||||
@@ -389,6 +389,8 @@ extern PrefPtr PREF_HTTP_NO_CACHE;
|
||||
extern PrefPtr PREF_HTTP_ACCEPT_GZIP;
|
||||
// value: true | false
|
||||
extern PrefPtr PREF_CONTENT_DISPOSITION_DEFAULT_UTF8;
|
||||
+// value: true | false
|
||||
+extern PrefPtr PREF_HTTP_WANT_DIGEST;
|
||||
|
||||
/**;
|
||||
* Proxy related preferences
|
||||
diff --git a/src/usage_text.h b/src/usage_text.h
|
||||
index 7a0a981..aee3ac0 100644
|
||||
--- a/src/usage_text.h
|
||||
+++ b/src/usage_text.h
|
||||
@@ -560,6 +560,14 @@
|
||||
" Content-Disposition header as UTF-8 instead of\n" \
|
||||
" ISO-8859-1, for example, the filename parameter,\n" \
|
||||
" but not the extended version filename*.")
|
||||
+#define TEXT_HTTP_WANT_DIGEST \
|
||||
+ _(" --http-want-digest[=true|false] Send Want-Digest HTTP requser header\n" \
|
||||
+ " with only limited hash algorithms:\n" \
|
||||
+ " SHA-512, SHA-256, and SHA-1.\n" \
|
||||
+ " The Want-Digest HTTP header is primarily used\n" \
|
||||
+ " in a HTTP request, to ask the responder to\n" \
|
||||
+ " provide a digest of the requested resource\n" \
|
||||
+ " using the Digest response header")
|
||||
#define TEXT_EVENT_POLL \
|
||||
_(" --event-poll=POLL Specify the method for polling events.")
|
||||
#define TEXT_BT_EXTERNAL_IP \
|
||||
--
|
||||
2.29.2
|
||||
|
Loading…
Reference in New Issue
Block a user