Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
woniuzfb committed Mar 19, 2024
1 parent 60b29b7 commit 0934f1e
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 59 deletions.
2 changes: 1 addition & 1 deletion core
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ CurlFake()
"${CURL_IMPERSONATE_FILE}-$service_name" "$@"
return 0
fi
curl-impersonate "$@"
$CURL_IMPERSONATE_FILE "$@"
}

SetDelimiters()
Expand Down
6 changes: 3 additions & 3 deletions scripts/fix_ngx_lua_resp_get_headers_key_whitespace.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/src/ngx_http_lua_headers.c b/src/ngx_http_lua_headers.c
index d8d5edc8..5466ae47 100644
index 85836a1..ea526af 100644
--- a/src/ngx_http_lua_headers.c
+++ b/src/ngx_http_lua_headers.c
@@ -417,7 +417,7 @@ ngx_http_lua_ngx_resp_get_headers(lua_State *L)
@@ -429,7 +429,7 @@ ngx_http_lua_ngx_resp_get_headers(lua_State *L)
ngx_http_lua_ctx_t *ctx;
u_char *lowcase_key = NULL;
size_t lowcase_key_sz = 0;
Expand All @@ -11,7 +11,7 @@ index d8d5edc8..5466ae47 100644
int n;
int max;
int raw = 0;
@@ -556,6 +556,29 @@ ngx_http_lua_ngx_resp_get_headers(lua_State *L)
@@ -568,6 +568,29 @@ ngx_http_lua_ngx_resp_get_headers(lua_State *L)
continue;
}

Expand Down
12 changes: 6 additions & 6 deletions scripts/node-libcurl-impersonate.patch
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ index a12448b..3ee0452 100644
tsconfig.tsbuildinfo
website/
diff --git a/lib/Curl.ts b/lib/Curl.ts
index d2a419c..5d44ba3 100644
index 14013df..7f89018 100644
--- a/lib/Curl.ts
+++ b/lib/Curl.ts
@@ -69,7 +69,7 @@ import { CurlReadFunc } from './enum/CurlReadFunc'
Expand Down Expand Up @@ -64,22 +64,22 @@ index 9bba413..bccbb1e 100644
/**
* This is a Node.js wrapper around the binding {@link EasyNativeBinding | native Easy class}.
diff --git a/package.json b/package.json
index 15071fd..49350a8 100644
index 4d392fc..633a602 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
- "name": "node-libcurl",
+ "name": "node-libcurl-impersonate",
"version": "3.0.0",
"version": "4.0.0",
- "description": "The fastest http(s) client (and much more) for Node.js - Node.js bindings for libcurl",
+ "description": "The fastest http(s) client (and much more) for Node.js - Node.js bindings for libcurl (curl-impersonate)",
"keywords": [
"node-curl",
"curl",
@@ -23,7 +23,7 @@
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
@@ -30,7 +30,7 @@
"LIBCURL_VERSION_WIN_DEPS"
],
"binary": {
- "module_name": "node_libcurl",
+ "module_name": "node_libcurl-impersonate",
Expand Down
6 changes: 3 additions & 3 deletions src/lhh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ LhhDownload()
ZhLhhDownload()
{
local book_url="$1" title="$2" i j
local book_path="$save_dir/$title"
local book_path="$save_dir/${title//\//_}"

i=2
until [ ! -d "$book_path" ]
Expand Down Expand Up @@ -465,7 +465,7 @@ reduce ({adapter,addtime,bookname,category_id,cover,drawing,m,muludir,original,p
HdlzZhihuDownload()
{
local id=$1 title=$2 i j
local book_path="$save_dir/$title"
local book_path="$save_dir/${title//\//_}"
shift 2

i=2
Expand Down Expand Up @@ -548,7 +548,7 @@ HdlzZhihuDownload()
HdlzToutiaoDownload()
{
local id=$1 title=$2 i j
local book_path="$save_dir/$title"
local book_path="$save_dir/${title//\//_}"

i=2
until [ ! -d "$book_path" ]
Expand Down
47 changes: 26 additions & 21 deletions src/nx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ NginxInstall()

if [ "$dist" == "mac" ] && [ ! -d /usr/local/nginx ]
then
Println "$info 建立目录 /usr/local/nginx\n"
Println "$info 建立目录 /usr/local/nginx, 可能需要输入密码\n"
sudo mkdir /usr/local/nginx
sudo chown $USER /usr/local/nginx
fi
Expand Down Expand Up @@ -261,30 +261,31 @@ NginxInstall()
fi
fi

while IFS= read -r line
do
if [ "$openssl_options_index" -eq 0 ]
then
if [[ $line == *"openssl-1."* ]]
then
openssl_name=${line#*<a href=\"}
openssl_name=${openssl_name%%.tar.gz*}
break
fi
else
if [[ $line == *"openssl-3.0"* ]]
if [ "$openssl_options_index" -eq 0 ]
then
openssl_url="https://www.openssl.org/source/old"
openssl_vers=($(curl -s -Lm 20 $openssl_url/ | grep -oP '<li><a href="[^"]+">\K[^<]+'))

for openssl_ver in "${openssl_vers[@]}"
do
if [ "${openssl_ver%%.*}" -eq 1 ]
then
openssl_name=${line#*<a href=\"}
openssl_name=${openssl_name%%.tar.gz*}
break
fi
fi
done < <(curl -s -L -H "User-Agent: $USER_AGENT_BROWSER" https://www.openssl.org/source/ 2> /dev/null)
done
openssl_url="$openssl_url/$openssl_ver"
else
openssl_url="https://www.openssl.org/source"
fi

openssl_packs=($(curl -s -Lm 20 $openssl_url/ | grep -oP '<td><a href="[^"]+">\K[^<]+'))
openssl_pack="${openssl_packs[0]}"
openssl_name=${openssl_pack%.tar*}

if [ ! -d "./$openssl_name" ]
then
curl -s -L "https://www.openssl.org/source/$openssl_name.tar.gz" -o "$openssl_name.tar.gz"
tar xzf "$openssl_name.tar.gz"
curl -s -L "$openssl_url/$openssl_pack" -o "$openssl_pack"
tar xzf "$openssl_pack"
fi

echo -n "...60%..."
Expand Down Expand Up @@ -469,14 +470,15 @@ Println " nginx 管理面板 ${normal}${red}[v$sh_ver]${normal}
${green}11.${normal} 开关
${green}12.${normal} 重启
————————————
${green}13.${normal} 配置 日志切割
${green}13.${normal} 配置 vim
${green}14.${normal} 配置 nodejs
${green}15.${normal} 配置 mongodb
${green}16.${normal} 配置 postfix
${green}17.${normal} 配置 mmproxy
${green}18.${normal} 配置 dnscrypt proxy
${green}19.${normal} 识别 cloudflare/ibm ip
${green}20.${normal} 删除域名
${green}21.${normal} 日志切割

${tip} 输入: nx 打开面板

Expand Down Expand Up @@ -529,7 +531,7 @@ case "$nginx_num" in
NginxRestart
;;
13)
NginxLogRotate
VimConfig
;;
14)
NodejsMenu
Expand All @@ -552,6 +554,9 @@ case "$nginx_num" in
20)
NginxDeleteDomain
;;
21)
NginxLogRotate
;;
*) Println "$error $i18n_input_correct_number [1-20]\n"
;;
esac
Expand Down
16 changes: 8 additions & 8 deletions src/or
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ OpenrestyInstall()

if [ "$dist" == "mac" ] && [ ! -d /usr/local/openresty ]
then
Println "$info 建立目录 /usr/local/openresty\n"
Println "$info 建立目录 /usr/local/openresty, 可能需要输入密码\n"
sudo mkdir /usr/local/openresty
sudo chown $USER /usr/local/openresty
fi
Expand Down Expand Up @@ -178,7 +178,7 @@ OpenrestyInstall()
cd "$openresty_package_name/bundle/ngx_lua-"*

curl -s -L "$FFMPEG_MIRROR_LINK/fix_ngx_lua_resp_get_headers_key_whitespace.patch" -o fix_ngx_lua_resp_get_headers_key_whitespace.patch
patch -p1 < fix_ngx_lua_resp_get_headers_key_whitespace.patch >/dev/null 2>&1
patch -p1 < fix_ngx_lua_resp_get_headers_key_whitespace.patch >/dev/null 2>&1 || true

cd ../../

Expand Down Expand Up @@ -309,12 +309,12 @@ OpenrestyInstall()
then
rm -rf ${openssl_name}
rm -rf ${openssl_name}-patched
curl -s -L https://www.openssl.org/source/$openssl_name.tar.gz -o $openssl_name.tar.gz
tar xzf $openssl_name.tar.gz
mv $openssl_name $openssl_name-patched
cd $openssl_name-patched
curl -s -L https://www.openssl.org/source/old/1.1.1/${openssl_name}.tar.gz -o ${openssl_name}.tar.gz
tar xzf ${openssl_name}.tar.gz
mv ${openssl_name} ${openssl_name}-patched
cd ${openssl_name}-patched
curl -s -L "$FFMPEG_MIRROR_LINK/openssl-1.1.1f-sess_set_get_cb_yield.patch" -o openssl-1.1.1f-sess_set_get_cb_yield.patch
patch -p1 < openssl-1.1.1f-sess_set_get_cb_yield.patch >/dev/null 2>&1
patch -p1 < openssl-1.1.1f-sess_set_get_cb_yield.patch >/dev/null 2>&1 || true
cd ~
fi

Expand All @@ -323,7 +323,7 @@ OpenrestyInstall()
cd "$openresty_package_name/bundle/ngx_lua-"*

curl -s -L "$FFMPEG_MIRROR_LINK/fix_ngx_lua_resp_get_headers_key_whitespace.patch" -o fix_ngx_lua_resp_get_headers_key_whitespace.patch
patch -p1 < fix_ngx_lua_resp_get_headers_key_whitespace.patch >/dev/null 2>&1
patch -p1 < fix_ngx_lua_resp_get_headers_key_whitespace.patch >/dev/null 2>&1 || true

cd ../..

Expand Down
30 changes: 20 additions & 10 deletions utils/curl
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ CurlImpersonateCompile()
mkdir build && cd build
../configure --prefix="$curl_impersonate_prefix"
gmake chrome-build
Println "$tip 可能需要输入密码建立安装路径 $curl_impersonate_prefix"
sudo gmake chrome-install
else
if [ "$dist" == "rpm" ]
Expand All @@ -233,23 +234,25 @@ CurlImpersonateCompile()
sudo ldconfig
fi

if [ "$dist" == "mac" ]
then
Println "$tip 可能需要输入密码建立安装路径 ${curl_impersonate_prefix}/include/curl/"
fi

sudo mkdir -p "$curl_impersonate_prefix"/include/curl/
cp -f curl-*/include/curl/* "$curl_impersonate_prefix"/include/curl/
cp -f curl-*/curl-impersonate-chrome-config "$curl_impersonate_prefix"/bin/
chmod +x "$curl_impersonate_prefix"/bin/curl-impersonate-chrome-config
sudo cp -f curl-*/include/curl/* "$curl_impersonate_prefix"/include/curl/
# sudo cp -f curl-*/curl-impersonate-chrome-config "$curl_impersonate_prefix"/bin/
# sudo chmod +x "$curl_impersonate_prefix"/bin/curl-impersonate-chrome-config

# rm -f /usr/local/bin/curl-config
# ln -s "$curl_impersonate_prefix"/bin/curl-impersonate-chrome-config /usr/local/bin/curl-config
# sudo ln -s "$curl_impersonate_prefix"/bin/curl-impersonate-chrome-config /usr/local/bin/curl-config

Println "$info curl impersonate 编译成功\n"
}

NodeLibcurlImpersonateCompile()
{
if [[ ! -x $(command -v node) ]] || [[ ! -x $(command -v npm) ]]
then
NodejsInstall
fi
NodejsInstall

echo
inquirer text_input "输入编译安装好的 curl impersonate 路径" curl_impersonate_prefix /usr/local/curl-impersonate
Expand All @@ -271,10 +274,17 @@ NodeLibcurlImpersonateCompile()
git clone https://github.com/JCMais/node-libcurl.git node-libcurl-impersonate
cd node-libcurl-impersonate
curl -s -Lm 20 "$FFMPEG_MIRROR_LINK/node-libcurl-impersonate.patch" -o node-libcurl-impersonate.patch
patch -p1 < node-libcurl-impersonate.patch
patch -p1 < node-libcurl-impersonate.patch || true

if [ "$dist" == "mac" ]
then
Println "$tip 可能需要输入密码创建链接 ln -s ${curl_impersonate_prefix}/bin/curl-impersonate-chrome-config /usr/local/bin/curl-config"
fi

rm -f /usr/local/bin/curl-config
ln -s "$curl_impersonate_prefix"/bin/curl-impersonate-chrome-config /usr/local/bin/curl-config
sudo ln -s "$curl_impersonate_prefix"/bin/curl-impersonate-chrome-config /usr/local/bin/curl-config
npm install --force --unsafe-perm
npm run build:dist

Println "$info 查看 $HOME/node-libcurl-impersonate/lib/binding/node_libcurl-impersonate.node\n可以这样使用 const { Curl, CurlFeature, CurlHttpVersion, CurlSslVersion } = require('$HOME/node-libcurl-impersonate/dist')\n详见 https://github.com/lwthiker/curl-impersonate\n"
}
11 changes: 4 additions & 7 deletions utils/mirror
Original file line number Diff line number Diff line change
Expand Up @@ -357,14 +357,11 @@ else
Println "$error vim-plug.vim 下载出错, 无法连接 github ?"
fi

