Merge Mainline

This commit is contained in:
AmadeusGhost 2021-02-25 12:25:05 +08:00
commit 40ae41824c
57 changed files with 915 additions and 10669 deletions

View File

@ -90,7 +90,7 @@ endef
define gettext_version_target
(cd $(PKG_BUILD_DIR) && \
GETTEXT_VERSION=$(shell $(STAGING_DIR_HOSTPKG)/bin/gettext -V | $(STAGING_DIR_HOST)/bin/sed -ne '1s/.*\([0-9]\.[0-9]\{2\}\.[0-9]\).*/\1/p' ) && \
GETTEXT_VERSION=$(shell $(STAGING_DIR_HOSTPKG)/bin/gettext -V | $(STAGING_DIR_HOST)/bin/sed -rne '1s/.*\b([0-9]\.[0-9]+(\.[0-9]+)?)\b.*/\1/p' ) && \
$(STAGING_DIR_HOST)/bin/sed \
-i $(PKG_BUILD_DIR)/configure.ac \
-e "s/AM_GNU_GETTEXT_VERSION(.*)/AM_GNU_GETTEXT_VERSION(\[$$$$GETTEXT_VERSION\])/g" && \

View File

@ -467,7 +467,8 @@ endef
ifndef IB
define Device/Build/initramfs
$(call Device/Export,$(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE),$(1))
$$(_TARGET): $$(if $$(KERNEL_INITRAMFS),$(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE))
$$(_TARGET): $$(if $$(KERNEL_INITRAMFS),$(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE) \
$$(if $$(CONFIG_JSON_OVERVIEW_IMAGE_INFO), $(BUILD_DIR)/json_info_files/$$(KERNEL_INITRAMFS_IMAGE).json,))
$(KDIR)/$$(KERNEL_INITRAMFS_NAME):: image_prepare
$(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE): $(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE)
@ -476,6 +477,38 @@ define Device/Build/initramfs
$(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE): $(KDIR)/$$(KERNEL_INITRAMFS_NAME) $(CURDIR)/Makefile $$(KERNEL_DEPENDS) image_prepare
@rm -f $$@
$$(call concat_cmd,$$(KERNEL_INITRAMFS))
$(call Device/Export,$(BUILD_DIR)/json_info_files/$$(KERNEL_INITRAMFS_IMAGE).json,$(1))
$(BUILD_DIR)/json_info_files/$$(KERNEL_INITRAMFS_IMAGE).json: $(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE)
@mkdir -p $$(shell dirname $$@)
DEVICE_ID="$(1)" \
BIN_DIR="$(BIN_DIR)" \
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
IMAGE_NAME="$$(notdir $$^)" \
IMAGE_TYPE="kernel" \
IMAGE_FILESYSTEM="initramfs" \
IMAGE_PREFIX="$$(IMAGE_PREFIX)" \
DEVICE_VENDOR="$$(DEVICE_VENDOR)" \
DEVICE_MODEL="$$(DEVICE_MODEL)" \
DEVICE_VARIANT="$$(DEVICE_VARIANT)" \
DEVICE_ALT0_VENDOR="$$(DEVICE_ALT0_VENDOR)" \
DEVICE_ALT0_MODEL="$$(DEVICE_ALT0_MODEL)" \
DEVICE_ALT0_VARIANT="$$(DEVICE_ALT0_VARIANT)" \
DEVICE_ALT1_VENDOR="$$(DEVICE_ALT1_VENDOR)" \
DEVICE_ALT1_MODEL="$$(DEVICE_ALT1_MODEL)" \
DEVICE_ALT1_VARIANT="$$(DEVICE_ALT1_VARIANT)" \
DEVICE_ALT2_VENDOR="$$(DEVICE_ALT2_VENDOR)" \
DEVICE_ALT2_MODEL="$$(DEVICE_ALT2_MODEL)" \
DEVICE_ALT2_VARIANT="$$(DEVICE_ALT2_VARIANT)" \
DEVICE_TITLE="$$(DEVICE_TITLE)" \
DEVICE_PACKAGES="$$(DEVICE_PACKAGES)" \
TARGET="$(BOARD)" \
SUBTARGET="$(if $(SUBTARGET),$(SUBTARGET),generic)" \
VERSION_NUMBER="$(VERSION_NUMBER)" \
VERSION_CODE="$(VERSION_CODE)" \
SUPPORTED_DEVICES="$$(SUPPORTED_DEVICES)" \
$(TOPDIR)/scripts/json_add_image_info.py $$@
endef
endif

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-openclash
PKG_VERSION:=0.41.14
PKG_VERSION:=0.42.01
PKG_RELEASE:=beta
PKG_MAINTAINER:=vernesong <https://github.com/vernesong/OpenClash>

View File

@ -144,10 +144,21 @@ o:value("debug", translate("Debug Mode"))
o:value("silent", translate("Silent Mode"))
o.default = "silent"
o = s:taboption("settings", Value, "log_size", translate("Log Size (KB)"))
o.description = translate("Set Log File Size (KB)")
o.default=1024
o = s:taboption("settings", Flag, "intranet_allowed", translate("Only intranet allowed"))
o.description = translate("When Enabled, The Control Panel And The Connection Broker Port Will Not Be Accessible From The Public Network")
o.default=0
o = s:taboption("settings", Value, "dns_port")
o.title = translate("DNS Port")
o.default = 7874
o.datatype = "port"
o.rmempty = false
o.description = translate("Please Make Sure Ports Available")
o = s:taboption("settings", Value, "proxy_port")
o.title = translate("Redir Port")
o.default = 7892

View File

@ -3,14 +3,17 @@
<fieldset class="cbi-section">
<table width="100%">
<tr>
<td width="33%" align="center">
<td width="25%" align="center">
<input type="button" class="cbi-button cbi-button-apply" id="stop_refresh_button" value="<%:Stop Refresh Log%>" onclick=" return stop_refresh() "/>
</td>
<td width="33%" align="center">
<td width="25%" align="center">
<input type="button" class="cbi-button cbi-button-apply" id="start_refresh_button" value="<%:Start Refresh Log%>" onclick=" return start_refresh() "/>
</td>
<td width="33%" align="center">
<input type="button" class="cbi-button cbi-button-apply" id="del_log_button" value="<%:Clean Log%>" style=" display:inline;" onclick=" return del_log()" />
<td width="25%" align="center">
<input type="button" class="cbi-button cbi-button-apply" id="del_log_button" value="<%:Clean Log%>" style=" display:inline;" onclick=" return del_log() " />
</td>
<td width="25%" align="center">
<input type="button" class="cbi-button cbi-button-apply" id="down_log_button" value="<%:Download Log%>" style=" display:inline;" onclick=" return download_log() " />
</td>
</tr>
</table>
@ -30,6 +33,22 @@ function start_refresh() {
return
}
function createAndDownloadFile(fileName, content) {
var aTag = document.createElement('a');
var blob = new Blob([content]);
aTag.download = fileName;
aTag.href = URL.createObjectURL(blob);
aTag.click();
URL.revokeObjectURL(blob);
}
function download_log(){
var lv = document.getElementById('cbid.openclash.config.clog');
var dt = new Date();
var timestamp = dt.getFullYear()+"-"+(dt.getMonth()+1)+"-"+dt.getDate()+"-"+dt.getHours()+"-"+dt.getMinutes()+"-"+dt.getSeconds();
createAndDownloadFile("OpenClash-"+timestamp+".log",lv.innerHTML)
return
}
function del_log() {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "del_log")%>',null,function(x, data){
var lv = document.getElementById('cbid.openclash.config.clog');

View File

@ -1438,4 +1438,16 @@ msgid "Restart Time (Every Week)"
msgstr "重启时间(每周)"
msgid "Restart time (every day)"
msgstr "重启时间(每天)"
msgstr "重启时间(每天)"
msgid "DNS Port"
msgstr "DNS监听端口"
msgid "Log Size (KB)"
msgstr "日志大小KB"
msgid "Set Log File Size (KB)"
msgstr "设置日志文件大小KB"
msgid "Download Log"
msgstr "下载日志"

View File

@ -4,6 +4,7 @@ config openclash 'config'
option mixed_port '7893'
option socks_port '7891'
option http_port '7890'
option dns_port '7874'
option enable '0'
option update '0'
option en_mode '0'
@ -34,6 +35,7 @@ config openclash 'config'
option small_flash_memory '0'
option interface_name '0'
option common_ports '0'
option log_size '1024'
option geo_custom_url 'http://www.ideame.top/mmdb/Country.mmdb'
option chnr_custom_url 'https://ispip.clang.cn/all_cn.txt'

View File

@ -24,13 +24,13 @@ PROXY_FWMARK="0x162"
PROXY_ROUTE_TABLE="0x162"
set_lock() {
exec 888>"$LOCK_FILE" 2>/dev/null
flock -x 888 2>/dev/null
exec 888>"$LOCK_FILE" 2>/dev/null
flock -x 888 2>/dev/null
}
del_lock() {
flock -u 888 2>/dev/null
rm -rf "$LOCK_FILE" 2>/dev/null
flock -u 888 2>/dev/null
rm -rf "$LOCK_FILE" 2>/dev/null
}
add_cron()
@ -139,27 +139,9 @@ start_fail()
exit 0
}
yml_check()
{
#创建原始备份
if [ ! -f "$2" ]; then
cp "$1" "$2"
fi
dns_port="$(ruby_read "$1" "['dns']['listen'].split(':')[1]")"
if [ -z "$dns_port" ] || [ "$dns_port" -eq 53 ]; then
dns_port=7874
fi
#保存DNS端口方便后续调用
uci set openclash.config.dns_port="$dns_port" && uci commit openclash
}
yml_dns_check()
{
#检查DNS服务
#检查DNS服务
if [ -z "$(ruby_read "$1" "['dns']['nameserver']")" ]; then
echo "检测到DNS选项下的Nameserver未设置服务器开始补全..." >$START_LOG
echo " nameserver:" > "$DNS_FILE" 2>/dev/null
@ -946,17 +928,22 @@ do_run_file()
sleep 5
start_fail
fi
#创建原始备份
if [ ! -f "$2" ]; then
cp "$1" "$2"
fi
}
#绑定interface防止回环
check_interface_name()
{
if [ -n "$interface_name" ] && [ "$interface_name" != "0" ]; then
ruby_edit "$CONFIG_FILE" "['interface-name']='$interface_name'"
else
sed -i "/^interface-name:/d" "$CONFIG_FILE" 2>/dev/null
fi
if [ -n "$interface_name" ] && [ "$interface_name" != "0" ]; then
ruby_edit "$CONFIG_FILE" "['interface-name']='$interface_name'"
else
sed -i "/^interface-name:/d" "$CONFIG_FILE" 2>/dev/null
fi
}
start_run_core()
@ -1341,7 +1328,7 @@ if [ -z "$en_mode_tun" ] || [ "$en_mode_tun" -eq 3 ]; then
iptables -t mangle -A openclash -m set --match-set china_ip_route dst -j RETURN >/dev/null 2>&1
fi
iptables -t mangle -A openclash -p udp --dport 53 -j RETURN >/dev/null 2>&1
iptables -t mangle -A openclash -p udp -j TPROXY --on-port "$proxy_port" --on-ip 0.0.0.0 --tproxy-mark "$PROXY_FWMARK"
iptables -t mangle -A openclash -p udp -j TPROXY --on-port "$proxy_port" --tproxy-mark "$PROXY_FWMARK"
iptables -t mangle -A PREROUTING -p udp -j openclash
fi
fi
@ -1605,6 +1592,8 @@ get_config()
mixed_port=$(uci get openclash.config.mixed_port 2>/dev/null)
interface_name=$(uci get openclash.config.interface_name 2>/dev/null)
common_ports=$(uci get openclash.config.common_ports 2>/dev/null)
dns_port=$(uci get openclash.config.dns_port 2>/dev/null)
[ -z "$dns_port" ] && dns_port=7874 && uci set openclash.config.dns_port=7874 2>/dev/null
uci set openclash.config.restricted_mode=0 && uci commit openclash
}
@ -1622,11 +1611,9 @@ start()
echo "第一步: 获取配置..." >$START_LOG
get_config
echo "第二步: 组件运行前检查..." >$START_LOG
#检查文件是否存在
do_run_file
echo "第二步: 配置文件检查..." >$START_LOG
yml_check "$CONFIG_FILE" "$BACKUP_FILE"
do_run_file "$CONFIG_FILE" "$BACKUP_FILE"
echo "第三步: 修改配置文件..." >$START_LOG
config_load "openclash"
@ -1746,7 +1733,7 @@ restart()
[ -f "$LOCK_FILE" ] && echo "${LOGTIME} Warning: Multiple Restart Scripts Running, Exit..." >> $LOG_FILE && exit 0
mkdir -p /tmp/lock
touch $LOCK_FILE
set_lock
set_lock
stop
start
del_lock

