Skip to content

fix(cli): keep --allow / profile network rules working under --proxy-user#97

Merged
tito merged 1 commit into
mainfrom
feat/check-if-allow-still-8yn
May 22, 2026
Merged

fix(cli): keep --allow / profile network rules working under --proxy-user#97
tito merged 1 commit into
mainfrom
feat/check-if-allow-still-8yn

Conversation

@tito

@tito tito commented May 22, 2026

Copy link
Copy Markdown
Contributor

Fixes #96.

Problem

greyproxy associates a live proxy connection with its session — and therefore enforces that session's network rules, including --allow and profile network.rules — by matching the SOCKS5 login against the session container_name (docs/templates.md:88,100; the --proxy-user help at main.go:132 calls this "match per-client rules by login"). The random sessionID is never sent over the proxy connection, so the login is the only identifier tying the connection to its rules.

These two values were derived independently in runCommand:

value old derivation
SOCKS5 login (proxyUser) proxyUserFlag ?? cmdName ?? "proxy"
session container_name cmdName ?? "sandbox"

They matched for an ordinary greywall -- curl … run, but diverged when:

In those cases the --allow/profile rules were registered under a container name that no live connection ever authenticated as, so greyproxy never applied them and the traffic was blocked despite the explicit allow.

Fix

Introduce a single proxyIdentity(proxyUserFlag, cmdName) helper and derive both the proxy-URL login and the RegisterSession container_name from it, so they can never diverge.

Test

TestProxyIdentity (cmd/greywall/main_test.go) pins the precedence; the --proxy-user case (proxyIdentity("agent1","curl") == "agent1") is the regression guard — the old container-name derivation would have produced "curl".

Verification

  • go test ./cmd/greywall/
  • make lint → 0 issues ✅
  • go build ./...

greyproxy associates a proxied connection with its session — and thus
enforces that session's network rules, including --allow — by matching
the SOCKS5 login against the session container_name. These were derived
independently: the login was proxyUserFlag || cmdName || "proxy", while
the container name was cmdName || "sandbox". With --proxy-user set (or an
empty cmdName) the two diverged, so --allow and profile network rules were
silently registered under a container no live connection ever logged in as.

Derive both from a single proxyIdentity helper so they can never diverge,
and add a regression test pinning the --proxy-user case.
@tito tito merged commit 6a95565 into main May 22, 2026
4 checks passed
@tito tito deleted the feat/check-if-allow-still-8yn branch May 22, 2026 22:32
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.

--allow / profile network rules silently ignored when --proxy-user is set (container_name != SOCKS5 login)

1 participant