feat(proxy): add http_router caller override; invalid URI fails the call - #272
Merged
Merged
Conversation
Route-level caller rewrite for the callee leg (From header): accepts a full SIP URI, user@host, or bare user qualified with the caller's realm. Omitted keeps the authenticated caller; an unparseable value aborts routing with 500 Server Internal Error instead of falling back.
ftong2010
force-pushed
the
http-route-caller-rewrite
branch
from
September 3, 2026 04:59
b8a3802 to
f86b2f6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a route-level caller override to the HTTP dynamic router (
http_router)forwarddecision: a new optionalcallerfield in the response payload rewrites the From URI of the callee leg.Accepted forms:
sip:88888888@pbx.example.com88888888@pbx.example.comsip:88888888@pbx.example.com88888888sip:88888888@<caller realm>500 Server Internal Error(fail-fast viaRouteError); the routing decision is treated as invalid rather than silently falling back to the original caller.Why
Static route rules can already rewrite
from.user/from.hostviaRewriteRules, but the HTTP router had no equivalent — the callee-leg From was always the authenticated caller. This is a common need for trunk/wholesale routing scenarios where the routing service decides the presented caller ID per call.The fail-fast choice matters: a malformed override coming from the router is a router bug, and silently keeping the original caller would route the call with an unexpected (and possibly non-billable) identity.
Tests
test_http_router_forward_caller_rewrite_full_uri— full URI is used verbatimtest_http_router_forward_caller_rewrite_bare_user— bare user qualified with the caller's realmtest_http_router_forward_caller_rewrite_invalid_fails_call— unparseable URI →RouteErrorwith a SIP error statusAll
proxy_routingtests pass (82/82).Docs
docs/config/04-routing.mdresponse-field table updated with the newcallerfield and its failure semantics.Validation
Verified end-to-end in a Docker benchmark (rustpbx → asterisk at 50 cps):
88888888: 3000/3000 INVITEs arriving at asterisk carriedFrom: <sip:88888888@...>(0 with the original caller identity)...:99999, port overflow): 1500/1500 calls rejected immediately with 500, zero INVITEs left rustpbx