build: bake the request-based solver into the image
This commit is contained in:
1 parent
64cc1a7577
commit
60057640dc
5 files changed
+31
-6
No files matched your search
+2
-2
@@ -16,8 +16,8 @@ MCP_HTTP_MAX_RETRIES=3
|
||||
# Trust store for https:// proxies: extra PEM appended to the bundled roots.
|
||||
MCP_PROXY_CA=
|
||||
|
||||
# Optional request-based solver (cfsolve). Empty uses the default WSL command;
|
||||
# "off" disables solving. A JSON array overrides the command prefix.
|
||||
# Request-based solver (cfsolve). Empty uses the default WSL command; in the image
|
||||
# it is /opt/cfsolve/challenge. "off" disables solving; a JSON array overrides it.
|
||||
MCP_SOLVER=
|
||||
MCP_SOLVER_PROFILE=profiles/safari-26-ios.json
|
||||
MCP_SOLVER_TIMEOUT=120
|
||||
|
||||
@@ -123,6 +123,13 @@ jobs:
|
||||
assert tools is not None
|
||||
print("smoke ok:", ids)
|
||||
PY
|
||||
- name: Solver binary answers offline
|
||||
run: |
|
||||
set -euo pipefail
|
||||
out=$(docker run --rm --network none --entrypoint /opt/cfsolve/challenge \
|
||||
"$IMAGE:${{ needs.image.outputs.tag }}" --help)
|
||||
printf '%s\n' "$out" | head -3
|
||||
printf '%s' "$out" | grep -q -- '--fingerprint'
|
||||
- name: Keep the transcript
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3.2.2
|
||||
|
||||
+19
-1
@@ -1,5 +1,7 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
ARG PYTHON_IMAGE=python:3.13-slim@sha256:168d3a5d10f2152f8e8d77b6843ac82c22a846cfefeef7afdf9aa630404e82a7
|
||||
# Request-based Cloudflare solver: pinned commit, own toolchain, no browser.
|
||||
ARG CFSOLVE_COMMIT=3d2f67ed56df29be6ceba1de60b7ab9077e554c8
|
||||
|
||||
FROM ${PYTHON_IMAGE} AS deps
|
||||
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy UV_PYTHON_DOWNLOADS=never
|
||||
@@ -8,18 +10,34 @@ WORKDIR /app
|
||||
COPY pyproject.toml uv.lock ./
|
||||
RUN uv sync --locked --no-dev --no-install-project
|
||||
|
||||
FROM ${PYTHON_IMAGE} AS solver
|
||||
ARG CFSOLVE_COMMIT
|
||||
ENV RUSTUP_HOME=/usr/local/rustup CARGO_HOME=/usr/local/cargo PATH=/usr/local/cargo/bin:$PATH
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends git curl ca-certificates build-essential cmake clang libclang-dev perl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
RUN curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain 1.98.0
|
||||
RUN git clone -q https://github.com/chris124567/cfsolve /src \
|
||||
&& cd /src && git checkout -q "$CFSOLVE_COMMIT"
|
||||
WORKDIR /src
|
||||
RUN cargo build --release --locked --bin challenge
|
||||
|
||||
FROM ${PYTHON_IMAGE} AS runtime
|
||||
ENV PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
HOME=/app \
|
||||
PATH=/app/.venv/bin:/usr/local/bin:/usr/bin:/bin \
|
||||
MCP_LIVE_ROUTE=proxy \
|
||||
MCP_SOLVER=off \
|
||||
MCP_SOLVER=/opt/cfsolve/challenge \
|
||||
MCP_SOLVER_PROFILE=/opt/cfsolve/profiles/safari-26-ios.json \
|
||||
MCP_CLEARANCE_FILE=/data/.clearance.json \
|
||||
MCP_REPORT_FILE=/data/.reports.jsonl
|
||||
RUN mkdir -p /data && chown 10001:10001 /data
|
||||
WORKDIR /app
|
||||
COPY --from=deps --chown=10001:10001 /app/.venv /app/.venv
|
||||
COPY --from=solver --chown=10001:10001 /src/target/release/challenge /opt/cfsolve/challenge
|
||||
COPY --from=solver --chown=10001:10001 /src/profiles/safari-26-ios.json /opt/cfsolve/profiles/
|
||||
COPY --from=solver --chown=10001:10001 /src/profiles/safari-26-ios /opt/cfsolve/profiles/safari-26-ios
|
||||
COPY --chown=10001:10001 server.py transport.py proxy.py identity.py solve.py clearance.py reports.py \
|
||||
html_reader.py json_reader.py ./
|
||||
USER 10001:10001
|
||||
|
||||
@@ -54,7 +54,7 @@ The ladder is automatic, and `solved` tells you which rung answered.
|
||||
3. **Solver** — a detected challenge page is handed to an external request-based solver ([cfsolve](https://github.com/chris124567/cfsolve)), which runs through the same proxy, up to three exits. The clearance is then replayed and cached.
|
||||
4. **Widget** — a page carrying a Turnstile sitekey gets a solved `cf_turnstile_response` in `turnstile` (disable with `MCP_SOLVE_TURNSTILE=0`).
|
||||
|
||||
Without a solver the server still fetches and reports the challenge. The default command expects cfsolve built in WSL at `~/cfsolve`; override the prefix with `MCP_SOLVER` (JSON array) or disable with `MCP_SOLVER=off`. `MCP_SOLVER_PROFILE` holds the solver's fingerprint file, whose User-Agent identity is reused for replay.
|
||||
Without a solver the server still fetches and reports the challenge. On the host the default command is cfsolve built in WSL at `~/cfsolve`; in the image it is `/opt/cfsolve/challenge`. Override the prefix with `MCP_SOLVER` (JSON array) or disable with `MCP_SOLVER=off`. `MCP_SOLVER_PROFILE` holds the solver's fingerprint file, whose User-Agent identity is reused for replay.
|
||||
|
||||
## Reports
|
||||
|
||||
@@ -82,6 +82,6 @@ docker run -d --name fetch-mcp -v fetch-mcp-data:/data \
|
||||
git.eeee.moe/omar/fetch-mcp:latest
|
||||
```
|
||||
|
||||
The image runs as UID 10001, writes clearance and reports under `/data`, and defaults to `MCP_SOLVER=off` because the WSL command does not exist in a container. Set `MCP_SOLVER` to a Linux solver path to enable that rung.
|
||||
The image runs as UID 10001 and writes clearance and reports under `/data`. The request-based solver is built in at `/opt/cfsolve/challenge` with its Safari-iOS profile, so the clearance rung works without WSL and without a browser; `MCP_SOLVER=off` disables it, and `MCP_SOLVER_PROFILE` points at another profile. The solver is pinned by commit in the image (`CFSOLVE_COMMIT`), and CI checks its `--help` offline.
|
||||
|
||||
`ci/Dockerfile` is the runner-side image (uv, git, node, docker CLI); it is built by the operator, not by CI.
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" ?>
|
||||
<coverage version="7.17.5" timestamp="1795883363267" lines-valid="1332" lines-covered="1207" line-rate="0.9062" branches-valid="388" branches-covered="325" branch-rate="0.8376" complexity="0">
|
||||
<coverage version="7.17.5" timestamp="1795926405893" lines-valid="1332" lines-covered="1207" line-rate="0.9062" branches-valid="388" branches-covered="325" branch-rate="0.8376" complexity="0">
|
||||
<!-- Generated by coverage.py: https://coverage.readthedocs.io/en/7.17.5 -->
|
||||
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
|
||||
<sources>
|
||||
|
||||
Reference in new issue
Block a user