Skip to content

feat(singbox)!: remove the sing-box server core from the node (feature 004) - #14

Merged
Free-Guy-IR merged 11 commits into
mainfrom
feat/004-remove-singbox
Dec 2, 2026
Merged

Free-Guy-IR merged 11 commits into
mainfrom
feat/004-remove-singbox

Conversation

@Free-Guy-IR

@Free-Guy-IR Free-Guy-IR commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

Feature 004, track A, node part: the sing-box server core leaves the node, on the owner's order of 2026-12-01 («کامل بردارش»). Everything removed is fork-only; upstream PasarGuard/node (main 739eab9, dev d536e6b) has no backend/singbox and no SING_BOX.

commit what
38e2e83d RED: over gRPC, a Start of BackendType 2 must fail with invalid backend type, an AddBackend of 2 with InvalidArgument, a RemoveBackend of 2 with NotFound, and the same node must then start Xray and stop advertising sing_box
33fc15f8 RED: over REST, POST /backend of 2 must be 400, DELETE /backend of 2 404, and the Xray primary keeps running
e9b21c21 backend/singbox (36 files, 8,675 lines), its registration, sing_box in supported_backends, SINGBOX_EXECUTABLE_PATH, and the controller and REST tests that needed a sing-box binary
bfc492f2 backend/openvpn: comment sentences that pointed at backend/singbox deleted, no word added, code unchanged
837d9d04 Dockerfile singbox-builder stage and its COPY, Makefile targets, singbox_http2_guard.sh and its test, the two sing-box CI steps, the race step's sing-box path, workflow_gates.lock (test job only), toolchain-floor and govulncheck-gate fixtures
26d9893b proto: SING_BOX = 2 removed, reserved 2; and reserved "SING_BOX"; added, bindings regenerated with the same protoc and protoc-gen-go, a wire test pins the reservation
9f394dab drift: sing-box and sing-quic components removed, 43 waiver rows removed (40 sing-box and 2 sing-quic commit ids, each checked with git cat-file against a commit-only fetch of both repositories, plus GHSA-r5hm-mp3j-285g), MTProto rows reworded, parity doc updated
ecfb6b29 NodeVersion 0.6.27 to 0.6.28, because supported_backends changes (same step as the MTProto removal, 641d19c)

RED on 74c660de: the gRPC test fails with fork/exec /usr/local/bin/sing-box: no such file or directory, the REST test with the client's 10 s timeout, and the wire test with BackendType 2 has a value again: SING_BOX. All three pass on this head.

Local runs on this head (macOS, Go 1.27.4): go vet for linux/amd64 clean; controller, controller/rest, controller/rpc/..., common, config, backend and backend/openvpn pass (two openvpn tests need a short TMPDIR on macOS, the same on 74c660de); test_toolchain_floor.sh 299 cases 0 failed; toolchain_floor.sh 12 pins; test_govulncheck_gate.sh 87 passed; workflow_policy.sh, test_workflow_policy.sh, test_workflow_steps.sh (238), test_image_tag_policy.sh and the workflowgate tests pass; upstream_drift_bypass_test.sh 21 of 21; the changed cases of upstream_drift_test.sh pass, and the whole suite is left to this PR's CI.

