From 4d64376bae40fd27096756d3ce62ddf2c52e2535 Mon Sep 17 00:00:00 2001 From: woniuzfb <47843848+woniuzfb@users.noreply.github.com> Date: Tue, 19 Mar 2024 20:53:06 +0800 Subject: [PATCH] fix --- core | 2 +- docs/iptv.sh | 43 +++++++++-------- iptv.sh | 43 +++++++++-------- ..._lua_resp_get_headers_key_whitespace.patch | 6 +-- scripts/node-libcurl-impersonate.patch | 12 ++--- src/lhh | 6 +-- src/nx | 47 ++++++++++--------- src/or | 16 +++---- utils/curl | 30 ++++++++---- 9 files changed, 113 insertions(+), 92 deletions(-) diff --git a/core b/core index 8651122..8ee0b0b 100644 --- a/core +++ b/core @@ -93,7 +93,7 @@ CurlFake() "${CURL_IMPERSONATE_FILE}-$service_name" "$@" return 0 fi - curl-impersonate "$@" + $CURL_IMPERSONATE_FILE "$@" } SetDelimiters() diff --git a/docs/iptv.sh b/docs/iptv.sh index 375bc4e..4e69c0f 100755 --- a/docs/iptv.sh +++ b/docs/iptv.sh @@ -84,6 +84,8 @@ dim_underlined='\033[37;4;2m' indent_6='\r\033[6C' indent_20='\r\033[20C' +shopt -s extglob + Println() { printf '\n%b\n' "$1" @@ -27716,7 +27718,7 @@ OpenrestyInstall() 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 @@ -27725,7 +27727,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 ../.. @@ -27896,30 +27898,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#*\K[^<]+')) + + for openssl_ver in "${openssl_vers[@]}" + do + if [ "${openssl_ver%%.*}" -eq 1 ] then - openssl_name=${line#* /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 '\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%..." diff --git a/iptv.sh b/iptv.sh index 375bc4e..4e69c0f 100755 --- a/iptv.sh +++ b/iptv.sh @@ -84,6 +84,8 @@ dim_underlined='\033[37;4;2m' indent_6='\r\033[6C' indent_20='\r\033[20C' +shopt -s extglob + Println() { printf '\n%b\n' "$1" @@ -27716,7 +27718,7 @@ OpenrestyInstall() 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 @@ -27725,7 +27727,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 ../.. @@ -27896,30 +27898,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#*\K[^<]+')) + + for openssl_ver in "${openssl_vers[@]}" + do + if [ "${openssl_ver%%.*}" -eq 1 ] then - openssl_name=${line#* /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 '\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%..." diff --git a/scripts/fix_ngx_lua_resp_get_headers_key_whitespace.patch b/scripts/fix_ngx_lua_resp_get_headers_key_whitespace.patch index 0ba8f23..4b118d2 100644 --- a/scripts/fix_ngx_lua_resp_get_headers_key_whitespace.patch +++ b/scripts/fix_ngx_lua_resp_get_headers_key_whitespace.patch @@ -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; @@ -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; } diff --git a/scripts/node-libcurl-impersonate.patch b/scripts/node-libcurl-impersonate.patch index 9c41cec..1b978fa 100644 --- a/scripts/node-libcurl-impersonate.patch +++ b/scripts/node-libcurl-impersonate.patch @@ -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' @@ -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", diff --git a/src/lhh b/src/lhh index 456d20e..bc0e527 100644 --- a/src/lhh +++ b/src/lhh @@ -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" ] @@ -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 @@ -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" ] diff --git a/src/nx b/src/nx index 41d5465..0112d49 100644 --- a/src/nx +++ b/src/nx @@ -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 @@ -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#*\K[^<]+')) + + for openssl_ver in "${openssl_vers[@]}" + do + if [ "${openssl_ver%%.*}" -eq 1 ] then - openssl_name=${line#* /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 '\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%..." @@ -469,7 +470,7 @@ 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 @@ -477,6 +478,7 @@ Println " nginx 管理面板 ${normal}${red}[v$sh_ver]${normal} ${green}18.${normal} 配置 dnscrypt proxy ${green}19.${normal} 识别 cloudflare/ibm ip ${green}20.${normal} 删除域名 + ${green}21.${normal} 日志切割 ${tip} 输入: nx 打开面板 @@ -529,7 +531,7 @@ case "$nginx_num" in NginxRestart ;; 13) - NginxLogRotate + VimConfig ;; 14) NodejsMenu @@ -552,6 +554,9 @@ case "$nginx_num" in 20) NginxDeleteDomain ;; + 21) + NginxLogRotate + ;; *) Println "$error $i18n_input_correct_number [1-20]\n" ;; esac diff --git a/src/or b/src/or index a94eeb0..37946c8 100644 --- a/src/or +++ b/src/or @@ -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 @@ -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 ../../ @@ -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 @@ -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 ../.. diff --git a/utils/curl b/utils/curl index 4f89c97..997ca41 100644 --- a/utils/curl +++ b/utils/curl @@ -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" ] @@ -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 @@ -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" }