Skip to content

Commit

Permalink
86.0.4240.75-1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kenzok8 committed Oct 15, 2020
1 parent 2035133 commit 474f982
Show file tree
Hide file tree
Showing 5 changed files with 308 additions and 0 deletions.
86 changes: 86 additions & 0 deletions naiveproxy/Makefile
@@ -0,0 +1,86 @@
#
# Copyright (C) 2020 Project OpenWrt
#
# This is free software, licensed under the GNU General Public License v3.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk

PKG_NAME:=naiveproxy
PKG_VERSION:=86.0.4240.75-1
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:=91f946e137565115649bc5787788a6889d84e0a20e9878553a832b89c0cb161f
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)

PKG_LICENSE:=BSD 3-Clause
PKG_LICENSE_FILES:=LICENSE
PKG_MAINTAINER:=CN_SZTL <cnsztl@project-openwrt.eu.org>

PKG_BUILD_DEPENDS:=ninja/host python3/host
PKG_USE_MIPS16:=0
PKG_BUILD_PARALLEL:=1

ifneq ($(CONFIG_CPU_TYPE)," ")
CPU_TYPE:=$(word 1, $(subst +," ,$(CONFIG_CPU_TYPE)))
CPU_SUBTYPE:=$(word 2, $(subst +, ",$(CONFIG_CPU_TYPE)))
ifeq ($(CPU_SUBTYPE),)
CPU_SUBTYPE:=""
endif
else
CPU_TYPE:=""
CPU_SUBTYPE:=""
endif

include $(INCLUDE_DIR)/package.mk

define Package/naiveproxy/config
depends on !(arc||armeb||mips||mips64||powerpc)
endef

define Package/naiveproxy
SECTION:=net
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
URL:=https://github.com/klzgrad/naiveproxy
TITLE:=Make a fortune quietly
DEPENDS:=+libatomic +libnss
endef

define Package/naiveproxy/description
NaïveProxy uses Chrome's network stack to camouflage traffic with strong
censorship resistance and low detectability. Reusing Chrome's stack also
ensures best practices in performance and security.
endef

ifneq ($(CONFIG_CCACHE),)
export CCACHE_SLOPPINESS=time_macros
export CCACHE_BASEDIR=$(PKG_BUILD_DIR)/src
export CCACHE_CPP2=yes
export naive_ccache_flags=cc_wrapper="ccache"
endif

define Build/Compile
( \
cd $(PKG_BUILD_DIR) ; \
./tools/import-upstream.sh ; \
. ./init_env.sh "$(ARCH)" "$(BOARD)" $(CPU_TYPE) $(CPU_SUBTYPE) "$(TOOLCHAIN_DIR)" "$(DL_DIR)"; \
export naive_flags="$$$${naive_flags} $$$${naive_ccache_flags}" ; \
export OP_STAGING_DIR="$(STAGING_DIR)" ; \
mkdir -p out ; \
./gn/out/gn gen "out/Release" --args="$$$${naive_flags}" --script-executable="$(STAGING_DIR_HOSTPKG)/bin/python3" ; \
$(STAGING_DIR_HOSTPKG)/bin/ninja -C "out/Release" naive ; \
)
endef

define Package/naiveproxy/conffiles
endef

define Package/naiveproxy/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/out/Release/naive $(1)/usr/bin/naive
endef

$(eval $(call BuildPackage,naiveproxy))
44 changes: 44 additions & 0 deletions naiveproxy/patches/001-Remove-concurrency-limit.patch
@@ -0,0 +1,44 @@
From f1a49736010170a70123db07ca41256ba92c0002 Mon Sep 17 00:00:00 2001
From: klzgrad <kizdiv@gmail.com>
Date: Sat, 3 Oct 2020 08:54:59 +0800
Subject: [PATCH] Remove concurrency limit

---
src/net/tools/naive/naive_proxy.cc | 3 +--
src/net/tools/naive/naive_proxy_bin.cc | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/net/tools/naive/naive_proxy.cc b/src/net/tools/naive/naive_proxy.cc
index b4d5feee6..a38f79124 100644
--- a/src/net/tools/naive/naive_proxy.cc
+++ b/src/net/tools/naive/naive_proxy.cc
@@ -5,7 +5,6 @@

#include "net/tools/naive/naive_proxy.h"

-#include <algorithm>
#include <utility>

#include "base/bind.h"
@@ -35,7 +34,7 @@ NaiveProxy::NaiveProxy(std::unique_ptr<ServerSocket> listen_socket,
const NetworkTrafficAnnotationTag& traffic_annotation)
: listen_socket_(std::move(listen_socket)),
protocol_(protocol),
- concurrency_(std::min(4, std::max(1, concurrency))),
+ concurrency_(concurrency),
resolver_(resolver),
session_(session),
net_log_(
diff --git a/src/net/tools/naive/naive_proxy_bin.cc b/src/net/tools/naive/naive_proxy_bin.cc
index 4ba08712d..00acd7756 100644
--- a/src/net/tools/naive/naive_proxy_bin.cc
+++ b/src/net/tools/naive/naive_proxy_bin.cc
@@ -289,7 +289,7 @@ bool ParseCommandLine(const CommandLine& cmdline, Params* params) {

if (!cmdline.concurrency.empty()) {
if (!base::StringToInt(cmdline.concurrency, &params->concurrency) ||
- params->concurrency < 1 || params->concurrency > 4) {
+ params->concurrency < 1) {
std::cerr << "Invalid concurrency" << std::endl;
return false;
}
33 changes: 33 additions & 0 deletions naiveproxy/patches/100-build-add-OpenWrt-staging-libraries.patch
@@ -0,0 +1,33 @@
From 5b476d92f8dbee8b83061faa8cd18a46e5ab4aae Mon Sep 17 00:00:00 2001
From: CN_SZTL <cnsztl@project-openwrt.eu.org>
Date: Tue, 18 Aug 2020 20:36:39 +0000
Subject: [PATCH] build: add OpenWrt staging libraries

---
src/build/config/posix/BUILD.gn | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/src/build/config/posix/BUILD.gn b/src/build/config/posix/BUILD.gn
index 9ccb89f27..de9e5501d 100644
--- a/src/build/config/posix/BUILD.gn
+++ b/src/build/config/posix/BUILD.gn
@@ -28,6 +28,9 @@ config("runtime_library") {
if (!is_mac && !is_ios && sysroot != "") {
# Pass the sysroot to all C compiler variants, the assembler, and linker.
sysroot_flags = [ "--sysroot=" + rebase_path(sysroot, root_build_dir) ]
+ sysroot_flags += [ "-I" + getenv("OP_STAGING_DIR") + "/usr/include" ]
+ sysroot_flags += [ "-I" + getenv("OP_STAGING_DIR") + "/usr/include/nss" ]
+ sysroot_flags += [ "-I" + getenv("OP_STAGING_DIR") + "/usr/include/nspr" ]
if (is_linux || is_chromeos) {
# This is here so that all files get recompiled after a sysroot roll and
# when turning the sysroot on or off. (defines are passed via the command
@@ -57,6 +60,7 @@ config("runtime_library") {
cflags_objcc += sysroot_flags

# Need to get some linker flags out of the sysroot.
+ ldflags += [ "-L" + getenv("OP_STAGING_DIR") + "/usr/lib" ]
ld_paths = exec_script("sysroot_ld_path.py",
[
rebase_path("//build/linux/sysroot_ld_path.sh",
--
2.17.1
32 changes: 32 additions & 0 deletions naiveproxy/patches/101-build-drop-useless-deps-simd_asm.patch
@@ -0,0 +1,32 @@
From dd07b78f561914ccc6cbe076ae66c380304bf92c Mon Sep 17 00:00:00 2001
From: CN_SZTL <cnsztl@project-openwrt.eu.org>
Date: Wed, 19 Aug 2020 12:42:45 +0000
Subject: [PATCH] build: drop useless deps simd_asm

libjpeg_turbo itself has alreadly set the dependency "simd_asm",
and this will cause cross-compile failed:
```
ERROR Unresolved dependencies.
//:gn_all(//build/toolchain/linux:clang_arm64_openwrt)
needs //third_party/libjpeg_turbo:simd_asm(//build/toolchain/linux:clang_arm64_openwrt)
```
So, let's drop it in global build file.
---
src/BUILD.gn | 1 -
1 file changed, 1 deletion(-)

diff --git a/src/BUILD.gn b/src/BUILD.gn
index 97494c0a0..daddf5213 100644
--- a/src/BUILD.gn
+++ b/src/BUILD.gn
@@ -751,7 +751,6 @@ group("gn_all") {
if (enable_nacl) {
deps += [ "//native_client/src/trusted/platform_qualify:vcpuid" ]
}
- deps += [ "//third_party/libjpeg_turbo:simd_asm" ]
}
if ((is_linux || is_chromeos) && current_toolchain == host_toolchain) {
deps += [ "//v8:v8_shell" ]
--
2.17.1

113 changes: 113 additions & 0 deletions naiveproxy/src/init_env.sh
@@ -0,0 +1,113 @@
#!/bin/bash
# [CTCGFW] Project-OpenWrt
# Use it under GPLv3.
# --------------------------------------------------------
# Init build dependencies for naiveproxy

# Read args from shell
target_arch="$1"
target_board="$2"
cpu_type="$3"
cpu_subtype="$4"
toolchain_dir="$5"
dl_dir="$6"

# Set arch info
naive_arch="${target_arch}"
[ "${target_arch}" == "i386" ] && naive_arch="x86"
[ "${target_arch}" == "x86_64" ] && naive_arch="x64"
[ "${target_arch}" == "aarch64" ] && naive_arch="arm64"
ldso_path="/lib/$(find "${toolchain_dir}/" | grep -Eo "ld-musl-[a-z0-9_-]+\\.so\\.1")"

# OS detection
[ "$(uname)" != "Linux" -o "$(uname -m)" != "x86_64" ] && { echo -e "Support Linux AMD64 only."; exit 1; }

cd "$PWD/src"

# AFDO profile
[ ! -f "chrome/android/profiles/afdo.prof" ] && {
AFDO_NAME="$(cat "chrome/android/profiles/newest.txt")"
[ ! -f "${dl_dir}/${AFDO_NAME}" ] && curl -f --connect-timeout 20 --retry 5 --location --insecure "https://storage.googleapis.com/chromeos-prebuilt/afdo-job/llvm/${AFDO_NAME}" -o "${dl_dir}/${AFDO_NAME}"
bzip2 -cd > "chrome/android/profiles/afdo.prof" < "${dl_dir}/${AFDO_NAME}"
}

# Download Clang
[ ! -d "third_party/llvm-build/Release+Asserts/bin" ] && {
mkdir -p "third_party/llvm-build/Release+Asserts"
CLANG_REVISION="$(python3 "tools/clang/scripts/update.py" --print-revision)"
[ ! -f "${dl_dir}/clang-${CLANG_REVISION}.tgz" ] && curl -f --connect-timeout 20 --retry 5 --location --insecure "https://commondatastorage.googleapis.com/chromium-browser-clang/Linux_x64/clang-${CLANG_REVISION}.tgz" -o "${dl_dir}/clang-${CLANG_REVISION}.tgz"
tar -xzf "${dl_dir}/clang-${CLANG_REVISION}.tgz" -C "third_party/llvm-build/Release+Asserts"
}

# Download GN tool
[ ! -f "gn/out/gn" ] && {
mkdir -p "gn/out"
GN_VERSION="$(grep "'gn_version':" "buildtools/DEPS" | cut -d"'" -f4)"
[ ! -f "${dl_dir}/gn-${GN_VERSION}.zip" ] && curl -f --connect-timeout 20 --retry 5 --location --insecure "https://chrome-infra-packages.appspot.com/dl/gn/gn/linux-amd64/+/${GN_VERSION}" -o "${dl_dir}/gn-${GN_VERSION}.zip"
unzip -o "${dl_dir}/gn-${GN_VERSION}.zip" -d "gn/out"
}

# Set ENV
export DEPOT_TOOLS_WIN_TOOLCHAIN=0
export naive_flags="
is_official_build=true
exclude_unwind_tables=true
enable_resource_whitelist_generation=false
symbol_level=0
is_clang=true
use_sysroot=false
use_allocator=\"none\"
use_allocator_shim=false
fatal_linker_warnings=false
treat_warnings_as_errors=false
fieldtrial_testing_like_official_build=true
enable_base_tracing=false
enable_nacl=false
enable_print_preview=false
enable_remoting=false
use_alsa=false
use_cups=false
use_dbus=false
use_gio=false
use_platform_icu_alternatives=true
use_gtk=false
use_system_libdrm=false
use_gnome_keyring=false
use_libpci=false
use_pangocairo=false
use_glib=false
use_pulseaudio=false
use_udev=false
disable_file_support=true
enable_websockets=false
disable_ftp_support=true
use_kerberos=false
enable_mdns=false
enable_reporting=false
include_transport_security_state_preload_list=false
rtc_use_pipewire=false
use_xkbcommon=false
use_ozone=true
ozone_auto_platforms=false
ozone_platform=\"headless\"
ozone_platform_headless=true
current_os=\"linux\"
current_cpu=\"${naive_arch}\"
sysroot=\"${toolchain_dir}\"
custom_toolchain=\"//build/toolchain/linux:clang_${naive_arch}_openwrt\"
ldso_path=\"${ldso_path}\""
[ "${target_arch}" == "arm" ] && {
naive_flags="${naive_flags} arm_version=0 arm_cpu=\"${cpu_type}\""
[ -n "${cpu_subtype}" ] && { echo "${cpu_subtype}" | grep -q "neon" && neon_flag="arm_use_neon=true" || neon_flag="arm_use_neon=false"; naive_flags="${naive_flags} arm_fpu=\"${cpu_subtype}\" arm_float_abi=\"hard\" ${neon_flag}"; } || naive_flags="${naive_flags} arm_float_abi=\"soft\" arm_use_neon=false"
}
[[ "mips mips64 mipsel mips64el" =~ (^|[[:space:]])"${target_arch}"($|[[:space:]]) ]] && {
naive_flags="${naive_flags} use_gold=false is_cfi=false use_cfi_icall=false use_thin_lto=false mips_arch_variant=\"r2\""
[[ "${target_arch}" =~ ^"mips"$|^"mipsel"$ ]] && naive_flags="${naive_flags} mips_float_abi=\"soft\" mips_tune=\"${cpu_type}\""
}

0 comments on commit 474f982

Please sign in to comment.