Skip to content

feat(proxy): add http_router caller override; invalid URI fails the call - #272

Merged
yeoleobun merged 1 commit into
restsend:mainfrom
ftong2010:http-route-caller-rewrite
Sep 3, 2026
Merged

feat(proxy): add http_router caller override; invalid URI fails the call#272
yeoleobun merged 1 commit into
restsend:mainfrom
ftong2010:http-route-caller-rewrite

Conversation

@ftong2010

Copy link
Copy Markdown

What

Adds a route-level caller override to the HTTP dynamic router (http_router) forward decision: a new optional caller field in the response payload rewrites the From URI of the callee leg.

Accepted forms:

value resulting From URI
sip:88888888@pbx.example.com used as-is
88888888@pbx.example.com sip:88888888@pbx.example.com
88888888 sip:88888888@<caller realm>
  • Omitted / empty → authenticated caller is kept (unchanged behavior).
  • Unparseable value → the call fails immediately with 500 Server Internal Error (fail-fast via RouteError); 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.host via RewriteRules, 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 verbatim
  • test_http_router_forward_caller_rewrite_bare_user — bare user qualified with the caller's realm
  • test_http_router_forward_caller_rewrite_invalid_fails_call — unparseable URI → RouteError with a SIP error status

All proxy_routing tests pass (82/82).

Docs

docs/config/04-routing.md response-field table updated with the new caller field and its failure semantics.

Validation

Verified end-to-end in a Docker benchmark (rustpbx → asterisk at 50 cps):

  • valid override 88888888: 3000/3000 INVITEs arriving at asterisk carried From: <sip:88888888@...> (0 with the original caller identity)
  • invalid override (...:99999, port overflow): 1500/1500 calls rejected immediately with 500, zero INVITEs left rustpbx

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
ftong2010 force-pushed the http-route-caller-rewrite branch from b8a3802 to f86b2f6 Compare September 3, 2026 04:59
@yeoleobun
yeoleobun merged commit 17d19fb into restsend:main Sep 3, 2026
3 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.

2 participants