View File

@ -1,17 +0,0 @@
{
"files": {
"main.css": "./static/css/main.a3812757.chunk.css",
"main.js": "./static/js/main.8e23a89d.chunk.js",
"runtime-main.js": "./static/js/runtime-main.b905e4f3.js",
"static/js/2.d14c2fca.chunk.js": "./static/js/2.d14c2fca.chunk.js",
"index.html": "./index.html",
"static/js/2.d14c2fca.chunk.js.LICENSE.txt": "./static/js/2.d14c2fca.chunk.js.LICENSE.txt",
"static/media/logo.45983944.png": "./static/media/logo.45983944.png"
},
"entrypoints": [
"static/js/runtime-main.b905e4f3.js",
"static/js/2.d14c2fca.chunk.js",
"static/css/main.a3812757.chunk.css",
"static/js/main.8e23a89d.chunk.js"
]
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1,22 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" type="image/x-icon" href="https://cdn.jsdelivr.net/gh/Dreamacro/clash/docs/logo.png"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"/><meta name="description" content="Clash web port"/><title>Clash</title><link href="./static/css/main.a3812757.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,a,l=r[0],f=r[1],i=r[2],p=0,s=[];p<l.length;p++)a=l[p],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&s.push(o[a][0]),o[a]=0;for(n in f)Object.prototype.hasOwnProperty.call(f,n)&&(e[n]=f[n]);for(c&&c(r);s.length;)s.shift()();return u.push.apply(u,i||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var f=t[l];0!==o[f]&&(n=!1)}n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={1:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,function(r){return e[r]}.bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="./";var l=this["webpackJsonpclash-dashboard"]=this["webpackJsonpclash-dashboard"]||[],f=l.push.bind(l);l.push=r,l=l.slice();for(var i=0;i<l.length;i++)r(l[i]);var c=f;t()}([])</script><script src="./static/js/2.d14c2fca.chunk.js"></script><script src="./static/js/main.8e23a89d.chunk.js"></script></body></html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" type="image/x-icon" href="https://cdn.jsdelivr.net/gh/Dreamacro/clash/docs/logo.png" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Clash web port"
/>
<title>Clash</title>
<script type="module" crossorigin src="./assets/index.236bee55.js"></script>
<link rel="modulepreload" href="./assets/vendor.b176d855.js">
<link rel="stylesheet" href="./assets/index.5dfcf857.css">
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>

View File

@ -1,56 +0,0 @@
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
/*!
Copyright (c) 2017 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/
/**
* @license
* Lodash <https://lodash.com/>
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/
/** @license React v0.20.1
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v16.13.1
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v17.0.1
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v17.0.1
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

View File

@ -1 +0,0 @@
!function(e){function r(r){for(var n,a,l=r[0],f=r[1],i=r[2],p=0,s=[];p<l.length;p++)a=l[p],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&s.push(o[a][0]),o[a]=0;for(n in f)Object.prototype.hasOwnProperty.call(f,n)&&(e[n]=f[n]);for(c&&c(r);s.length;)s.shift()();return u.push.apply(u,i||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var f=t[l];0!==o[f]&&(n=!1)}n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={1:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"===typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,function(r){return e[r]}.bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="./";var l=this["webpackJsonpclash-dashboard"]=this["webpackJsonpclash-dashboard"]||[],f=l.push.bind(l);l.push=r,l=l.slice();for(var i=0;i<l.length;i++)r(l[i]);var c=f;t()}([]);

View File

@ -22,7 +22,7 @@ urlencode() {
}
GROUP_STATE() {
echo "$(curl -m 5 -w %{http_code}"\n" -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X GET http://"$LAN_IP":"$PORT"/proxies/"$1" 2>/dev/null |sed -n '$p' 2>/dev/null)"
echo "$(curl -m 2 -w %{http_code}"\n" -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X GET http://"$LAN_IP":"$PORT"/proxies/"$1" 2>/dev/null |sed -n '$p' 2>/dev/null)"
}
restore_history() {
@ -36,11 +36,11 @@ restore_history() {
GROUP_STATE_NUM=$(expr "$GROUP_STATE_NUM" + 1)
GROUP_STATE=$(GROUP_STATE "$GROUP_NAME")
done
curl -m 5 --retry 2 -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X PUT -d '{"name":"'"$NOW_NAME"'"}' http://"$LAN_IP":"$PORT"/proxies/"$GROUP_NAME" >> "$LOG_FILE"
curl -m 2 --retry 2 -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X PUT -d '{"name":"'"$NOW_NAME"'"}' http://"$LAN_IP":"$PORT"/proxies/"$GROUP_NAME" >> "$LOG_FILE"
}
close_all_conection() {
curl -m 5 --retry 2 -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X DELETE http://"$LAN_IP":"$PORT"/connections >/dev/null 2>&1
curl -m 2 -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X DELETE http://"$LAN_IP":"$PORT"/connections >/dev/null 2>&1
}
if [ -z "$CONFIG_FILE" ] || [ ! -f "$CONFIG_FILE" ]; then

View File

@ -10,6 +10,7 @@ dns_port=$(uci get openclash.config.dns_port 2>/dev/null)
disable_masq_cache=$(uci get openclash.config.disable_masq_cache 2>/dev/null)
en_mode=$(uci get openclash.config.en_mode 2>/dev/null)
cfg_update_interval=$(uci get openclash.config.config_update_interval 2>/dev/null)
log_size=$(uci get openclash.config.log_size 2>/dev/null || 1024)
CRASH_NUM=0
CFG_UPDATE_INT=0
@ -77,8 +78,8 @@ fi
## Log File Size Manage:
LOGSIZE=`ls -l /tmp/openclash.log |awk '{print int($5/1024)}'`
if [ "$LOGSIZE" -gt 90 ]; then
echo "$LOGTIME Watchdog: Size Limit, Clean Up All Log Records." > $LOG_FILE
if [ "$LOGSIZE" -gt "$log_size" ]; then
echo "$LOGTIME Watchdog: Log Size Limit, Clean Up All Log Records." > $LOG_FILE
fi
## 端口转发重启

View File

@ -89,6 +89,14 @@ hosts:
# '*.clash.dev': 127.0.0.1
# '.dev': 127.0.0.1
# 'alpha.clash.dev': '::1'
profile:
# store the `select` results in $HOME/.config/clash/.cache
# when two different configurations have groups with the same name, the selected values are shared
# set false if you don't want this behavior
store-selected: true
# open tracing exporter API
tracing: true
# DNS server settings
# This section is optional. When not present, the DNS server will be disabled.

File diff suppressed because one or more lines are too long

View File

@ -5,38 +5,38 @@ LOG_FILE="/tmp/openclash.log"
START_LOG="/tmp/openclash_start.log"
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
if [ "$14" != "1" ]; then
if [ "${14}" != "1" ]; then
controller_address="0.0.0.0"
bind_address="*"
else
controller_address=$11
bind_address=$11
controller_address=${11}
bind_address=${11}
fi
if [ -n "$(ruby_read "$7" "['tun']")" ]; then
if [ -n "$(ruby_read "$7" "['tun']['device-url']")" ]; then
if [ "$15" -eq 1 ] || [ "$15" -eq 3 ]; then
if [ "${15}" -eq 1 ] || [ "${15}" -eq 3 ]; then
uci set openclash.config.config_reload=0
fi
else
uci set openclash.config.config_reload=0
fi
else
if [ -n "$15" ]; then
if [ -n "${15}" ]; then
uci set openclash.config.config_reload=0
fi
fi
if [ -z "$15" ]; then
if [ -z "${15}" ]; then
en_mode_tun=0
else
en_mode_tun=$15
en_mode_tun=${15}
fi
if [ -z "$16" ]; then
if [ -z "${16}" ]; then
stack_type=system
else
stack_type=$16
stack_type=${16}
fi
if [ "$(ruby_read "$7" "['external-controller']")" != "$controller_address:$5" ]; then
@ -62,20 +62,20 @@ ruby -ryaml -E UTF-8 -e "
begin
Value = YAML.load_file('$7');
rescue Exception => e
puts '${LOGTIME} Load File Error: ' + e.message
puts '${LOGTIME} Load File Error: ' + e.message
end
begin
Value['redir-port']=$6;
Value['port']=$9;
Value['socks-port']=$10;
Value['mixed-port']=$19;
Value['mode']='$13';
Value['log-level']='$12';
Value['allow-lan']=true;
Value['external-controller']='$controller_address:$5';
Value['secret']='$4';
Value['bind-address']='$bind_address';
Value['external-ui']='/usr/share/openclash/dashboard';
Value['redir-port']=$6;
Value['port']=$9;
Value['socks-port']=${10};
Value['mixed-port']=${19};
Value['mode']='${13}';
Value['log-level']='${12}';
Value['allow-lan']=true;
Value['external-controller']='$controller_address:$5';
Value['secret']='$4';
Value['bind-address']='$bind_address';
Value['external-ui']='/usr/share/openclash/dashboard';
if not Value.key?('dns') then
Value_1={'dns'=>{'enable'=>true}}
Value['dns']=Value_1['dns']
@ -96,9 +96,9 @@ else
Value['dns'].delete('fake-ip-range')
end;
if $8 != 1 then
Value['dns']['listen']='127.0.0.1:$17'
Value['dns']['listen']='127.0.0.1:${17}'
else
Value['dns']['listen']='0.0.0.0:$17'
Value['dns']['listen']='0.0.0.0:${17}'
end;
Value_2={'tun'=>{'enable'=>true}};
if $en_mode_tun == 1 or $en_mode_tun == 3 then
@ -115,6 +115,12 @@ elsif $en_mode_tun == 0
Value['tun'].clear
end
end;
if not Value.key?('profile') then
Value_3={'profile'=>{'store-selected'=>true}}
Value['profile']=Value_3['profile']
else
Value['profile']['store-selected']=true
end;
rescue Exception => e
puts '${LOGTIME} Set General Error: ' + e.message
end

View File

@ -38,7 +38,7 @@
if (config && config.strict && (dir > 0) != (pos == where.ch)) return null;
var style = cm.getTokenTypeAt(Pos(where.line, pos + 1));
var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config);
var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style, config);
if (found == null) return null;
return {from: Pos(where.line, pos), to: found && found.pos,
match: found && found.ch == match.charAt(0), forward: dir > 0};
@ -67,7 +67,8 @@
if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0);
for (; pos != end; pos += dir) {
var ch = line.charAt(pos);
if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) {
if (re.test(ch) && (style === undefined ||
(cm.getTokenTypeAt(Pos(lineNo, pos + 1)) || "") == (style || ""))) {
var match = matching[ch];
if (match && (match.charAt(1) == ">") == (dir > 0)) stack.push(ch);
else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch};
@ -80,11 +81,12 @@
function matchBrackets(cm, autoclear, config) {
// Disable brace matching in long lines, since it'll cause hugely slow updates
var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000;
var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000,
highlightNonMatching = config && config.highlightNonMatching;
var marks = [], ranges = cm.listSelections();
for (var i = 0; i < ranges.length; i++) {
var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, config);
if (match && cm.getLine(match.from.line).length <= maxHighlightLen) {
if (match && (match.match || highlightNonMatching !== false) && cm.getLine(match.from.line).length <= maxHighlightLen) {
var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style}));
if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen)
@ -94,7 +96,7 @@
if (marks.length) {
// Kludge to work around the IE bug from issue #1193, where text
// input stops going to the textare whever this fires.
// input stops going to the textarea whenever this fires.
if (ie_lt8 && cm.state.focused) cm.focus();
var clear = function() {
@ -117,25 +119,25 @@
});
}
CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) {
function clear(cm) {
if (cm.state.matchBrackets && cm.state.matchBrackets.currentlyHighlighted) {
cm.state.matchBrackets.currentlyHighlighted();
cm.state.matchBrackets.currentlyHighlighted = null;
}
function clearHighlighted(cm) {
if (cm.state.matchBrackets && cm.state.matchBrackets.currentlyHighlighted) {
cm.state.matchBrackets.currentlyHighlighted();
cm.state.matchBrackets.currentlyHighlighted = null;
}
}
CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) {
if (old && old != CodeMirror.Init) {
cm.off("cursorActivity", doMatchBrackets);
cm.off("focus", doMatchBrackets)
cm.off("blur", clear)
clear(cm);
cm.off("blur", clearHighlighted)
clearHighlighted(cm);
}
if (val) {
cm.state.matchBrackets = typeof val == "object" ? val : {};
cm.on("cursorActivity", doMatchBrackets);
cm.on("focus", doMatchBrackets)
cm.on("blur", clear)
cm.on("blur", clearHighlighted)
}
});

File diff suppressed because one or more lines are too long

View File

@ -170,6 +170,10 @@
var anns = annotations[line];
if (!anns) continue;
// filter out duplicate messages
var message = [];
anns = anns.filter(function(item) { return message.indexOf(item.message) > -1 ? false : message.push(item.message) });
var maxSeverity = null;
var tipLabel = state.hasGutter && document.createDocumentFragment();
@ -187,9 +191,9 @@
__annotation: ann
}));
}
// use original annotations[line] to show multiple messages
if (state.hasGutter)
cm.setGutterMarker(line, GUTTER_ID, makeMarker(cm, tipLabel, maxSeverity, anns.length > 1,
cm.setGutterMarker(line, GUTTER_ID, makeMarker(cm, tipLabel, maxSeverity, annotations[line].length > 1,
state.options.tooltips));
}
if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm);

View File

@ -19,7 +19,7 @@
}
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
background-color: white; /* The little square between H and V scrollbars */
background-color: transparent; /* The little square between H and V scrollbars */
}
/* GUTTER */