if [ ! -e "$FFMPEG_MIRROR_ROOT/openssl-1.1.1f-sess_set_get_cb_yield.patch" ]
if curl -s -L "https://raw.githubusercontent.com/openresty/openresty/master/patches/openssl-1.1.1f-sess_set_get_cb_yield.patch" -o "$FFMPEG_MIRROR_ROOT/openssl-1.1.1f-sess_set_get_cb_yield.patch_tmp"
then
if curl -s -L "https://raw.githubusercontent.com/openresty/openresty/master/patches/openssl-1.1.1f-sess_set_get_cb_yield.patch" -o "$FFMPEG_MIRROR_ROOT/openssl-1.1.1f-sess_set_get_cb_yield.patch_tmp"
then
mv "$FFMPEG_MIRROR_ROOT/openssl-1.1.1f-sess_set_get_cb_yield.patch_tmp" "$FFMPEG_MIRROR_ROOT/openssl-1.1.1f-sess_set_get_cb_yield.patch"
else
Println "$error openssl patch 下载出错, 无法连接 github ?"
fi
mv "$FFMPEG_MIRROR_ROOT/openssl-1.1.1f-sess_set_get_cb_yield.patch_tmp" "$FFMPEG_MIRROR_ROOT/openssl-1.1.1f-sess_set_get_cb_yield.patch"
else
Println "$error openssl patch 下载出错, 无法连接 github ?"
fi

if [ ! -e "$FFMPEG_MIRROR_ROOT/Add-SVT-HEVC-support-for-RTMP-and-HLS-on-Nginx-HTTP-FLV.patch" ]
Expand Down

0 comments on commit 0934f1e

Please sign in to comment.