Open points for the owner and the main session:

  • Upstream dev gives BackendType 2 to MTPROTO (feat(mtproto): add an MTProto backend driven by telemt PasarGuard/node#120, in no release yet). Reserving 2 means a later port of upstream's MTProto must drop the reservation on purpose.
  • Proxy.hysteria2 = 7 and Proxy.tuic = 10 now have no consumer on the node; they stay on the wire because the panel and the bridge still fill them.
  • The image is built by branch ci-004-remove-singbox at the same commit (run 46754081563, image-branch.yml, all test jobs and the drift job green first), tag ghcr.io/free-guy-ir/node:ci-004-remove-singbox. That branch and tag exist only for this build and can be deleted after review.

Image size, compressed layers as pulled from GHCR (v0.8.27 has the same Dockerfile, go.mod and patches as 74c660de):

platform v0.8.27 ci-004-remove-singbox change
linux/amd64 78,008,168 bytes, 11 layers 65,338,168 bytes, 10 layers -12,670,000 (-16.2%)
linux/arm64 75,173,499 bytes, 11 layers 63,712,333 bytes, 10 layers -11,461,166 (-15.2%)

The COPY /out/sing-box layer (12,601,681 and 11,397,170 bytes) is gone, and the /app/main layer is 68,344 and 64,016 bytes smaller. A local cross-build of ./cmd/node with the builder stage's command gives 33,624,188 to 33,448,060 bytes on amd64 and 31,326,332 to 31,129,724 on arm64.

CI on ecfb6b29: Test Modules 46751969924, Upstream Drift 46751969987 (0 unported items across [node xray]) and the image run 46754081563 are all green.

… refused and the node keeps serving

The owner ordered the sing-box server core removed («کامل بردارش»,
2026-12-01). Once it is gone, a panel that still sends BackendType 2 must
get a clear refusal from the node, and the node must go on serving.

The test drives a fresh in-process node over gRPC the way a panel does:
a Start of type 2 with a sing-box config and a user carrying every
credential must fail with "invalid backend type" (upstream's message for
an unknown type); an AddBackend of type 2 must fail with InvalidArgument
with and without a running primary; a RemoveBackend of type 2 must report
NotFound; and the same node must then start Xray, report started, list
Xray alone and stop advertising sing_box.

RED on 74c660d: the node still builds type 2 as sing-box and fails with
"fork/exec /usr/local/bin/sing-box: no such file or directory".
…and the primary keeps running

The REST counterpart of the gRPC refusal test, on the package's shared
node with its Xray primary: POST /backend of type 2 must answer 400 Bad
Request, DELETE /backend of type 2 must answer 404 Not Found, and the node
must still list Xray alone and serve GET /stats afterwards.

It replaces the REST coverage of the two sing-box tests that go with the
backend. Read from the code and from run-tests.yml, not reproduced: no
remaining extra backend can be attached by the unprivileged CI race run.
WireGuard creates its link through netlink, OpenVPN renders "dev tunN" and
needs an openvpn binary the job does not install, and L2TP's CheckDeps
wants xl2tpd, pppd, /dev/ppp and strongSwan. So the /backend routes are
held on their refusal paths instead.

RED on 74c660d: the node builds type 2 as sing-box, and POST /backend
does not answer within the client's 10 s timeout ("context deadline
exceeded (Client.Timeout exceeded while awaiting headers)").
The owner had the sing-box server core removed («کامل بردارش»,
2026-12-01). It is fork-only: upstream PasarGuard/node has no
backend/singbox. On the production panel its only core (9) drives three
disabled nodes, which the panel track deletes before rollout.

- backend/singbox goes entirely (36 files, 8,675 lines), with its registration in
  buildBackend, "sing_box" in supported_backends, its entry in
  multiInstanceBackends, and config.SingBoxExecutablePath with its
  SINGBOX_EXECUTABLE_PATH variable.
- The four controller tests that exercised sing-box's own API and loopback
  guards and its counter carrying go with it. The Xray counter-carrying
  tests (backend_replacement_counters_test.go) stay as they are.
- The multi-backend unit tests that used SING_BOX as a fake type take
  WIREGUARD, OPEN_VPN or XRAY; every assertion is unchanged.
- The two REST tests that attached a real sing-box extra go, and the
  refusal test of the previous commit holds the /backend routes instead.
- The README fork note and the port warning stop naming sing-box;
  .gitignore drops the sing-box-src build directory.

A Start of type 2 now falls to buildBackend's default and is refused with
upstream's "invalid backend type"; an AddBackend of type 2 is refused as
not shareable. Both RED tests of the previous commits pass.
…ing-box backend

backend/openvpn never depended on sing-box; its comments only compared it
with backend/singbox, which is gone. The sentences and clauses that name
it are deleted and nothing is reworded: no comment gains a word, and the
code is unchanged.
- Dockerfile: the singbox-builder stage and its COPY into the final image
  go; the xray-builder comment loses its pointer to that stage.
- Makefile: build_singbox, test_singbox_http2_guard and the SINGBOX_*
  variables go; scripts/singbox_http2_guard.sh and its test go.
- run-tests.yml: the steps that built the pinned sing-box and ran the live
  sing-box tests go, and the controller race run no longer sets
  SINGBOX_EXECUTABLE_PATH. workflow_gates.lock carries the new fingerprint
  of the test job, regenerated with workflowgate fingerprint; no other job
  changed.
- scripts/test_workflow_policy.sh: the race-step mutations follow the
  one-line controller run, and the sing-box path mutation becomes
  "controller dropped from the race run", the twin of the backend one.
- scripts/toolchain_floor.sh no longer allows a sing-box copy in the final
  stage. Its tests drop the singbox-builder stage from both fixtures and
  move the four cases that used it (GOFLAGS as ARG and as a RUN
  assignment, GOTOOLCHAIN=auto, go env -w GOTOOLCHAIN) and the
  missing-digest case to the builder stage. The final-copy flag case
  copies /app/main with --chmod. Every expected pin count is one lower,
  and every problem count that covered all the golang images too.
- scripts/test_govulncheck_gate.sh: the other-stage fixture applies its
  patch in a builder stage that fetches PasarGuard/node.

Local runs on this tree (macOS, bash 3.2): test_toolchain_floor.sh 299
cases, 0 failed (run in chunks); toolchain_floor.sh 12 pins checked;
test_govulncheck_gate.sh 87 passed; workflow_policy.sh, test_workflow_policy.sh
(57 refusals), test_workflow_steps.sh (238), test_image_tag_policy.sh and
the workflowgate tests pass.
BackendType SING_BOX = 2 is fork-only: upstream main (v0.5.7, 739eab9)
has XRAY and WIREGUARD only. It goes, and "reserved 2;" and
"reserved \"SING_BOX\";" take its place next to the MTProto reservation,
so nothing reuses the number or the name. An older panel that still sends
2 is never misread as another backend: the node decodes it as the bare
enum number 2, and the controller refuses it as an invalid backend type.

Upstream dev (d536e6b) gives 2 to MTPROTO in PasarGuard#120, which no release
carries yet. With 2 reserved, taking that number later needs an explicit
decision to drop the reservation; the PR PasarGuard#61 and PasarGuard#120 waivers record the
collision.

The comment on message Hysteria2 that named sing-box is deleted. The
message and Proxy.hysteria2 = 7 stay on the wire unchanged.

common/service.pb.go is regenerated with protoc 36.2 (v7.36.2) and
protoc-gen-go v1.36.11, the versions in its header;
service_grpc.pb.go does not change. Regenerating the previous proto with
the same tools reproduced the committed files byte for byte.

common/reserved_wire_numbers_test.go expects the reserved names
[MTPROTO SING_BOX] and loses its SING_BOX = 2 check. A new test pins
that 2 has no value, that 2 and the name SING_BOX are reserved, and that
an older panel's Start of type 2 decodes as the bare number. RED on
74c660d: "BackendType 2 has a value again: SING_BOX".
…aivers

With the singbox-builder stage gone nothing pins sing-box or sing-quic,
so the drift check watches node and xray only.

- scripts/upstream_drift.sh: the sing-box and sing-quic sections leave
  the components (the default is now "node xray"), together with
  gomod_version and module_rev, which only the sing-quic pin read.
- .github/upstream-waivers.txt loses 43 rows: the 40 whose id is a
  SagerNet/sing-box commit, the 2 whose id is a SagerNet/sing-quic commit
  (each checked with git cat-file against a commit-only fetch of both
  repositories on 2026-12-02), and GHSA-r5hm-mp3j-285g, the sing-box SOCKS
  advisory. 114 rows remain.
- The 17 MTProto rows for upstream PR PasarGuard#61 and PasarGuard#120 no longer say the
  fork has SING_BOX = 2; they say BackendType 2 stays reserved by number
  and by name. Their category, branch: scope, "not merged", "dev-only"
  and until: tokens are untouched.
- The synthetic suites drop the sing-box fixture repository and the
  singbox-builder stage, and the two cases that only exercised the
  sing-box component (an xray patch naming a sing-box commit, a sing-box
  commit off its oldstable line). The CRLF case and the
  pin-in-another-stage case now hide or declare in the builder stage, and
  the bypass case that needed a trailer naming no xray commit passes a
  literal 40-hex id instead of a sing-box commit.
- docs/upstream-parity.md: the current-state sections (intro, other
  branches, third-party upstreams, pins, how a port is recognised, not
  covered, the drift check, running it locally) describe node and xray
  only, and a "Retired in feature 004" paragraph records the two
  components. The dated state sections are history and stay as written.

Local runs (macOS): upstream_drift_bypass_test.sh 21 of 21 passed; in
upstream_drift_test.sh the changed and neighbouring cases (clean,
xray-patch-applied, xray-patch-not-applied, xray-patch-other-stage,
xray-patch-shell-comment, xray-build-crlf-hides-the-builder-stage,
xray-dev-only-needs-no-waiver, xray-pin-declared-in-another-stage) pass.
The whole suite runs in CI (make test-drift).
NodeVersion goes 0.6.27 to 0.6.28, one patch step from the last value the
fork used (v0.8.27, 73fa6bd; no branch or tag on GitHub carries 0.6.28),
because BaseInfoResponse.supported_backends loses "sing_box" and a panel
reads that list to decide what a node can run. It is the same step the
MTProto removal took (641d19c). TestNodeVersionIsPinned and the three
upstream-waiver rows that cite the constant follow.
…ays out of the fork

The 17 waiver rows for upstream PR PasarGuard#61 and PasarGuard#120 explained their refusal only
by the wire collision on BackendType 2 and asked to revisit the backend if
upstream merged it. The owner ordered the Telegram proxy removed from the fork
on 2026-11-10 and confirmed on 2026-12-02 that it stays out, so the rows now
say so and the backend itself is never ported.

PasarGuard#120 stays pending under the release-only rule for the one generic piece it
carries, the retry-later sync error (backend/errors.go RetryLaterError,
HTTP 503 in controller/rest/sync_errors.go, gRPC Unavailable in
controller/rpc/sync_errors.go), which is ported or refused on its own once a
release contains it; its until: date moves from 2026-11-30 to 2026-12-31.
bfc492f cut the sentences about the removed sing-box backend out of the
openvpn comments, but it reflowed what was left and so wrote comment text of
its own ("This", "xray's"). The fork writes no comments, so the 19 comment
blocks that held a reworded line are removed whole instead: 122 comment lines
and one blank line left behind by the cut go, no line is added, and every other
removed line is a comment, so the code is unchanged (go vet and go build pass
for linux).
…rd#124 hold

docs/upstream-parity.md still said PR PasarGuard#61 was rejected only for its numbers
and asked to revisit it if upstream merged it. It now gives the owner's
decision that the Telegram proxy stays out of the fork, as the waiver rows
already do since 1f448d7, and points at PasarGuard#120's generic retry-later sync error,
which is ported or refused on its own once a release contains it.

Upstream PasarGuard#124 (9ccd263) is still in no release tag: the compare API shows it
ahead of v0.5.7, the newest tag, on 2026-12-02. Its pending hold had expired on
2026-11-30 and now runs until 2026-12-31 under the release-only rule.
@Free-Guy-IR
Free-Guy-IR force-pushed the feat/004-remove-singbox branch from fb238d9 to a145ce3 Compare December 1, 2026 23:35
@Free-Guy-IR
Free-Guy-IR merged commit 82c16f6 into main Dec 2, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant