Skip to content

feat(sip): add transport write filter - #381

Open
Michsantozz wants to merge 1 commit into
emiago:mainfrom
Michsantozz:write-filter
Open

Michsantozz wants to merge 1 commit into
emiago:mainfrom
Michsantozz:write-filter

Conversation

@Michsantozz

Copy link
Copy Markdown

What

WithTransportLayerWriteFilter(f TransportWriteFilter), the write-side counterpart of WithTransportLayerReadFilter.
The filter is called with each serialized message right before a UDP, TCP, TLS, WS or WSS connection writes it,
with TransportWriteProps{Transport, LocalAddr, RemoteAddr}, and can inspect, replace or drop it (an error drops the
message and is returned by WriteMsg).

Why

The read filter plus OnMessage let an application see what arrives, but nothing exposes what is sent: transactions
and dialogs call Connection.WriteMsg directly, so the only option today is SIPDebug and the global logger. With
both filters an application can keep a per-call SIP trace (both directions, after TLS) without touching every call site.

Notes

  • Plumbed exactly like readFilter: transport layer -> transports -> connections, set when a connection is created.
  • For UDP the remote address passed is the resolved destination; for TCP/TLS/WS/WSS the connection's addresses.
  • data is the pooled buffer: the doc comment says not to retain it.
  • Tests: UDP through the transport layer, TCP over net.Pipe, and an error dropping the message. go test ./... passes.

Mirror of WithTransportLayerReadFilter for the write side: the filter is
called with every serialized message right before UDP, TCP, TLS, WS or
WSS connections write it, and can inspect, replace or drop it. Together
with the read filter it allows tracing SIP in both directions without
SIPDebug and the global logger.

Co-Authored-By: Claude <noreply@anthropic.com>
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