mirror of
https://github.com/kenzok8/small-package
synced 2025-01-08 13:27:36 +08:00
update 2023-09-21 17:57:24
This commit is contained in:
parent
b164dae5d6
commit
d2eb3f67e1
@ -169,9 +169,8 @@ o = s:taboption("advanced", Flag, "adblock", translate("Enable DNS ADblock"))
|
||||
o:depends("configfile", "/etc/mosdns/config.yaml")
|
||||
o.default = false
|
||||
|
||||
o = s:taboption("advanced", Value, "ad_source", translate("ADblock Source"), translate("When using custom rule sources, use the rule types supported by MosDNS"))
|
||||
o = s:taboption("advanced", DynamicList, "ad_source", translate("ADblock Source"), translate("When using custom rule sources, please use rule types supported by MosDNS (domain lists)."))
|
||||
o:depends("adblock", "1")
|
||||
o.default = "https://raw.githubusercontent.com/privacy-protection-tools/anti-AD/master/anti-ad-domains.txt"
|
||||
o:value("geosite.dat", "v2ray-geosite")
|
||||
o:value("https://raw.githubusercontent.com/privacy-protection-tools/anti-AD/master/anti-ad-domains.txt", "anti-AD")
|
||||
o:value("https://raw.githubusercontent.com/ookangzheng/dbl-oisd-nl/master/dbl_light.txt", "oisd (small)")
|
||||
|
@ -73,8 +73,8 @@ msgstr "启用 DNS 广告过滤"
|
||||
msgid "ADblock Source"
|
||||
msgstr "广告过滤规则来源"
|
||||
|
||||
msgid "When using custom rule sources, use the rule types supported by MosDNS"
|
||||
msgstr "使用自定义规则来源时,请使用 MosDNS 支持的规则类型"
|
||||
msgid "When using custom rule sources, please use rule types supported by MosDNS (domain lists)."
|
||||
msgstr "使用自定义规则来源时,请使用 MosDNS 支持的规则类型(域名列表)"
|
||||
|
||||
msgid "Restart-Service"
|
||||
msgstr "重启服务"
|
||||
|
@ -67,9 +67,9 @@ get_config() {
|
||||
|
||||
init_yaml() {
|
||||
TMPDIR=$(mktemp -d) || exit 1
|
||||
adlist=$($MOSDNS_SCRIPT ad)
|
||||
[ $enable_pipeline -eq 1 ] && enable_pipeline=true || enable_pipeline=false
|
||||
[ $insecure_skip_verify -eq 1 ] && insecure_skip_verify=true || insecure_skip_verify=false
|
||||
# HTTP/3
|
||||
[ $enable_http3_local -eq 1 ] && enable_http3_local=true || enable_http3_local=false
|
||||
[ $enable_http3_remote -eq 1 ] && enable_http3_remote=true || enable_http3_remote=false
|
||||
if [ $enable_http3_local = true ]; then
|
||||
@ -80,6 +80,7 @@ init_yaml() {
|
||||
[ -n "$address" ] && echo ${domain#*://} $address >> $RULE_HOSTS
|
||||
done
|
||||
fi
|
||||
# Write parameters
|
||||
[ "$custom_local_dns" -eq 1 ] && \
|
||||
local_dns=$($MOSDNS_SCRIPT dns | awk '{for(i=1;i<=NF;i++)printf "%s- addr: \"%s\"\n%s bootstrap: '${bootstrap_dns}'\n%s enable_pipeline: '${enable_pipeline}'\n%s max_conns: '${max_conns}'\n%s insecure_skip_verify: '${insecure_skip_verify}'\n%s idle_timeout: '${idle_timeout}'\n%s enable_http3: '${enable_http3_local}'\n",s,$i,s,s,s,s,s,s}' s=' ') || \
|
||||
local_dns=$($MOSDNS_SCRIPT dns | awk '{for(i=1;i<=NF;i++)printf "%s- addr: \"%s\"\n",s,$i,s}' s=' ')
|
||||
@ -90,20 +91,29 @@ init_yaml() {
|
||||
s,minimal_ttl_custom,$minimal_ttl_custom,g; \
|
||||
s,maximum_ttl_custom,$maximum_ttl_custom,g; \
|
||||
s,concurrent_num,$concurrent,g;s,api_port,$listen_port_api,g; \
|
||||
s,adblock,$adlist,g;s,remote_dns_pipeline,$enable_pipeline,g" $DEFAULT_CONF > $CONF
|
||||
s,remote_dns_pipeline,$enable_pipeline,g" $DEFAULT_CONF > $CONF
|
||||
# Adlist
|
||||
adlist=$($MOSDNS_SCRIPT adlist)
|
||||
echo "${adlist}" > $TMPDIR/adlist_files.txt
|
||||
sed -i -e '/ADBLOCK_LIST/{r '$TMPDIR/adlist_files.txt -e';d}' $CONF
|
||||
# DNS
|
||||
echo "${local_dns}" > $TMPDIR/local_dns.txt
|
||||
echo "${remote_dns}" > $TMPDIR/remote_dns.txt
|
||||
sed -i -e '/- addr: local_dns/{r '$TMPDIR/local_dns.txt -e';d};/- addr: remote_dns/{r '$TMPDIR/remote_dns.txt -e';d}' $CONF
|
||||
# Cache dump
|
||||
[ "$dump_file" -eq 1 ] && sed -i "/lazy_cache_ttl/a\ dump_file: $DUMP_FILE\n dump_interval: $dump_interval" $CONF
|
||||
[ "$dump_file" -eq 1 ] && [ ! -f $DUMP_FILE ] && cp -a $DUMP_FILE_DEFAULT $DUMP_FILE
|
||||
[ "$dump_file" -eq 0 ] && \cp -a $DUMP_FILE_DEFAULT $DUMP_FILE
|
||||
# ECS
|
||||
if [ "$enable_ecs_remote" -eq 1 ]; then
|
||||
ecs_remote=$(sh $MOSDNS_SCRIPT ecs_remote)
|
||||
sed -i "s,ecs_remote,$ecs_remote,g" $CONF
|
||||
else
|
||||
sed -i "/ecs_remote/d;" $CONF
|
||||
fi
|
||||
# DNS Leak
|
||||
[ $dns_leak -eq 1 ] && sed -i "s,primary: query_is_local_ip,primary: query_is_remote,g" $CONF
|
||||
# Cloudflare IP
|
||||
if [ $cloudflare -eq 1 ]; then
|
||||
cloudflare_ip=$(sh $MOSDNS_SCRIPT cloudflare)
|
||||
sed -i "s/CLOUDFLARE_IP/$cloudflare_ip/g" $CONF
|
||||
@ -193,11 +203,22 @@ start_service() {
|
||||
[ "$redirect" -ne 1 ] && [ -f "/etc/mosdns/redirect.lock" ] && restore_setting
|
||||
[ "$redirect" -eq 1 ] && redirect_setting
|
||||
reload_dnsmasq
|
||||
# Update Adlist
|
||||
update_list=0
|
||||
[ "$adblock" -eq 1 ] && [ "$ad_source" != "geosite.dat" ] && {
|
||||
[ -s "/etc/mosdns/rule/adlist.txt" ] && [ -f "/etc/mosdns/rule/.ad_source" ] && url_adlist=$(cat /etc/mosdns/rule/.ad_source) || update_list=1
|
||||
[ "$ad_source" != "$url_adlist" ] && update_list=1
|
||||
}
|
||||
if [ "$adblock" -eq 1 ]; then
|
||||
if [ -f "/etc/mosdns/rule/.ad_source" ]; then
|
||||
for url in $ad_source;
|
||||
do
|
||||
[ "$url" = "geosite.dat" ] && continue
|
||||
if [ $(grep -c "$url" "/etc/mosdns/rule/.ad_source") -eq 0 ]; then
|
||||
update_list=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
else
|
||||
update_list=1
|
||||
fi
|
||||
fi
|
||||
[ "$update_list" -eq 1 ] && $MOSDNS_SCRIPT adlist_update &> /dev/null &
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ plugins:
|
||||
type: domain_set
|
||||
args:
|
||||
files:
|
||||
- "adblock"
|
||||
ADBLOCK_LIST
|
||||
|
||||
- tag: local_ptr
|
||||
type: domain_set
|
||||
|
@ -29,37 +29,60 @@ interface_dns() (
|
||||
fi
|
||||
)
|
||||
|
||||
ad_block() (
|
||||
get_adlist() (
|
||||
adblock=$(uci -q get mosdns.config.adblock)
|
||||
if [ "$adblock" = 1 ]; then
|
||||
mkdir -p /etc/mosdns/rule/adlist
|
||||
ad_source=$(uci -q get mosdns.config.ad_source)
|
||||
if [ "$ad_source" = "geosite.dat" ]; then
|
||||
echo "/var/mosdns/geosite_category-ads-all.txt"
|
||||
else
|
||||
echo "/etc/mosdns/rule/adlist.txt"
|
||||
fi
|
||||
for url in $ad_source;
|
||||
do
|
||||
if [ $(echo $url) = 'geosite.dat' ]; then
|
||||
echo " - \"/var/mosdns/geosite_category-ads-all.txt\""
|
||||
else
|
||||
echo " - \"/etc/mosdns/rule/adlist/$(basename $url)\""
|
||||
[ ! -f "/etc/mosdns/rule/adlist/$(basename $url)" ] && touch /etc/mosdns/rule/adlist/$(basename $url)
|
||||
fi
|
||||
done
|
||||
else
|
||||
touch /var/disable-ads.txt ; echo "/var/disable-ads.txt"
|
||||
rm -rf /etc/mosdns/rule/adlist /etc/mosdns/rule/.ad_source /etc/mosdns/rule/adlist.txt
|
||||
touch /var/disable-ads.txt
|
||||
echo " - \"/var/disable-ads.txt\""
|
||||
fi
|
||||
)
|
||||
|
||||
adlist_update() (
|
||||
[ $(uci -q get mosdns.config.adblock) -eq 0 ] && exit 0
|
||||
ad_source=$(uci -q get mosdns.config.ad_source)
|
||||
[ "$ad_source" = "geosite.dat" ] || [ -z "$ad_source" ] && exit 0
|
||||
AD_TMPDIR=$(mktemp -d) || exit 1
|
||||
if echo "$ad_source" | grep -Eq "^https://raw.githubusercontent.com" ; then
|
||||
google_status=$(curl -I -4 -m 3 -o /dev/null -s -w %{http_code} http://www.google.com/generate_204)
|
||||
[ "$google_status" -ne "204" ] && mirror="https://ghproxy.com/"
|
||||
fi
|
||||
echo -e "\e[1;32mDownloading $mirror$ad_source\e[0m"
|
||||
curl --connect-timeout 60 -m 90 --ipv4 -kfSLo "$AD_TMPDIR/adlist.txt" "$mirror$ad_source"
|
||||
google_status=$(curl -I -4 -m 3 -o /dev/null -s -w %{http_code} http://www.google.com/generate_204)
|
||||
mirror=""
|
||||
: > /etc/mosdns/rule/.ad_source
|
||||
has_update=0
|
||||
for url in $ad_source;
|
||||
do
|
||||
if [ "$url" != "geosite.dat" ]; then
|
||||
echo "$url" >> /etc/mosdns/rule/.ad_source
|
||||
filename=$(basename $url)
|
||||
if echo "$url" | grep -Eq "^https://raw.githubusercontent.com" ; then
|
||||
[ "$google_status" -ne "204" ] && mirror="https://ghproxy.com/"
|
||||
fi
|
||||
echo -e "\e[1;32mDownloading $mirror$url\e[0m"
|
||||
curl --connect-timeout 5 -m 90 --ipv4 -kfSLo "$AD_TMPDIR/$filename" "$mirror$url"
|
||||
has_update=1
|
||||
fi
|
||||
done
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "\e[1;31mRules download failed.\e[0m"
|
||||
rm -rf "$AD_TMPDIR"
|
||||
exit 1
|
||||
else
|
||||
\cp "$AD_TMPDIR/adlist.txt" /etc/mosdns/rule/adlist.txt
|
||||
echo "$ad_source" > /etc/mosdns/rule/.ad_source
|
||||
rm -rf "$AD_TMPDIR"
|
||||
[ $has_update -eq 1 ] && {
|
||||
mkdir -p /etc/mosdns/rule/adlist
|
||||
rm -rf /etc/mosdns/rule/adlist/*
|
||||
\cp $AD_TMPDIR/* /etc/mosdns/rule/adlist
|
||||
rm -rf "$AD_TMPDIR"
|
||||
restart_service
|
||||
}
|
||||
fi
|
||||
)
|
||||
|
||||
@ -69,11 +92,11 @@ geodat_update() (
|
||||
[ "$google_status" -ne "204" ] && mirror="https://ghproxy.com/"
|
||||
# geoip.dat - cn-private
|
||||
echo -e "\e[1;32mDownloading "$mirror"https://github.com/Loyalsoldier/geoip/releases/latest/download/geoip-only-cn-private.dat\e[0m"
|
||||
curl --connect-timeout 60 -m 900 --ipv4 -kfSLo "$TMPDIR/geoip.dat" ""$mirror"https://github.com/Loyalsoldier/geoip/releases/latest/download/geoip-only-cn-private.dat"
|
||||
curl --connect-timeout 5 -m 60 --ipv4 -kfSLo "$TMPDIR/geoip.dat" ""$mirror"https://github.com/Loyalsoldier/geoip/releases/latest/download/geoip-only-cn-private.dat"
|
||||
[ $? -ne 0 ] && rm -rf "$TMPDIR" && exit 1
|
||||
# checksum - geoip.dat
|
||||
echo -e "\e[1;32mDownloading "$mirror"https://github.com/Loyalsoldier/geoip/releases/latest/download/geoip-only-cn-private.dat.sha256sum\e[0m"
|
||||
curl --connect-timeout 60 -m 900 --ipv4 -kfSLo "$TMPDIR/geoip.dat.sha256sum" ""$mirror"https://github.com/Loyalsoldier/geoip/releases/latest/download/geoip-only-cn-private.dat.sha256sum"
|
||||
curl --connect-timeout 5 -m 10 --ipv4 -kfSLo "$TMPDIR/geoip.dat.sha256sum" ""$mirror"https://github.com/Loyalsoldier/geoip/releases/latest/download/geoip-only-cn-private.dat.sha256sum"
|
||||
[ $? -ne 0 ] && rm -rf "$TMPDIR" && exit 1
|
||||
if [ "$(sha256sum "$TMPDIR/geoip.dat" | awk '{print $1}')" != "$(cat "$TMPDIR/geoip.dat.sha256sum" | awk '{print $1}')" ]; then
|
||||
echo -e "\e[1;31mgeoip.dat checksum error\e[0m"
|
||||
@ -83,11 +106,11 @@ geodat_update() (
|
||||
|
||||
# geosite.dat
|
||||
echo -e "\e[1;32mDownloading "$mirror"https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat\e[0m"
|
||||
curl --connect-timeout 60 -m 900 --ipv4 -kfSLo "$TMPDIR/geosite.dat" ""$mirror"https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat"
|
||||
curl --connect-timeout 5 -m 120 --ipv4 -kfSLo "$TMPDIR/geosite.dat" ""$mirror"https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat"
|
||||
[ $? -ne 0 ] && rm -rf "$TMPDIR" && exit 1
|
||||
# checksum - geosite.dat
|
||||
echo -e "\e[1;32mDownloading "$mirror"https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat.sha256sum\e[0m"
|
||||
curl --connect-timeout 60 -m 900 --ipv4 -kfSLo "$TMPDIR/geosite.dat.sha256sum" ""$mirror"https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat.sha256sum"
|
||||
curl --connect-timeout 5 -m 10 --ipv4 -kfSLo "$TMPDIR/geosite.dat.sha256sum" ""$mirror"https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat.sha256sum"
|
||||
[ $? -ne 0 ] && rm -rf "$TMPDIR" && exit 1
|
||||
if [ "$(sha256sum "$TMPDIR/geosite.dat" | awk '{print $1}')" != "$(cat "$TMPDIR/geosite.dat.sha256sum" | awk '{print $1}')" ]; then
|
||||
echo -e "\e[1;31mgeosite.dat checksum error\e[0m"
|
||||
@ -124,7 +147,7 @@ v2dat_dump() {
|
||||
# default config
|
||||
v2dat unpack geoip -o /var/mosdns -f cn $v2dat_dir/geoip.dat
|
||||
v2dat unpack geosite -o /var/mosdns -f cn -f 'geolocation-!cn' $v2dat_dir/geosite.dat
|
||||
[ "$adblock" -eq 1 ] && [ "$ad_source" = "geosite.dat" ] && v2dat unpack geosite -o /var/mosdns -f category-ads-all $v2dat_dir/geosite.dat
|
||||
[ "$adblock" -eq 1 ] && [ $(echo $ad_source | grep -c geosite.dat) -ge '1' ] && v2dat unpack geosite -o /var/mosdns -f category-ads-all $v2dat_dir/geosite.dat
|
||||
else
|
||||
# custom config
|
||||
v2dat unpack geoip -o /var/mosdns -f cn $v2dat_dir/geoip.dat
|
||||
@ -144,8 +167,8 @@ case $script_action in
|
||||
"dns")
|
||||
interface_dns
|
||||
;;
|
||||
"ad")
|
||||
ad_block
|
||||
"adlist")
|
||||
get_adlist
|
||||
;;
|
||||
"geodata")
|
||||
geodat_update && adlist_update && restart_service
|
||||
@ -154,7 +177,7 @@ case $script_action in
|
||||
logfile_path
|
||||
;;
|
||||
"adlist_update")
|
||||
adlist_update && restart_service
|
||||
adlist_update
|
||||
;;
|
||||
"ecs_remote")
|
||||
ecs_remote
|
||||
|
@ -5,12 +5,12 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=naiveproxy
|
||||
PKG_VERSION:=117.0.5938.44-1
|
||||
PKG_VERSION:=117.0.5938.44-2
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/klzgrad/naiveproxy/tar.gz/v$(PKG_VERSION)?
|
||||
PKG_HASH:=42bc36a068711bc0752930c201371495bd39279caed41e6ff4097e2b05d1844c
|
||||
PKG_HASH:=fa10ce129a3d6307cc45c811b4e4e67638421de247fda543112449682c78a75b
|
||||
|
||||
PKG_LICENSE:=BSD 3-Clause
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
@ -18,7 +18,6 @@ PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
|
||||
|
||||
PKG_BUILD_DEPENDS:=gn/host
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_USE_MIPS16:=0
|
||||
PKG_BUILD_FLAGS:=no-mips16
|
||||
|
||||
ifneq ($(CONFIG_CPU_TYPE)," ")
|
||||
|
@ -1,207 +0,0 @@
|
||||
--- a/src/build.sh
|
||||
+++ b/src/build.sh
|
||||
@@ -49,6 +49,9 @@ flags="$flags"'
|
||||
enable_reporting=false
|
||||
include_transport_security_state_preload_list=false
|
||||
use_nss_certs=false
|
||||
+
|
||||
+ enable_backup_ref_ptr_support=false
|
||||
+ enable_dangling_raw_ptr_checks=false
|
||||
'
|
||||
|
||||
if [ "$WITH_SYSROOT" ]; then
|
||||
--- a/src/net/tools/naive/naive_proxy_bin.cc
|
||||
+++ b/src/net/tools/naive/naive_proxy_bin.cc
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
+#include "base/allocator/partition_alloc_support.h"
|
||||
#include "base/at_exit.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/feature_list.h"
|
||||
@@ -145,7 +146,9 @@ class MultipleListenCollector : public b
|
||||
}
|
||||
}
|
||||
|
||||
- const std::vector<std::string>& GetAllValues() const { return all_values_; }
|
||||
+ const std::vector<std::string>& GetAllValues() const {
|
||||
+ return all_values_;
|
||||
+ }
|
||||
|
||||
private:
|
||||
std::vector<std::string> all_values_;
|
||||
@@ -539,7 +542,8 @@ int main(int argc, char* argv[]) {
|
||||
net::HttpNetworkSession::NORMAL_SOCKET_POOL,
|
||||
kDefaultMaxSocketsPerGroup * kExpectedMaxUsers);
|
||||
|
||||
- naive_partition_alloc_support::ReconfigureAfterFeatureListInit();
|
||||
+ base::allocator::PartitionAllocSupport::Get()
|
||||
+ ->ReconfigureAfterFeatureListInit(/*process_type=*/"");
|
||||
|
||||
#if BUILDFLAG(IS_APPLE)
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
@@ -576,7 +580,8 @@ int main(int argc, char* argv[]) {
|
||||
base::SingleThreadTaskExecutor io_task_executor(base::MessagePumpType::IO);
|
||||
base::ThreadPoolInstance::CreateAndStartWithDefaultParams("naive");
|
||||
|
||||
- naive_partition_alloc_support::ReconfigureAfterTaskRunnerInit();
|
||||
+ base::allocator::PartitionAllocSupport::Get()
|
||||
+ ->ReconfigureAfterTaskRunnerInit(/*process_type=*/"");
|
||||
|
||||
if (!params.ssl_key_path.empty()) {
|
||||
net::SSLClientSocket::SetSSLKeyLogger(
|
||||
--- a/src/net/tools/naive/partition_alloc_support.cc
|
||||
+++ b/src/net/tools/naive/partition_alloc_support.cc
|
||||
@@ -5,30 +5,13 @@
|
||||
|
||||
#include "net/tools/naive/partition_alloc_support.h"
|
||||
|
||||
-#include <string>
|
||||
-
|
||||
#include "base/allocator/allocator_check.h"
|
||||
-#include "base/allocator/buildflags.h"
|
||||
-#include "base/allocator/partition_alloc_features.h"
|
||||
#include "base/allocator/partition_alloc_support.h"
|
||||
-#include "base/allocator/partition_allocator/partition_alloc_config.h"
|
||||
#include "base/allocator/partition_allocator/shim/allocator_shim.h"
|
||||
-#include "base/allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_partition_alloc.h"
|
||||
-#include "base/allocator/partition_allocator/thread_cache.h"
|
||||
-#include "base/feature_list.h"
|
||||
+#include "base/check.h"
|
||||
#include "base/process/memory.h"
|
||||
-#include "base/time/time.h"
|
||||
#include "build/build_config.h"
|
||||
|
||||
-#if BUILDFLAG(IS_ANDROID)
|
||||
-#include "base/system/sys_info.h"
|
||||
-#endif
|
||||
-
|
||||
-#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
|
||||
-#include "base/allocator/partition_allocator/memory_reclaimer.h"
|
||||
-#include "base/task/single_thread_task_runner.h"
|
||||
-#endif
|
||||
-
|
||||
#if BUILDFLAG(IS_APPLE)
|
||||
#include "base/allocator/early_zone_registration_mac.h"
|
||||
#endif
|
||||
@@ -62,9 +45,8 @@ void ReconfigureEarly() {
|
||||
// ReconfigureEarlyish():
|
||||
// These initializations are only relevant for PartitionAlloc-Everywhere
|
||||
// builds.
|
||||
-#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
|
||||
- allocator_shim::EnablePartitionAllocMemoryReclaimer();
|
||||
-#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
|
||||
+ base::allocator::PartitionAllocSupport::Get()->ReconfigureEarlyish(
|
||||
+ /*process_type=*/"");
|
||||
|
||||
// content/app/content_main.cc: RunContentProcess()
|
||||
// content/app/content_main_runner_impl.cc: Initialize()
|
||||
@@ -75,96 +57,4 @@ void ReconfigureEarly() {
|
||||
CHECK(base::allocator::IsAllocatorInitialized());
|
||||
}
|
||||
|
||||
-void ReconfigureAfterFeatureListInit() {
|
||||
- // TODO(bartekn): Switch to DCHECK once confirmed there are no issues.
|
||||
- CHECK(base::FeatureList::GetInstance());
|
||||
-
|
||||
- // Does not use any of the security features yet.
|
||||
- [[maybe_unused]] bool enable_brp = false;
|
||||
- [[maybe_unused]] bool enable_memory_tagging = false;
|
||||
- [[maybe_unused]] bool split_main_partition = false;
|
||||
- [[maybe_unused]] bool use_dedicated_aligned_partition = false;
|
||||
- [[maybe_unused]] bool process_affected_by_brp_flag = false;
|
||||
-
|
||||
-#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
|
||||
- auto bucket_distribution = allocator_shim::BucketDistribution::kNeutral;
|
||||
- // No specified type means we are in the browser.
|
||||
- switch (base::features::kPartitionAllocBucketDistributionParam.Get()) {
|
||||
- case base::features::BucketDistributionMode::kDefault:
|
||||
- break;
|
||||
- case base::features::BucketDistributionMode::kDenser:
|
||||
- bucket_distribution = allocator_shim::BucketDistribution::kDenser;
|
||||
- break;
|
||||
- }
|
||||
-
|
||||
- allocator_shim::ConfigurePartitions(
|
||||
- allocator_shim::EnableBrp(enable_brp),
|
||||
- allocator_shim::EnableMemoryTagging(enable_memory_tagging),
|
||||
- partition_alloc::TagViolationReportingMode::kDisabled,
|
||||
- allocator_shim::SplitMainPartition(split_main_partition),
|
||||
- allocator_shim::UseDedicatedAlignedPartition(
|
||||
- use_dedicated_aligned_partition),
|
||||
- /*ref_count_size=*/0, bucket_distribution);
|
||||
-#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
|
||||
-
|
||||
-#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
|
||||
- allocator_shim::internal::PartitionAllocMalloc::Allocator()
|
||||
- ->EnableThreadCacheIfSupported();
|
||||
-
|
||||
- if (base::FeatureList::IsEnabled(
|
||||
- base::features::kPartitionAllocLargeEmptySlotSpanRing)) {
|
||||
- allocator_shim::internal::PartitionAllocMalloc::Allocator()
|
||||
- ->EnableLargeEmptySlotSpanRing();
|
||||
- allocator_shim::internal::PartitionAllocMalloc::AlignedAllocator()
|
||||
- ->EnableLargeEmptySlotSpanRing();
|
||||
- }
|
||||
-#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
|
||||
-}
|
||||
-
|
||||
-void ReconfigureAfterTaskRunnerInit() {
|
||||
-#if defined(PA_THREAD_CACHE_SUPPORTED) && \
|
||||
- BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
|
||||
- base::allocator::StartThreadCachePeriodicPurge();
|
||||
-
|
||||
-#if BUILDFLAG(IS_ANDROID)
|
||||
- // Lower thread cache limits to avoid stranding too much memory in the caches.
|
||||
- if (base::SysInfo::IsLowEndDevice()) {
|
||||
- ::partition_alloc::ThreadCacheRegistry::Instance().SetThreadCacheMultiplier(
|
||||
- ::partition_alloc::ThreadCache::kDefaultMultiplier / 2.);
|
||||
- }
|
||||
-#endif // BUILDFLAG(IS_ANDROID)
|
||||
-
|
||||
- // Renderer processes are more performance-sensitive, increase thread cache
|
||||
- // limits.
|
||||
- if (/*is_performance_sensitive=*/true &&
|
||||
- base::FeatureList::IsEnabled(
|
||||
- base::features::kPartitionAllocLargeThreadCacheSize)) {
|
||||
- size_t largest_cached_size =
|
||||
- ::partition_alloc::ThreadCacheLimits::kLargeSizeThreshold;
|
||||
-
|
||||
-#if BUILDFLAG(IS_ANDROID) && defined(ARCH_CPU_32_BITS)
|
||||
- // Devices almost always report less physical memory than what they actually
|
||||
- // have, so anything above 3GiB will catch 4GiB and above.
|
||||
- if (base::SysInfo::AmountOfPhysicalMemoryMB() <= 3500)
|
||||
- largest_cached_size =
|
||||
- ::partition_alloc::ThreadCacheLimits::kDefaultSizeThreshold;
|
||||
-#endif // BUILDFLAG(IS_ANDROID) && !defined(ARCH_CPU_64_BITS)
|
||||
-
|
||||
- ::partition_alloc::ThreadCache::SetLargestCachedSize(largest_cached_size);
|
||||
- }
|
||||
-
|
||||
-#endif // defined(PA_THREAD_CACHE_SUPPORTED) &&
|
||||
- // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
|
||||
-
|
||||
-#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
|
||||
- base::allocator::StartMemoryReclaimer(
|
||||
- base::SingleThreadTaskRunner::GetCurrentDefault());
|
||||
-#endif
|
||||
-
|
||||
- if (base::FeatureList::IsEnabled(
|
||||
- base::features::kPartitionAllocSortActiveSlotSpans)) {
|
||||
- partition_alloc::PartitionRoot::EnableSortActiveSlotSpans();
|
||||
- }
|
||||
-}
|
||||
-
|
||||
} // namespace naive_partition_alloc_support
|
||||
--- a/src/net/tools/naive/partition_alloc_support.h
|
||||
+++ b/src/net/tools/naive/partition_alloc_support.h
|
||||
@@ -9,8 +9,6 @@
|
||||
namespace naive_partition_alloc_support {
|
||||
|
||||
void ReconfigureEarly();
|
||||
-void ReconfigureAfterFeatureListInit();
|
||||
-void ReconfigureAfterTaskRunnerInit();
|
||||
|
||||
} // namespace naive_partition_alloc_support
|
||||
|
Loading…
Reference in New Issue
Block a user