View File

@ -38,9 +38,9 @@ CodeMirror.defineMode("yaml", function() {
state.pair = false;
state.pairStart = false;
/* document start */
if(stream.match(/---/)) { return "def"; }
if(stream.match('---')) { return "def"; }
/* document end */
if (stream.match(/\.\.\./)) { return "def"; }
if (stream.match('...')) { return "def"; }
/* array list item */
if (stream.match(/\s*-\s+/)) { return 'meta'; }
}
@ -57,12 +57,12 @@ CodeMirror.defineMode("yaml", function() {
return 'meta';
}
/* list seperator */
/* list separator */
if (state.inlineList > 0 && !esc && ch == ',') {
stream.next();
return 'meta';
}
/* pairs seperator */
/* pairs separator */
if (state.inlinePairs > 0 && !esc && ch == ',') {
state.keyCol = 0;
state.pair = false;

View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=nps
PKG_VERSION:=0.26.9
PKG_RELEASE:=3
PKG_RELEASE:=4
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/ehang-io/nps/tar.gz/v$(PKG_VERSION)?
@ -82,6 +82,15 @@ ifeq ($(CONFIG_NPS_COMPRESS_UPX),y)
endif
endef
define Package/nps/install/template
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/$(2) $(1)/usr/bin/$(2)
endef
Package/npc/install = $(call Package/nps/install/template,$(1),npc)
Package/nps/install = $(call Package/nps/install/template,$(1),nps)
$(eval $(call GoBinPackage,npc))
$(eval $(call GoBinPackage,nps))
$(eval $(call BuildPackage,npc))

View File

@ -0,0 +1,11 @@
--- a/Makefile
+++ b/Makefile
@@ -2103,8 +2103,6 @@ ifeq ($(ARCH), i386)
EXTRA_CFLAGS += -mhard-float
else ifeq ($(ARCH), x86_64)
EXTRA_CFLAGS += -mhard-float
-else ifeq ($(ARCH), arm)
-EXTRA_CFLAGS += -mfloat-abi=hard
endif
ifeq ($(CONFIG_MULTIDRV), y)

View File

@ -9,80 +9,45 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=baidupcs-web
PKG_VERSION:=3.7.1
PKG_RELEASE:=2
PKG_VERSION:=3.7.3
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/Erope/BaiduPCS-Go.git
PKG_SOURCE_VERSION:=b2f5436699d1acd6dc3d90f2066bf1e36c373cd5
PKG_MIRROR_HASH:=815410a7c348c82eea638f6d34fd4dfab59286e16b172c434ff0008de24676dc
PKG_LICENSE:=Apache-2.0
PKG_LICENSE_FILES:=LICENSE
PKG_BUILD_DEPENDS:=golang/host
PKG_BUILD_PARALLEL:=1
PKG_USE_MIPS16:=0
GO_PKG:=github.com/Erope/BaiduPCS-Go
GO_PKG_LDFLAGS:=-s -w
GO_PKG_LDFLAGS_X:=main.Version=v$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
define Package/$(PKG_NAME)
SECTION:=net
CATEGORY:=Network
TITLE:=BaiduPCS-Web is a web controller for BaiduPCS-Go
URL:=https://github.com/Erope/baidupcs-web
URL:=https://github.com/Erope/BaiduPCS-Go
DEPENDS:=$(GO_ARCH_DEPENDS)
endef
define Package/$(PKG_NAME)/description
BaiduPCS-Web is a web controller for BaiduPCS-Go
endef
# 禁止OpenWrt对二进制文件进行strip
STRIP:=true
ifeq ($(ARCH),i386)
PKG_ARCH_BAIDUPCS-WEB:=386
endif
ifeq ($(ARCH),x86_64)
PKG_ARCH_BAIDUPCS-WEB:=amd64
endif
ifeq ($(ARCH),mipsel)
PKG_ARCH_BAIDUPCS-WEB:=mipsle
endif
ifeq ($(ARCH),mips)
PKG_ARCH_BAIDUPCS-WEB:=mipsle
endif
ifeq ($(ARCH),arm)
ifeq ($(BOARD),bcm53xx)
PKG_ARCH_BAIDUPCS-WEB:=armv5
else ifeq ($(BOARD),kirkwood)
PKG_ARCH_BAIDUPCS-WEB:=armv5
else
PKG_ARCH_BAIDUPCS-WEB:=armv7
endif
endif
ifeq ($(ARCH),aarch64)
PKG_ARCH_BAIDUPCS-WEB:=arm64
endif
PKG_SOURCE:=BaiduPCS-Go-v$(PKG_VERSION)-linux-$(PKG_ARCH_BAIDUPCS-WEB).zip
PKG_SOURCE_URL:=https://github.com/coolsnowwolf/baidupcs-web/raw/master/
UNZIP_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)/$(PKG_NAME)-unzip
PKG_HASH:=skip
define Build/Prepare
mkdir -vp $(UNZIP_DIR)
unzip -od $(UNZIP_DIR) $(DL_DIR)/$(PKG_SOURCE)
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/$(PKG_NAME)/install
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(UNZIP_DIR)/*/BaiduPCS-Go $(1)/usr/bin/$(PKG_NAME)
chmod 755 $(1)/usr/bin/$(PKG_NAME)
$(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/BaiduPCS-Go $(1)/usr/bin/$(PKG_NAME)
endef
$(eval $(call GoBinPackage,$(PKG_NAME)))
$(eval $(call BuildPackage,$(PKG_NAME)))

View File

@ -18,9 +18,10 @@ config_t_get() {
echo ${ret:=$3}
}
project_directory=$(config_t_get global project_directory)
gen_nginx_config() {
port=$(config_t_get global port)
project_directory=$(config_t_get global project_directory)
cat <<-EOF > $1
user root root;
worker_processes 1;
@ -77,7 +78,7 @@ gen_php_config() {
unserialize_callback_func =
serialize_precision = 100
open_basedir = $storage_device_path:/tmp/:/proc/:/usr/bin/
open_basedir = $storage_device_path:$project_directory:/tmp/:/proc/:/usr/bin/
disable_functions =
disable_classes =
expose_php = On
@ -168,4 +169,4 @@ stop() {
restart() {
stop
start
}
}

View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=libusb
PKG_VERSION:=1.0.24
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=\

View File

@ -0,0 +1,29 @@
From 369af149e3ad92514a2d24f112cedfeb7acaf558 Mon Sep 17 00:00:00 2001
From: Chris Dickens <christopher.a.dickens@gmail.com>
Date: Sun, 13 Dec 2020 15:46:27 -0800
Subject: [PATCH] Correct a typo in the Changelog and clean up a stray file
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
---
ChangeLog | 2 +-
libusb/version_nano.h | 2 +-
test | 0
3 files changed, 2 insertions(+), 2 deletions(-)
delete mode 100644 test
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,7 +12,7 @@ visit: http://log.libusb.info
* Darwin (macOS): use IOUSBDevice as darwin_device_class explicitly (#693)
* Linux: Drop support for kernel older than 2.6.32
* Linux: Provide an event thread name (#689)
-* Linux: Wait until all USBs have been reaped before freeing them (#607)
+* Linux: Wait until all URBs have been reaped before freeing them (#607)
* NetBSD: Recognize device timeouts (#710)
* OpenBSD: Allow opening ugen devices multiple times (#763)
* OpenBSD: Support libusb_get_port_number() (#764)
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11584
+#define LIBUSB_NANO 11585

View File

@ -0,0 +1,61 @@
From f6d2cb561402c3b6d3627c0eb89e009b503d9067 Mon Sep 17 00:00:00 2001
From: Chris Dickens <christopher.a.dickens@gmail.com>
Date: Sun, 13 Dec 2020 15:49:19 -0800
Subject: [PATCH] linux_usbfs: Fix parsing of descriptors for
multi-configuration devices
Commit e2be556bd2 ("linux_usbfs: Parse config descriptors during device
initialization") introduced a regression for devices with multiple
configurations. The logic that verifies the reported length of the
configuration descriptors failed to count the length of the
configuration descriptor itself and would truncate the actual length by
9 bytes, leading to a parsing error for subsequent descriptors.
Closes #825
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
---
libusb/os/linux_usbfs.c | 12 ++++++++----
libusb/version_nano.h | 2 +-
2 files changed, 9 insertions(+), 5 deletions(-)
--- a/libusb/os/linux_usbfs.c
+++ b/libusb/os/linux_usbfs.c
@@ -641,7 +641,12 @@ static int seek_to_next_config(struct li
uint8_t *buffer, size_t len)
{
struct usbi_descriptor_header *header;
- int offset = 0;
+ int offset;
+
+ /* Start seeking past the config descriptor */
+ offset = LIBUSB_DT_CONFIG_SIZE;
+ buffer += LIBUSB_DT_CONFIG_SIZE;
+ len -= LIBUSB_DT_CONFIG_SIZE;
while (len > 0) {
if (len < 2) {
@@ -718,7 +723,7 @@ static int parse_config_descriptors(stru
}
if (priv->sysfs_dir) {
- /*
+ /*
* In sysfs wTotalLength is ignored, instead the kernel returns a
* config descriptor with verified bLength fields, with descriptors
* with an invalid bLength removed.
@@ -727,8 +732,7 @@ static int parse_config_descriptors(stru
int offset;
if (num_configs > 1 && idx < num_configs - 1) {
- offset = seek_to_next_config(ctx, buffer + LIBUSB_DT_CONFIG_SIZE,
- remaining - LIBUSB_DT_CONFIG_SIZE);
+ offset = seek_to_next_config(ctx, buffer, remaining);
if (offset < 0)
return offset;
sysfs_config_len = (uint16_t)offset;
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11585
+#define LIBUSB_NANO 11586

View File

@ -297,15 +297,4 @@ config OPENSSL_WITH_ASYNC
initiate crypto operations asynchronously. In order to work
this will require the presence of an async capable engine.
config OPENSSL_WITH_GOST
bool
prompt "Prepare library for GOST engine"
depends on OPENSSL_ENGINE
help
This option prepares the library to accept engine support
for Russian GOST crypto algorithms.
The gost engine is not included in standard openwrt feeds.
To build such engine yourself, see:
https://github.com/gost-engine/engine
endif

View File

@ -11,7 +11,7 @@ PKG_NAME:=openssl
PKG_BASE:=1.1.1
PKG_BUGFIX:=j
PKG_VERSION:=$(PKG_BASE)$(PKG_BUGFIX)
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_USE_MIPS16:=0
ENGINES_DIR=engines-1.1
@ -54,7 +54,6 @@ PKG_CONFIG_DEPENDS:= \
CONFIG_OPENSSL_WITH_DTLS \
CONFIG_OPENSSL_WITH_EC2M \
CONFIG_OPENSSL_WITH_ERROR_MESSAGES \
CONFIG_OPENSSL_WITH_GOST \
CONFIG_OPENSSL_WITH_IDEA \
CONFIG_OPENSSL_WITH_MDC2 \
CONFIG_OPENSSL_WITH_NPN \
@ -291,10 +290,6 @@ else
OPENSSL_OPTIONS += no-engine
endif
ifndef CONFIG_OPENSSL_WITH_GOST
OPENSSL_OPTIONS += no-gost
endif
ifndef CONFIG_OPENSSL_WITH_DTLS
OPENSSL_OPTIONS += no-dtls
endif

View File

@ -1,6 +1,6 @@
--- a/apps/openssl.cnf
+++ b/apps/openssl.cnf
@@ -22,6 +22,82 @@ oid_section = new_oids
@@ -22,6 +22,99 @@ oid_section = new_oids
# (Alternatively, use a configuration file that has only
# X.509v3 extensions in its main [= default] section.)
@ -14,6 +14,7 @@
+#devcrypto=devcrypto
+#afalg=afalg
+#padlock=padlock
+##gost=gost
+
+[afalg]
+# Leave this alone and configure algorithms with CIPERS/DIGESTS below
@ -79,6 +80,22 @@
+
+[padlock]
+default_algorithms = ALL
+
+[gost]
+default_algorithms = ALL
+# CRYPT_PARAMS: OID of default GOST 28147-89 parameters It allows the
+# user to choose between different parameter sets of symmetric cipher
+# algorithm. RFC 4357 specifies several parameters for the
+# GOST 28147-89 algorithm, but OpenSSL doesn't provide user interface
+# to choose one when encrypting. So use engine configuration parameter
+# instead.
+# Value of this parameter can be either short name, defined in OpenSSL
+# obj_dat.h header file or numeric representation of OID, defined in
+# RFC 4357. Defaults to id-tc26-gost-28147-param-Z
+#CRYPT_PARAMS = id-tc26-gost-28147-param-Z
+
+# PBE_PARAMS: Shortname of default digest alg for PBE
+#PBE_PARAMS =
+
[ new_oids ]

View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=pcre
PKG_VERSION:=8.44
PKG_RELEASE:=3
PKG_RELEASE:=4
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=@SF/$(PKG_NAME)
@ -24,10 +24,8 @@ PKG_INSTALL:=1
PKG_BUILD_PARALLEL:=1
PKG_CONFIG_DEPENDS:=\
CONFIG_PACKAGE_libpcrecpp \
CONFIG_PCRE_JIT_ENABLED
include $(INCLUDE_DIR)/uclibc++.mk
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/host-build.mk
@ -56,19 +54,12 @@ define Package/libpcre32
TITLE:=A Perl Compatible Regular Expression library (32bit support)
endef
define Package/libpcrecpp
$(call Package/libpcre/default)
TITLE:=C++ wrapper for Perl Compatible Regular Expression library
DEPENDS:=+libpcre $(CXX_DEPENDS)
endef
HOST_CONFIGURE_ARGS += \
--enable-utf8 \
--enable-unicode-properties \
--enable-pcre16 \
--with-match-limit-recursion=16000 \
--enable-cpp
--disable-cpp
TARGET_CFLAGS += $(FPIC)
@ -79,7 +70,7 @@ CONFIGURE_ARGS += \
--enable-pcre32 \
$(if $(CONFIG_PCRE_JIT_ENABLED),--enable-jit,--disable-jit) \
--with-match-limit-recursion=16000 \
$(if $(CONFIG_PACKAGE_libpcrecpp),--enable,--disable)-cpp
-disable-cpp
MAKE_FLAGS += \
CFLAGS="$(TARGET_CFLAGS)"
@ -118,13 +109,7 @@ define Package/libpcre32/install
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre32.so* $(1)/usr/lib/
endef
define Package/libpcrecpp/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcrecpp.so.* $(1)/usr/lib/
endef
$(eval $(call BuildPackage,libpcre))
$(eval $(call BuildPackage,libpcre16))
$(eval $(call BuildPackage,libpcre32))
$(eval $(call BuildPackage,libpcrecpp))
$(eval $(call HostBuild))

View File

@ -8,12 +8,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=wolfssl
PKG_VERSION:=4.6.0-stable
PKG_RELEASE:=2
PKG_VERSION:=4.7.0-stable
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/wolfSSL/wolfssl/archive/v$(PKG_VERSION)
PKG_HASH:=053aefbb02d0b06b27c5e2df6875b4b587318755b7db9d6aa8d72206b310a848
PKG_HASH:=b0e740b31d4d877d540ad50cc539a8873fc41af02bd3091c4357b403f7106e31
PKG_FIXUP:=libtool
PKG_INSTALL:=1

View File

@ -1,53 +0,0 @@
From fad1e67677bf7797b6bd6e1f21a513c289d963a7 Mon Sep 17 00:00:00 2001
From: Sean Parkinson <sean@wolfssl.com>
Date: Thu, 21 Jan 2021 08:24:38 +1000
Subject: [PATCH] TLS 1.3: ensure key for signature in CertificateVerify
---
src/tls13.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
--- a/src/tls13.c
+++ b/src/tls13.c
@@ -5624,28 +5624,36 @@ static int DoTls13CertificateVerify(WOLF
#ifdef HAVE_ED25519
if (args->sigAlgo == ed25519_sa_algo &&
!ssl->peerEd25519KeyPresent) {
- WOLFSSL_MSG("Oops, peer sent ED25519 key but not in verify");
+ WOLFSSL_MSG("Peer sent ED22519 sig but not ED22519 cert");
+ ret = SIG_VERIFY_E;
+ goto exit_dcv;
}
#endif
#ifdef HAVE_ED448
if (args->sigAlgo == ed448_sa_algo && !ssl->peerEd448KeyPresent) {
- WOLFSSL_MSG("Oops, peer sent ED448 key but not in verify");
+ WOLFSSL_MSG("Peer sent ED448 sig but not ED448 cert");
+ ret = SIG_VERIFY_E;
+ goto exit_dcv;
}
#endif
#ifdef HAVE_ECC
if (args->sigAlgo == ecc_dsa_sa_algo &&
!ssl->peerEccDsaKeyPresent) {
- WOLFSSL_MSG("Oops, peer sent ECC key but not in verify");
+ WOLFSSL_MSG("Peer sent ECC sig but not ECC cert");
+ ret = SIG_VERIFY_E;
+ goto exit_dcv;
}
#endif
#ifndef NO_RSA
if (args->sigAlgo == rsa_sa_algo) {
- WOLFSSL_MSG("Oops, peer sent PKCS#1.5 signature");
+ WOLFSSL_MSG("Peer sent PKCS#1.5 algo but not in certificate");
ERROR_OUT(INVALID_PARAMETER, exit_dcv);
}
if (args->sigAlgo == rsa_pss_sa_algo &&
(ssl->peerRsaKey == NULL || !ssl->peerRsaKeyPresent)) {
- WOLFSSL_MSG("Oops, peer sent RSA key but not in verify");
+ WOLFSSL_MSG("Peer sent RSA sig but not RSA cert");
+ ret = SIG_VERIFY_E;
+ goto exit_dcv;
}
#endif

View File

@ -1,6 +1,6 @@
--- a/wolfssl/wolfcrypt/settings.h
+++ b/wolfssl/wolfcrypt/settings.h
@@ -2248,7 +2248,7 @@ extern void uITRON4_free(void *p) ;
@@ -2255,7 +2255,7 @@ extern void uITRON4_free(void *p) ;
#endif
/* warning for not using harden build options (default with ./configure) */

View File

@ -1,25 +0,0 @@
From 391ecbd647c121300dc7dcf209e412ccb7b8d432 Mon Sep 17 00:00:00 2001
From: Hauke Mehrtens <hauke@hauke-m.de>
Date: Fri, 1 Jan 2021 21:57:56 +0100
Subject: [PATCH] Fix linking against hostapd with LTO
When running LTO on wolfssl the ecc_map() function is removed from the
binary by GCC 8.4.0. This function is used by multiple functions from
the crypto_wolfssl.c implementation of hostapd master.
Fixes: 780e8a4619b6 ("Fixes for building `--enable-wpas=small` with WPA Supplicant v2.7.")
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
configure.ac | 1 +
1 file changed, 1 insertion(+)
--- a/configure.ac
+++ b/configure.ac
@@ -947,6 +947,7 @@ then
AM_CFLAGS="$AM_CFLAGS -DOPENSSL_EXTRA_X509_SMALL"
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_PUBLIC_MP"
+ AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_PUBLIC_ECC_ADD_DBL"
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DER_LOAD"
AM_CFLAGS="$AM_CFLAGS -DATOMIC_USER"
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_KEY_GEN"

View File

@ -1,10 +0,0 @@
--- a/configure.ac
+++ b/configure.ac
@@ -943,6 +943,7 @@ then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ALWAYS_KEEP_SNI"
AM_CFLAGS="$AM_CFLAGS -DHAVE_EX_DATA"
AM_CFLAGS="$AM_CFLAGS -DHAVE_EXT_CACHE"
+ AM_CFLAGS="$AM_CFLAGS -DHAVE_SECRET_CALLBACK"
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_EITHER_SIDE"
AM_CFLAGS="$AM_CFLAGS -DOPENSSL_EXTRA_X509_SMALL"

View File

@ -1907,505 +1907,3 @@ index 00000000..ac333e8c
+ state = (struct inflate_state FAR *)strm->state;
+ return (unsigned long)(state->next - state->codes);
+}
From 247147654fe5cd11cf15d8dff91440405ea57040 Mon Sep 17 00:00:00 2001
From: Simon Hosie <simon.hosie@arm.com>
Date: Wed, 12 Apr 2017 15:44:21 -0700
Subject: [PATCH 2/2] Inflate using wider loads and stores
In inflate_fast() the output pointer always has plenty of room to write. This
means that so long as the target is capable, wide un-aligned loads and stores
can be used to transfer several bytes at once. When the reference distance is
too short simply unroll the data a little to increase the distance.
Change-Id: I59854eb25d2b1e43561c8a2afaf9175bf10cf674
---
contrib/arm/chunkcopy.h | 279 ++++++++++++++++++++++++++++++++++++++++++++++++
contrib/arm/inffast.c | 96 +++++++----------
contrib/arm/inflate.c | 22 ++--
3 files changed, 335 insertions(+), 62 deletions(-)
create mode 100644 contrib/arm/chunkcopy.h
diff --git a/contrib/arm/chunkcopy.h b/contrib/arm/chunkcopy.h
new file mode 100644
index 00000000..2d6fd6f9
--- /dev/null
+++ b/contrib/arm/chunkcopy.h
@@ -0,0 +1,279 @@
+/* chunkcopy.h -- fast copies and sets
+ * Copyright (C) 2017 ARM, Inc.
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#ifndef CHUNKCOPY_H
+#define CHUNKCOPY_H
+
+#include "zutil.h"
+#include <arm_neon.h>
+
+#if __STDC_VERSION__ >= 199901L
+#define Z_RESTRICT restrict
+#else
+#define Z_RESTRICT
+#endif
+
+typedef uint8x16_t chunkcopy_chunk_t;
+#define CHUNKCOPY_CHUNK_SIZE sizeof(chunkcopy_chunk_t)
+
+/*
+ Ask the compiler to perform a wide, unaligned load with an machine
+ instruction appropriate for the chunkcopy_chunk_t type.
+ */
+static inline chunkcopy_chunk_t loadchunk(const unsigned char FAR *s) {
+ chunkcopy_chunk_t c;
+ __builtin_memcpy(&c, s, sizeof(c));
+ return c;
+}
+
+/*
+ Ask the compiler to perform a wide, unaligned store with an machine
+ instruction appropriate for the chunkcopy_chunk_t type.
+ */
+static inline void storechunk(unsigned char FAR *d, chunkcopy_chunk_t c) {
+ __builtin_memcpy(d, &c, sizeof(c));
+}
+
+/*
+ Perform a memcpy-like operation, but assume that length is non-zero and that
+ it's OK to overwrite at least CHUNKCOPY_CHUNK_SIZE bytes of output even if
+ the length is shorter than this.
+
+ It also guarantees that it will properly unroll the data if the distance
+ between `out` and `from` is at least CHUNKCOPY_CHUNK_SIZE, which we rely on
+ in chunkcopy_relaxed().
+
+ Aside from better memory bus utilisation, this means that short copies
+ (CHUNKCOPY_CHUNK_SIZE bytes or fewer) will fall straight through the loop
+ without iteration, which will hopefully make the branch prediction more
+ reliable.
+ */
+static inline unsigned char FAR *chunkcopy_core(unsigned char FAR *out,
+ const unsigned char FAR *from,
+ unsigned len) {
+ int bump = (--len % CHUNKCOPY_CHUNK_SIZE) + 1;
+ storechunk(out, loadchunk(from));
+ out += bump;
+ from += bump;
+ len /= CHUNKCOPY_CHUNK_SIZE;
+ while (len-- > 0) {
+ storechunk(out, loadchunk(from));
+ out += CHUNKCOPY_CHUNK_SIZE;
+ from += CHUNKCOPY_CHUNK_SIZE;
+ }
+ return out;
+}
+
+/*
+ Like chunkcopy_core, but avoid writing beyond of legal output.
+
+ Accepts an additional pointer to the end of safe output. A generic safe
+ copy would use (out + len), but it's normally the case that the end of the
+ output buffer is beyond the end of the current copy, and this can still be
+ exploited.
+ */
+static inline unsigned char FAR *chunkcopy_core_safe(unsigned char FAR *out,
+ const unsigned char FAR * from,
+ unsigned len,
+ unsigned char FAR *limit) {
+ Assert(out + len <= limit, "chunk copy exceeds safety limit");
+ if (limit - out < CHUNKCOPY_CHUNK_SIZE) {
+ const unsigned char FAR * Z_RESTRICT rfrom = from;
+ if (len & 8) { __builtin_memcpy(out, rfrom, 8); out += 8; rfrom += 8; }
+ if (len & 4) { __builtin_memcpy(out, rfrom, 4); out += 4; rfrom += 4; }
+ if (len & 2) { __builtin_memcpy(out, rfrom, 2); out += 2; rfrom += 2; }
+ if (len & 1) { *out++ = *rfrom++; }
+ return out;
+ }
+ return chunkcopy_core(out, from, len);
+}
+
+/*
+ Perform short copies until distance can be rewritten as being at least
+ CHUNKCOPY_CHUNK_SIZE.
+
+ This assumes that it's OK to overwrite at least the first
+ 2*CHUNKCOPY_CHUNK_SIZE bytes of output even if the copy is shorter than
+ this. This assumption holds within inflate_fast() which starts every
+ iteration with at least 258 bytes of output space available (258 being the
+ maximum length output from a single token; see inffast.c).
+ */
+static inline unsigned char FAR *chunkunroll_relaxed(unsigned char FAR *out,
+ unsigned FAR *dist,
+ unsigned FAR *len) {
+ const unsigned char FAR *from = out - *dist;
+ while (*dist < *len && *dist < CHUNKCOPY_CHUNK_SIZE) {
+ storechunk(out, loadchunk(from));
+ out += *dist;
+ *len -= *dist;
+ *dist += *dist;
+ }
+ return out;
+}
+
+
+static inline uint8x16_t chunkset_vld1q_dup_u8x8(const unsigned char FAR * Z_RESTRICT from) {
+#if defined(__clang__) || defined(__aarch64__)
+ return vreinterpretq_u8_u64(vld1q_dup_u64((void *)from));
+#else
+ /* 32-bit GCC uses an alignment hint for vld1q_dup_u64, even when given a
+ * void pointer, so here's an alternate implementation.
+ */
+ uint8x8_t h = vld1_u8(from);
+ return vcombine_u8(h, h);
+#endif
+}
+
+/*
+ Perform an overlapping copy which behaves as a memset() operation, but
+ supporting periods other than one, and assume that length is non-zero and
+ that it's OK to overwrite at least CHUNKCOPY_CHUNK_SIZE*3 bytes of output
+ even if the length is shorter than this.
+ */
+static inline unsigned char FAR *chunkset_core(unsigned char FAR *out,
+ unsigned period,
+ unsigned len) {
+ uint8x16_t f;
+ int bump = ((len - 1) % sizeof(f)) + 1;
+
+ switch (period) {
+ case 1:
+ f = vld1q_dup_u8(out - 1);
+ vst1q_u8(out, f);
+ out += bump;
+ len -= bump;
+ while (len > 0) {
+ vst1q_u8(out, f);
+ out += sizeof(f);
+ len -= sizeof(f);
+ }
+ return out;
+ case 2:
+ f = vreinterpretq_u8_u16(vld1q_dup_u16((void *)(out - 2)));
+ vst1q_u8(out, f);
+ out += bump;
+ len -= bump;
+ if (len > 0) {
+ f = vreinterpretq_u8_u16(vld1q_dup_u16((void *)(out - 2)));
+ do {
+ vst1q_u8(out, f);
+ out += sizeof(f);
+ len -= sizeof(f);
+ } while (len > 0);
+ }
+ return out;
+ case 4:
+ f = vreinterpretq_u8_u32(vld1q_dup_u32((void *)(out - 4)));
+ vst1q_u8(out, f);
+ out += bump;
+ len -= bump;
+ if (len > 0) {
+ f = vreinterpretq_u8_u32(vld1q_dup_u32((void *)(out - 4)));
+ do {
+ vst1q_u8(out, f);
+ out += sizeof(f);
+ len -= sizeof(f);
+ } while (len > 0);
+ }
+ return out;
+ case 8:
+ f = chunkset_vld1q_dup_u8x8(out - 8);
+ vst1q_u8(out, f);
+ out += bump;
+ len -= bump;
+ if (len > 0) {
+ f = chunkset_vld1q_dup_u8x8(out - 8);
+ do {
+ vst1q_u8(out, f);
+ out += sizeof(f);
+ len -= sizeof(f);
+ } while (len > 0);
+ }
+ return out;
+ }
+ out = chunkunroll_relaxed(out, &period, &len);
+ return chunkcopy_core(out, out - period, len);
+}
+
+/*
+ Perform a memcpy-like operation, but assume that length is non-zero and that
+ it's OK to overwrite at least CHUNKCOPY_CHUNK_SIZE bytes of output even if
+ the length is shorter than this.
+
+ Unlike chunkcopy_core() above, no guarantee is made regarding the behaviour
+ of overlapping buffers, regardless of the distance between the pointers.
+ This is reflected in the `restrict`-qualified pointers, allowing the
+ compiler to reorder loads and stores.
+ */
+static inline unsigned char FAR *chunkcopy_relaxed(unsigned char FAR * Z_RESTRICT out,
+ const unsigned char FAR * Z_RESTRICT from,
+ unsigned len) {
+ return chunkcopy_core(out, from, len);
+}
+
+/*
+ Like chunkcopy_relaxed, but avoid writing beyond of legal output.
+
+ Unlike chunkcopy_core_safe() above, no guarantee is made regarding the
+ behaviour of overlapping buffers, regardless of the distance between the
+ pointers. This is reflected in the `restrict`-qualified pointers, allowing
+ the compiler to reorder loads and stores.
+
+ Accepts an additional pointer to the end of safe output. A generic safe
+ copy would use (out + len), but it's normally the case that the end of the
+ output buffer is beyond the end of the current copy, and this can still be
+ exploited.
+ */
+static inline unsigned char FAR *chunkcopy_safe(unsigned char FAR *out,
+ const unsigned char FAR * Z_RESTRICT from,
+ unsigned len,
+ unsigned char FAR *limit) {
+ Assert(out + len <= limit, "chunk copy exceeds safety limit");
+ return chunkcopy_core_safe(out, from, len, limit);
+}
+
+/*
+ Perform chunky copy within the same buffer, where the source and destination
+ may potentially overlap.
+
+ Assumes that len > 0 on entry, and that it's safe to write at least
+ CHUNKCOPY_CHUNK_SIZE*3 bytes to the output.
+ */
+static inline unsigned char FAR *chunkcopy_lapped_relaxed(unsigned char FAR *out,
+ unsigned dist,
+ unsigned len) {
+ if (dist < len && dist < CHUNKCOPY_CHUNK_SIZE) {
+ return chunkset_core(out, dist, len);
+ }
+ return chunkcopy_core(out, out - dist, len);
+}
+
+/*
+ Behave like chunkcopy_lapped_relaxed, but avoid writing beyond of legal output.
+
+ Accepts an additional pointer to the end of safe output. A generic safe
+ copy would use (out + len), but it's normally the case that the end of the
+ output buffer is beyond the end of the current copy, and this can still be
+ exploited.
+ */
+static inline unsigned char FAR *chunkcopy_lapped_safe(unsigned char FAR *out,
+ unsigned dist,
+ unsigned len,
+ unsigned char FAR *limit) {
+ Assert(out + len <= limit, "chunk copy exceeds safety limit");
+ if (limit - out < CHUNKCOPY_CHUNK_SIZE * 3) {
+ /* TODO: try harder to optimise this */
+ while (len-- > 0) {
+ *out = *(out - dist);
+ out++;
+ }
+ return out;
+ }
+ return chunkcopy_lapped_relaxed(out, dist, len);
+}
+
+#undef Z_RESTRICT
+
+#endif /* CHUNKCOPY_H */
diff --git a/contrib/arm/inffast.c b/contrib/arm/inffast.c
index 0dbd1dbc..f7f50071 100644
--- a/contrib/arm/inffast.c
+++ b/contrib/arm/inffast.c
@@ -7,6 +7,7 @@
#include "inftrees.h"
#include "inflate.h"
#include "inffast.h"
+#include "chunkcopy.h"
#ifdef ASMINF
# pragma message("Assembler code may have bugs -- use at your own risk")
@@ -57,6 +58,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
unsigned char FAR *out; /* local strm->next_out */
unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
unsigned char FAR *end; /* while out < end, enough space available */
+ unsigned char FAR *limit; /* safety limit for chunky copies */
#ifdef INFLATE_STRICT
unsigned dmax; /* maximum distance from zlib header */
#endif
@@ -84,12 +86,13 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
out = strm->next_out;
beg = out - (start - strm->avail_out);
end = out + (strm->avail_out - 257);
+ limit = out + strm->avail_out;
#ifdef INFLATE_STRICT
dmax = state->dmax;
#endif
wsize = state->wsize;
whave = state->whave;
- wnext = state->wnext;
+ wnext = (state->wnext == 0 && whave >= wsize) ? wsize : state->wnext;
window = state->window;
hold = state->hold;
bits = state->bits;
@@ -197,70 +200,51 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
#endif
}
from = window;
- if (wnext == 0) { /* very common case */
- from += wsize - op;
- if (op < len) { /* some from window */
- len -= op;
- do {
- *out++ = *from++;
- } while (--op);
- from = out - dist; /* rest from output */
- }
+ if (wnext >= op) { /* contiguous in window */
+ from += wnext - op;
}
- else if (wnext < op) { /* wrap around window */
- from += wsize + wnext - op;
+ else { /* wrap around window */
op -= wnext;
+ from += wsize - op;
if (op < len) { /* some from end of window */
len -= op;
- do {
- *out++ = *from++;
- } while (--op);
- from = window;
- if (wnext < len) { /* some from start of window */
- op = wnext;
- len -= op;
- do {
- *out++ = *from++;
- } while (--op);
- from = out - dist; /* rest from output */
- }
+ out = chunkcopy_safe(out, from, op, limit);
+ from = window; /* more from start of window */
+ op = wnext;
+ /* This (rare) case can create a situation where
+ the first chunkcopy below must be checked.
+ */
}
}
- else { /* contiguous in window */
- from += wnext - op;
- if (op < len) { /* some from window */
- len -= op;
- do {
- *out++ = *from++;
- } while (--op);
- from = out - dist; /* rest from output */
- }
- }
- while (len > 2) {
- *out++ = *from++;
- *out++ = *from++;
- *out++ = *from++;
- len -= 3;
- }
- if (len) {
- *out++ = *from++;
- if (len > 1)
- *out++ = *from++;
+ if (op < len) { /* still need some from output */
+ out = chunkcopy_safe(out, from, op, limit);
+ len -= op;
+ /* When dist is small the amount of data that can be
+ copied from the window is also small, and progress
+ towards the dangerous end of the output buffer is
+ also small. This means that for trivial memsets and
+ for chunkunroll_relaxed() a safety check is
+ unnecessary. However, these conditions may not be
+ entered at all, and in that case it's possible that
+ the main copy is near the end.
+ */
+ out = chunkunroll_relaxed(out, &dist, &len);
+ out = chunkcopy_safe(out, out - dist, len, limit);
+ } else {
+ /* from points to window, so there is no risk of
+ overlapping pointers requiring memset-like behaviour
+ */
+ out = chunkcopy_safe(out, from, len, limit);
}
}
else {
- from = out - dist; /* copy direct from output */
- do { /* minimum length is three */
- *out++ = *from++;
- *out++ = *from++;
- *out++ = *from++;
- len -= 3;
- } while (len > 2);
- if (len) {
- *out++ = *from++;
- if (len > 1)
- *out++ = *from++;
- }
+ /* Whole reference is in range of current output. No
+ range checks are necessary because we start with room
+ for at least 258 bytes of output, so unroll and roundoff
+ operations can write beyond `out+len` so long as they
+ stay within 258 bytes of `out`.
+ */
+ out = chunkcopy_lapped_relaxed(out, dist, len);
}
}
else if ((op & 64) == 0) { /* 2nd level distance code */
diff --git a/contrib/arm/inflate.c b/contrib/arm/inflate.c
index ac333e8c..e40322c3 100644
--- a/contrib/arm/inflate.c
+++ b/contrib/arm/inflate.c
@@ -84,6 +84,7 @@
#include "inftrees.h"
#include "inflate.h"
#include "inffast.h"
+#include "contrib/arm/chunkcopy.h"
#ifdef MAKEFIXED
# ifndef BUILDFIXED
@@ -405,10 +406,20 @@ unsigned copy;
/* if it hasn't been done already, allocate space for the window */
if (state->window == Z_NULL) {
+ unsigned wsize = 1U << state->wbits;
state->window = (unsigned char FAR *)
- ZALLOC(strm, 1U << state->wbits,
+ ZALLOC(strm, wsize + CHUNKCOPY_CHUNK_SIZE,
sizeof(unsigned char));
if (state->window == Z_NULL) return 1;
+#ifdef INFLATE_CLEAR_UNUSED_UNDEFINED
+ /* Copies from the overflow portion of this buffer are undefined and
+ may cause analysis tools to raise a warning if we don't initialize
+ it. However, this undefined data overwrites other undefined data
+ and is subsequently either overwritten or left deliberately
+ undefined at the end of decode; so there's really no point.
+ */
+ memset(state->window + wsize, 0, CHUNKCOPY_CHUNK_SIZE);
+#endif
}
/* if window not in use yet, initialize */
@@ -1175,17 +1186,16 @@ int flush;
else
from = state->window + (state->wnext - copy);
if (copy > state->length) copy = state->length;
+ if (copy > left) copy = left;
+ put = chunkcopy_safe(put, from, copy, put + left);
}
else { /* copy from output */
- from = put - state->offset;
copy = state->length;
+ if (copy > left) copy = left;
+ put = chunkcopy_lapped_safe(put, state->offset, copy, put + left);
}
- if (copy > left) copy = left;
left -= copy;
state->length -= copy;
- do {
- *put++ = *from++;
- } while (--copy);
if (state->length == 0) state->mode = LEN;
break;
case LIT:

View File

@ -0,0 +1,501 @@
From 247147654fe5cd11cf15d8dff91440405ea57040 Mon Sep 17 00:00:00 2001
From: Simon Hosie <simon.hosie@arm.com>
Date: Wed, 12 Apr 2017 15:44:21 -0700
Subject: [PATCH 2/2] Inflate using wider loads and stores
In inflate_fast() the output pointer always has plenty of room to write. This
means that so long as the target is capable, wide un-aligned loads and stores
can be used to transfer several bytes at once. When the reference distance is
too short simply unroll the data a little to increase the distance.
Change-Id: I59854eb25d2b1e43561c8a2afaf9175bf10cf674
---
contrib/arm/chunkcopy.h | 279 ++++++++++++++++++++++++++++++++++++++++++++++++
contrib/arm/inffast.c | 96 +++++++----------
contrib/arm/inflate.c | 22 ++--
3 files changed, 335 insertions(+), 62 deletions(-)
create mode 100644 contrib/arm/chunkcopy.h
diff --git a/contrib/arm/chunkcopy.h b/contrib/arm/chunkcopy.h
new file mode 100644
index 00000000..2d6fd6f9
--- /dev/null
+++ b/contrib/arm/chunkcopy.h
@@ -0,0 +1,279 @@
+/* chunkcopy.h -- fast copies and sets
+ * Copyright (C) 2017 ARM, Inc.
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#ifndef CHUNKCOPY_H
+#define CHUNKCOPY_H
+
+#include "zutil.h"
+#include <arm_neon.h>
+
+#if __STDC_VERSION__ >= 199901L
+#define Z_RESTRICT restrict
+#else
+#define Z_RESTRICT
+#endif
+
+typedef uint8x16_t chunkcopy_chunk_t;
+#define CHUNKCOPY_CHUNK_SIZE sizeof(chunkcopy_chunk_t)
+
+/*
+ Ask the compiler to perform a wide, unaligned load with an machine
+ instruction appropriate for the chunkcopy_chunk_t type.
+ */
+static inline chunkcopy_chunk_t loadchunk(const unsigned char FAR *s) {
+ chunkcopy_chunk_t c;
+ __builtin_memcpy(&c, s, sizeof(c));
+ return c;
+}
+
+/*
+ Ask the compiler to perform a wide, unaligned store with an machine
+ instruction appropriate for the chunkcopy_chunk_t type.
+ */
+static inline void storechunk(unsigned char FAR *d, chunkcopy_chunk_t c) {
+ __builtin_memcpy(d, &c, sizeof(c));
+}
+
+/*
+ Perform a memcpy-like operation, but assume that length is non-zero and that
+ it's OK to overwrite at least CHUNKCOPY_CHUNK_SIZE bytes of output even if
+ the length is shorter than this.
+
+ It also guarantees that it will properly unroll the data if the distance
+ between `out` and `from` is at least CHUNKCOPY_CHUNK_SIZE, which we rely on
+ in chunkcopy_relaxed().
+
+ Aside from better memory bus utilisation, this means that short copies
+ (CHUNKCOPY_CHUNK_SIZE bytes or fewer) will fall straight through the loop
+ without iteration, which will hopefully make the branch prediction more
+ reliable.
+ */
+static inline unsigned char FAR *chunkcopy_core(unsigned char FAR *out,
+ const unsigned char FAR *from,
+ unsigned len) {
+ int bump = (--len % CHUNKCOPY_CHUNK_SIZE) + 1;
+ storechunk(out, loadchunk(from));
+ out += bump;
+ from += bump;
+ len /= CHUNKCOPY_CHUNK_SIZE;
+ while (len-- > 0) {
+ storechunk(out, loadchunk(from));
+ out += CHUNKCOPY_CHUNK_SIZE;
+ from += CHUNKCOPY_CHUNK_SIZE;
+ }
+ return out;
+}
+
+/*
+ Like chunkcopy_core, but avoid writing beyond of legal output.
+
+ Accepts an additional pointer to the end of safe output. A generic safe
+ copy would use (out + len), but it's normally the case that the end of the
+ output buffer is beyond the end of the current copy, and this can still be
+ exploited.
+ */
+static inline unsigned char FAR *chunkcopy_core_safe(unsigned char FAR *out,
+ const unsigned char FAR * from,
+ unsigned len,
+ unsigned char FAR *limit) {
+ Assert(out + len <= limit, "chunk copy exceeds safety limit");
+ if (limit - out < CHUNKCOPY_CHUNK_SIZE) {
+ const unsigned char FAR * Z_RESTRICT rfrom = from;
+ if (len & 8) { __builtin_memcpy(out, rfrom, 8); out += 8; rfrom += 8; }
+ if (len & 4) { __builtin_memcpy(out, rfrom, 4); out += 4; rfrom += 4; }
+ if (len & 2) { __builtin_memcpy(out, rfrom, 2); out += 2; rfrom += 2; }
+ if (len & 1) { *out++ = *rfrom++; }
+ return out;
+ }
+ return chunkcopy_core(out, from, len);
+}
+
+/*
+ Perform short copies until distance can be rewritten as being at least
+ CHUNKCOPY_CHUNK_SIZE.
+
+ This assumes that it's OK to overwrite at least the first
+ 2*CHUNKCOPY_CHUNK_SIZE bytes of output even if the copy is shorter than
+ this. This assumption holds within inflate_fast() which starts every
+ iteration with at least 258 bytes of output space available (258 being the
+ maximum length output from a single token; see inffast.c).
+ */
+static inline unsigned char FAR *chunkunroll_relaxed(unsigned char FAR *out,
+ unsigned FAR *dist,
+ unsigned FAR *len) {
+ const unsigned char FAR *from = out - *dist;
+ while (*dist < *len && *dist < CHUNKCOPY_CHUNK_SIZE) {
+ storechunk(out, loadchunk(from));
+ out += *dist;
+ *len -= *dist;
+ *dist += *dist;
+ }
+ return out;
+}
+
+
+static inline uint8x16_t chunkset_vld1q_dup_u8x8(const unsigned char FAR * Z_RESTRICT from) {
+#if defined(__clang__) || defined(__aarch64__)
+ return vreinterpretq_u8_u64(vld1q_dup_u64((void *)from));
+#else
+ /* 32-bit GCC uses an alignment hint for vld1q_dup_u64, even when given a
+ * void pointer, so here's an alternate implementation.
+ */
+ uint8x8_t h = vld1_u8(from);
+ return vcombine_u8(h, h);
+#endif
+}
+
+/*
+ Perform an overlapping copy which behaves as a memset() operation, but
+ supporting periods other than one, and assume that length is non-zero and
+ that it's OK to overwrite at least CHUNKCOPY_CHUNK_SIZE*3 bytes of output
+ even if the length is shorter than this.
+ */
+static inline unsigned char FAR *chunkset_core(unsigned char FAR *out,
+ unsigned period,
+ unsigned len) {
+ uint8x16_t f;
+ int bump = ((len - 1) % sizeof(f)) + 1;
+
+ switch (period) {
+ case 1:
+ f = vld1q_dup_u8(out - 1);
+ vst1q_u8(out, f);
+ out += bump;
+ len -= bump;
+ while (len > 0) {
+ vst1q_u8(out, f);
+ out += sizeof(f);
+ len -= sizeof(f);
+ }
+ return out;
+ case 2:
+ f = vreinterpretq_u8_u16(vld1q_dup_u16((void *)(out - 2)));
+ vst1q_u8(out, f);
+ out += bump;
+ len -= bump;
+ if (len > 0) {
+ f = vreinterpretq_u8_u16(vld1q_dup_u16((void *)(out - 2)));
+ do {
+ vst1q_u8(out, f);
+ out += sizeof(f);
+ len -= sizeof(f);
+ } while (len > 0);
+ }
+ return out;
+ case 4:
+ f = vreinterpretq_u8_u32(vld1q_dup_u32((void *)(out - 4)));
+ vst1q_u8(out, f);
+ out += bump;
+ len -= bump;
+ if (len > 0) {
+ f = vreinterpretq_u8_u32(vld1q_dup_u32((void *)(out - 4)));
+ do {
+ vst1q_u8(out, f);
+ out += sizeof(f);
+ len -= sizeof(f);
+ } while (len > 0);
+ }
+ return out;
+ case 8:
+ f = chunkset_vld1q_dup_u8x8(out - 8);
+ vst1q_u8(out, f);
+ out += bump;
+ len -= bump;
+ if (len > 0) {
+ f = chunkset_vld1q_dup_u8x8(out - 8);
+ do {
+ vst1q_u8(out, f);
+ out += sizeof(f);
+ len -= sizeof(f);
+ } while (len > 0);
+ }
+ return out;
+ }
+ out = chunkunroll_relaxed(out, &period, &len);
+ return chunkcopy_core(out, out - period, len);
+}
+
+/*
+ Perform a memcpy-like operation, but assume that length is non-zero and that
+ it's OK to overwrite at least CHUNKCOPY_CHUNK_SIZE bytes of output even if
+ the length is shorter than this.
+
+ Unlike chunkcopy_core() above, no guarantee is made regarding the behaviour
+ of overlapping buffers, regardless of the distance between the pointers.
+ This is reflected in the `restrict`-qualified pointers, allowing the
+ compiler to reorder loads and stores.
+ */
+static inline unsigned char FAR *chunkcopy_relaxed(unsigned char FAR * Z_RESTRICT out,
+ const unsigned char FAR * Z_RESTRICT from,
+ unsigned len) {
+ return chunkcopy_core(out, from, len);
+}
+
+/*
+ Like chunkcopy_relaxed, but avoid writing beyond of legal output.
+
+ Unlike chunkcopy_core_safe() above, no guarantee is made regarding the
+ behaviour of overlapping buffers, regardless of the distance between the
+ pointers. This is reflected in the `restrict`-qualified pointers, allowing
+ the compiler to reorder loads and stores.
+
+ Accepts an additional pointer to the end of safe output. A generic safe
+ copy would use (out + len), but it's normally the case that the end of the
+ output buffer is beyond the end of the current copy, and this can still be
+ exploited.
+ */
+static inline unsigned char FAR *chunkcopy_safe(unsigned char FAR *out,
+ const unsigned char FAR * Z_RESTRICT from,
+ unsigned len,
+ unsigned char FAR *limit) {
+ Assert(out + len <= limit, "chunk copy exceeds safety limit");
+ return chunkcopy_core_safe(out, from, len, limit);
+}
+
+/*
+ Perform chunky copy within the same buffer, where the source and destination
+ may potentially overlap.
+
+ Assumes that len > 0 on entry, and that it's safe to write at least
+ CHUNKCOPY_CHUNK_SIZE*3 bytes to the output.
+ */
+static inline unsigned char FAR *chunkcopy_lapped_relaxed(unsigned char FAR *out,
+ unsigned dist,
+ unsigned len) {
+ if (dist < len && dist < CHUNKCOPY_CHUNK_SIZE) {
+ return chunkset_core(out, dist, len);
+ }
+ return chunkcopy_core(out, out - dist, len);
+}
+
+/*
+ Behave like chunkcopy_lapped_relaxed, but avoid writing beyond of legal output.
+
+ Accepts an additional pointer to the end of safe output. A generic safe
+ copy would use (out + len), but it's normally the case that the end of the
+ output buffer is beyond the end of the current copy, and this can still be
+ exploited.
+ */
+static inline unsigned char FAR *chunkcopy_lapped_safe(unsigned char FAR *out,
+ unsigned dist,
+ unsigned len,
+ unsigned char FAR *limit) {
+ Assert(out + len <= limit, "chunk copy exceeds safety limit");
+ if (limit - out < CHUNKCOPY_CHUNK_SIZE * 3) {
+ /* TODO: try harder to optimise this */
+ while (len-- > 0) {
+ *out = *(out - dist);
+ out++;
+ }
+ return out;
+ }
+ return chunkcopy_lapped_relaxed(out, dist, len);
+}
+
+#undef Z_RESTRICT
+
+#endif /* CHUNKCOPY_H */
diff --git a/contrib/arm/inffast.c b/contrib/arm/inffast.c
index 0dbd1dbc..f7f50071 100644
--- a/contrib/arm/inffast.c
+++ b/contrib/arm/inffast.c
@@ -7,6 +7,7 @@
#include "inftrees.h"
#include "inflate.h"
#include "inffast.h"
+#include "chunkcopy.h"
#ifdef ASMINF
# pragma message("Assembler code may have bugs -- use at your own risk")
@@ -57,6 +58,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
unsigned char FAR *out; /* local strm->next_out */
unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
unsigned char FAR *end; /* while out < end, enough space available */
+ unsigned char FAR *limit; /* safety limit for chunky copies */
#ifdef INFLATE_STRICT
unsigned dmax; /* maximum distance from zlib header */
#endif
@@ -84,12 +86,13 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
out = strm->next_out;
beg = out - (start - strm->avail_out);
end = out + (strm->avail_out - 257);
+ limit = out + strm->avail_out;
#ifdef INFLATE_STRICT
dmax = state->dmax;
#endif
wsize = state->wsize;
whave = state->whave;
- wnext = state->wnext;
+ wnext = (state->wnext == 0 && whave >= wsize) ? wsize : state->wnext;
window = state->window;
hold = state->hold;
bits = state->bits;
@@ -197,70 +200,51 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
#endif
}
from = window;
- if (wnext == 0) { /* very common case */
- from += wsize - op;
- if (op < len) { /* some from window */
- len -= op;
- do {
- *out++ = *from++;
- } while (--op);
- from = out - dist; /* rest from output */
- }
+ if (wnext >= op) { /* contiguous in window */
+ from += wnext - op;
}
- else if (wnext < op) { /* wrap around window */
- from += wsize + wnext - op;
+ else { /* wrap around window */
op -= wnext;
+ from += wsize - op;
if (op < len) { /* some from end of window */
len -= op;
- do {
- *out++ = *from++;
- } while (--op);
- from = window;
- if (wnext < len) { /* some from start of window */
- op = wnext;
- len -= op;
- do {
- *out++ = *from++;
- } while (--op);
- from = out - dist; /* rest from output */
- }
+ out = chunkcopy_safe(out, from, op, limit);
+ from = window; /* more from start of window */
+ op = wnext;
+ /* This (rare) case can create a situation where
+ the first chunkcopy below must be checked.
+ */
}
}
- else { /* contiguous in window */
- from += wnext - op;
- if (op < len) { /* some from window */
- len -= op;
- do {
- *out++ = *from++;
- } while (--op);
- from = out - dist; /* rest from output */
- }
- }
- while (len > 2) {
- *out++ = *from++;
- *out++ = *from++;
- *out++ = *from++;
- len -= 3;
- }
- if (len) {
- *out++ = *from++;
- if (len > 1)
- *out++ = *from++;
+ if (op < len) { /* still need some from output */
+ out = chunkcopy_safe(out, from, op, limit);
+ len -= op;
+ /* When dist is small the amount of data that can be
+ copied from the window is also small, and progress
+ towards the dangerous end of the output buffer is
+ also small. This means that for trivial memsets and
+ for chunkunroll_relaxed() a safety check is
+ unnecessary. However, these conditions may not be
+ entered at all, and in that case it's possible that
+ the main copy is near the end.
+ */
+ out = chunkunroll_relaxed(out, &dist, &len);
+ out = chunkcopy_safe(out, out - dist, len, limit);
+ } else {
+ /* from points to window, so there is no risk of
+ overlapping pointers requiring memset-like behaviour
+ */
+ out = chunkcopy_safe(out, from, len, limit);
}
}
else {
- from = out - dist; /* copy direct from output */
- do { /* minimum length is three */
- *out++ = *from++;
- *out++ = *from++;
- *out++ = *from++;
- len -= 3;
- } while (len > 2);
- if (len) {
- *out++ = *from++;
- if (len > 1)
- *out++ = *from++;
- }
+ /* Whole reference is in range of current output. No
+ range checks are necessary because we start with room
+ for at least 258 bytes of output, so unroll and roundoff
+ operations can write beyond `out+len` so long as they
+ stay within 258 bytes of `out`.
+ */
+ out = chunkcopy_lapped_relaxed(out, dist, len);
}
}
else if ((op & 64) == 0) { /* 2nd level distance code */
diff --git a/contrib/arm/inflate.c b/contrib/arm/inflate.c
index ac333e8c..e40322c3 100644
--- a/contrib/arm/inflate.c
+++ b/contrib/arm/inflate.c
@@ -84,6 +84,7 @@
#include "inftrees.h"
#include "inflate.h"
#include "inffast.h"
+#include "contrib/arm/chunkcopy.h"
#ifdef MAKEFIXED
# ifndef BUILDFIXED
@@ -405,10 +406,20 @@ unsigned copy;
/* if it hasn't been done already, allocate space for the window */
if (state->window == Z_NULL) {
+ unsigned wsize = 1U << state->wbits;
state->window = (unsigned char FAR *)
- ZALLOC(strm, 1U << state->wbits,
+ ZALLOC(strm, wsize + CHUNKCOPY_CHUNK_SIZE,
sizeof(unsigned char));
if (state->window == Z_NULL) return 1;
+#ifdef INFLATE_CLEAR_UNUSED_UNDEFINED
+ /* Copies from the overflow portion of this buffer are undefined and
+ may cause analysis tools to raise a warning if we don't initialize
+ it. However, this undefined data overwrites other undefined data
+ and is subsequently either overwritten or left deliberately
+ undefined at the end of decode; so there's really no point.
+ */
+ memset(state->window + wsize, 0, CHUNKCOPY_CHUNK_SIZE);
+#endif
}
/* if window not in use yet, initialize */
@@ -1175,17 +1186,16 @@ int flush;
else
from = state->window + (state->wnext - copy);
if (copy > state->length) copy = state->length;
+ if (copy > left) copy = left;
+ put = chunkcopy_safe(put, from, copy, put + left);
}
else { /* copy from output */
- from = put - state->offset;
copy = state->length;
+ if (copy > left) copy = left;
+ put = chunkcopy_lapped_safe(put, state->offset, copy, put + left);
}
- if (copy > left) copy = left;
left -= copy;
state->length -= copy;
- do {
- *put++ = *from++;
- } while (--copy);
if (state->length == 0) state->mode = LEN;
break;
case LIT:

View File

@ -601,7 +601,7 @@ run_redir() {
[ "$tcp_node_http" = "1" ] && {
http_port=$tcp_node_http_port
}
run_socks TCP $TCP_NODE "0.0.0.0" $port $config_file $http_port $http_config_file
run_socks TCP $node "0.0.0.0" $port $config_file $http_port $http_config_file
}
}
;;

View File

@ -238,7 +238,6 @@ foreach my $mirror (@ARGV) {
push @mirrors, "http://ftp.acc.umu.se/mirror/gnu.org/savannah/$1";
push @mirrors, "http://nongnu.uib.no/$1";
push @mirrors, "http://ftp.igh.cnrs.fr/pub/nongnu/$1";
push @mirrors, "http://public.p-knowledge.co.jp/Savannah-nongnu-mirror/$1";
push @mirrors, "ftp://cdimage.debian.org/mirror/gnu.org/savannah/$1";
push @mirrors, "ftp://ftp.acc.umu.se/mirror/gnu.org/savannah/$1";
} elsif ($mirror =~ /^\@KERNEL\/(.+)$/) {
@ -252,7 +251,6 @@ foreach my $mirror (@ARGV) {
push @mirrors, "https://mirrors.cqu.edu.cn/kernel/$dir";
push @mirrors, "https://mirrors.ustc.edu.cn/kernel.org/$dir";
push @mirrors, "https://cdn.kernel.org/pub/$dir";
push @mirrors, "https://mirror.rackspace.com/kernel.org/pub/$dir";
push @mirrors, "https://download.xs4all.nl/ftp.kernel.org/pub/$dir";
push @mirrors, "https://mirrors.mit.edu/kernel/$dir";
push @mirrors, "http://ftp.nara.wide.ad.jp/pub/kernel.org/$dir";

View File

@ -0,0 +1,9 @@
. /lib/functions.sh
case "$(board_name)" in
raspberrypi,4-model-b)
sed -i 's/VHT80/VHT40/g' /lib/wifi/mac80211.sh
;;
esac
exit 0

View File

@ -1,11 +0,0 @@
#!/bin/sh
set_rpi_info() {
case "$(board_name)" in
raspberrypi,4-model-b)
sed -i 's/VHT80/VHT40/g' /lib/wifi/mac80211.sh
;;
esac
}
boot_hook_add preinit_main set_rpi_info