From adac33b675d0a9579aad9cd174190727a5ff73c1 Mon Sep 17 00:00:00 2001 From: Mihai Ene Date: Tue, 1 Apr 2025 13:30:33 +0300 Subject: [PATCH 1/3] Impersonate safari on ios. --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index c5bd95c..135aa9e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,8 +12,8 @@ FROM node:18.9-slim ENV NODE_ENV production RUN apt-get update && apt-get install -y wget xz-utils -RUN wget "https://github.com/stunnel/static-curl/releases/download/8.8.0/curl-linux-x86_64-8.8.0.tar.xz" -qO - | tar -xJf - -RUN mv ./curl /usr/local/bin/curl && chmod +x /usr/local/bin/curl +RUN wget "https://github.com/lexiforest/curl-impersonate/releases/download/v0.9.5/curl-impersonate-v0.9.5.x86_64-linux-gnu.tar.gz" -qO - | tar -xzf - +RUN mv ./curl_safari18_0_ios /usr/local/bin/curl && chmod +x /usr/local/bin/curl ENV CURL_PATH /usr/local/bin/curl RUN mkdir /app && chown -R node:node /app From cd6862f29dcfc1abcc81786c87780c7f02680028 Mon Sep 17 00:00:00 2001 From: Mihai Ene Date: Tue, 1 Apr 2025 14:20:23 +0300 Subject: [PATCH 2/3] Keep the original curl binary. --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 135aa9e..57d1f54 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,8 +13,8 @@ ENV NODE_ENV production RUN apt-get update && apt-get install -y wget xz-utils RUN wget "https://github.com/lexiforest/curl-impersonate/releases/download/v0.9.5/curl-impersonate-v0.9.5.x86_64-linux-gnu.tar.gz" -qO - | tar -xzf - -RUN mv ./curl_safari18_0_ios /usr/local/bin/curl && chmod +x /usr/local/bin/curl -ENV CURL_PATH /usr/local/bin/curl +RUN chmod +x /curl_safari18_0_ios +ENV CURL_PATH /curl_safari18_0_ios RUN mkdir /app && chown -R node:node /app WORKDIR /app From eef07659f9477bf75d50ef101b79e6c4427d704e Mon Sep 17 00:00:00 2001 From: inca Date: Tue, 1 Apr 2025 14:33:16 +0300 Subject: [PATCH 3/3] chore: add support for custom curl binaries --- Dockerfile | 11 +++++++++-- src/main/global/CurlHandler.ts | 8 ++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 57d1f54..7df011a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,9 +12,16 @@ FROM node:18.9-slim ENV NODE_ENV production RUN apt-get update && apt-get install -y wget xz-utils + +RUN mkdir /curl-binaries +WORKDIR /curl-binaries RUN wget "https://github.com/lexiforest/curl-impersonate/releases/download/v0.9.5/curl-impersonate-v0.9.5.x86_64-linux-gnu.tar.gz" -qO - | tar -xzf - -RUN chmod +x /curl_safari18_0_ios -ENV CURL_PATH /curl_safari18_0_ios +RUN wget "https://github.com/stunnel/static-curl/releases/download/8.8.0/curl-linux-x86_64-8.8.0.tar.xz" -qO - | tar -xJf - +RUN chmod +x ./curl* + +# RUN ls -lia /curl-binaries + +ENV CURL_DEFAULT_PATH /curl-binaries/curl RUN mkdir /app && chown -R node:node /app WORKDIR /app diff --git a/src/main/global/CurlHandler.ts b/src/main/global/CurlHandler.ts index 2802842..6d82c26 100644 --- a/src/main/global/CurlHandler.ts +++ b/src/main/global/CurlHandler.ts @@ -4,6 +4,7 @@ import { CounterMetric, HistogramMetric, metric } from '@nodescript/metrics'; import { spawn } from 'child_process'; import { config } from 'mesh-config'; import { dep } from 'mesh-ioc'; +import path from 'path'; import { CurlHeaders } from '../../schema/CurlHeaders.js'; import { CurlMethod } from '../../schema/CurlMethod.js'; @@ -12,7 +13,7 @@ import { parseJson } from '../util.js'; export class CurlHandler extends HttpRouter { - @config({ default: 'curl' }) CURL_PATH!: string; + @config({ default: 'curl' }) CURL_DEFAULT_PATH!: string; @dep() private logger!: Logger; @@ -39,7 +40,10 @@ export class CurlHandler extends HttpRouter { const request = this.parseRequestSpec(ctx); try { const args = this.prepareArgs(request); - const child = spawn(this.CURL_PATH, args, { + const curlPath = request.options.curlBinary ? + path.join(path.dirname(this.CURL_DEFAULT_PATH), request.options.curlBinary) : + this.CURL_DEFAULT_PATH; + const child = spawn(curlPath, args, { stdio: 'pipe', }); if (this.supportsBody(request.method)) {