* feat(secure-input): add a data packet receive hook and sip method stubs
* refactor(secure-input): bump protocol for sensitivity class names
* fix(secure-input): normalize data packets before caching them for joiners
* refactor(sensitive-input): rename secure input to sensitive input and bump protocol
* Replay missed disconnects on resume from the client's last pong time
A resuming client can send the timestamp of the last Pong it processed.
The server replays the participant disconnects newer than the earlier of
that time minus 1 s and the last signal receive time minus 3 s. Requests
buffered by an offline client move the last signal receive time to just
before the resume, the last Pong time does not move.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Take the test pong time from the cached disconnect time
The simulated pong time came from time.Now(), so a pause of more than
1 s after the disconnect was cached moved the disconnect out of the
look back.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Exercise the pong look back in the replay test
A pong time equal to the disconnect time is replayed without the 1 s
look back too. Use a pong time 500 ms after the disconnect.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
* Enable ice-lite for migration session
In the client's ICE restart, a full agent's checks
can reach libwebrtc before it applies our answer;
it then prunes the resulting peer reflexive pair
behind the still writable pair to the previous node,
keeps that pair and sends the DTLS handshake to the previous node.
* service: answer StopEgress for an ended egress without waiting
A stop for an egress that already ended finds no server subscribed to its
topic. On NATS psrpc reports that at once, but its retry interceptor then
waits out the request timeout before each retry, so the API answered 412
only after about 8 s.
StopEgress now sends the stop without psrpc's no-subscriber retry and asks
the IO service for the egress instead. An ended egress gets 412 and an
unknown one 404 at once. A starting or active egress that nothing is
subscribed for yet is retried every second for up to 3 seconds.
DeleteIngress and UpdateIngress only log a failed RPC to the ingress, so
they send it without the no-subscriber retry too.
Bumps psrpc for middleware.WithoutNoSubscriberRetry.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uq3jhDWWfeXi18uQ1wMJv6
* deps: bump psrpc to claim queue rpcs on non-NATS buses
psrpc after v0.8.2 stopped claiming queue rpcs, so on the local and Redis
buses a queue rpc with no subscriber timed out instead of failing with
ErrNoResponse after the selection timeout. That broke
TestJobTerminateReleasesJob. The new pseudo-version claims queue rpcs again
on buses that do not report unsubscribed requests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uq3jhDWWfeXi18uQ1wMJv6
* service: retry an active ingress the way StopEgress retries a live egress
UpdateIngress and DeleteIngress send their RPC only when the stored state
says the ingress is buffering or publishing. When no ingress is subscribed,
they now reload the ingress and retry every second for up to 3 seconds
while it is still active, as StopEgress does for a live egress. A stale
state that is no longer active returns at once. The RPC error is still only
logged.
The retry timing is shared by egress and ingress, so it is renamed from
stopEgressRetry* to noSubscriberRetry*.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uq3jhDWWfeXi18uQ1wMJv6
* deps: pin psrpc to the merged livekit/psrpc#177
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uq3jhDWWfeXi18uQ1wMJv6
---------
Co-authored-by: Claude <noreply@anthropic.com>
* Let clients set a preferred ICE candidate protocol on join
The v1 JoinRequest ConnectionSettings.candidate_protocol and the v0
candidate_protocol query parameter let a client ask for TCP or TLS
from the start. The SFU applies the stronger of the client preference
and the learned room fallback, and keeps the join preference on resume.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Require the candidate protocol on every connect, check ICE/TCP
Resume uses the preference from the resume request, the same as join,
so the participant no longer stores the join value. TCP mode drops UDP
candidates, so a TCP preference applies only when ICE/TCP is enabled,
and TLS without TURN/TLS falls back to TCP only under the same check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Keep the client preference apart from the learned fallback
The room cache now holds only fallbacks the transport learned after a
failure. The participant stores the client preference from join, and
resume applies the stronger of it and the resume request before the
resume response, so the response carries the matching ForceRelay.
TLS mode lists only TLS relays, also from external TURN servers.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Let a resume preference replace the join preference
A resume that sends TCP or TLS uses that value, and only a resume
without a value inherits the preference from join.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Ignore an unsupported preference on resume
A resume preference for a transport the server does not offer no
longer replaces the join preference. Each preference is lowered to a
supported transport before the resume picks between them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* feat: add token revocation
* token revocation: match LiveKit Cloud API, make it optional
- add token_revocation config section (enabled: false by default, ttl)
- RemoveParticipant: cutoff defaults to now, revoke_token_ts must be within
60s and is stored with the validation leeway, revoke absent participants,
keep not found unless revoke_token_ts is given
- UpdateParticipant revokes older tokens on permission updates and the
participant gets a refreshed token
- share the RoomService logic with Cloud through RevokeTokenClient
- revocations merge to the later cutoff and expiry
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* token revocation: clean up expired revocations lazily
Drop the cleanup goroutine of LocalStore. Revocations are kept in a queue
ordered by expiry, and expired ones are removed from its front when
revoking or checking, at most once per minute.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* token revocation: request context for redis, own lock for LocalStore
- RedisStore revocation calls use the request context
- LocalStore revocations use their own lock instead of the store lock
- remove TestRTCValidateRoomlessTokenAfterRevocation, which passes without revocation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* token revocation: length checks before auth, test all auth chains
Check lengths before the admin permission check, as LiveKit Cloud does, and
test that the API, agent endpoint and WebTransport chains reject revoked tokens.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* token revocation: do not return store errors to clients
Log the error of a failed revocation lookup and respond with a fixed message,
as the store error may contain internal addresses.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: cnderrauber <zengjie9004@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
gotestfmt prints a group per test, so a failure is buried in a long log
with no summary. tparse prints build errors, failing test output and a
per-package summary table at the end.
Swap the go.mod tool directive and keep stderr out of the pipe: tparse
rejects the whole stream if a non-JSON line follows the first JSON event.
Claude-Session: https://claude.ai/code/session_01S1stDkLA73F1pW3QWkhNVT
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* sfu: tighten RTP stats restart detection and RTCP report handling
- A stream restart is a forward-moving run of rejected packets that
lasts 1 s with no accepted packet, not 5 rejected packets.
- Receiver reports with a wrong cycle count are aligned to the highest
sent sequence number and no longer dropped as runaway.
- No sender report is sent while publisher sender reports advance at
less than half or more than twice the clock rate.
- Fold repeated drop and logging blocks into helpers and remove
unreachable branches.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* sfu: use only the low 16 bits of the receiver report sequence number
Cycle correction could move a report before the start, underflow the
saved highest and block every later report. Map the report to the
latest matching sequence number at or before the highest sent, and
drop the misalignment bookkeeping.
A publisher sender report time stamp that does not advance is now
treated as an off clock rate, not as unmeasured.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* sfu: bound the receiver report distance and key the unchanged check on the accepted report
A report ahead of the highest sent mapped into the previous cycle once
the stream was longer than one cycle. A report must now be within half
a cycle behind the highest sent.
A repeated stale report matched the last received report, not the last
accepted one, and replaced newer loss and jitter values.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Bump mediatransportutil for the OWD estimator fix
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* sfu: log the source stream generation in packetMeta
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* rtpstats: address review comments from Jules
Addresses only the comments from Jules (jtestard) on #5220.
Restart detection
- a reordered or duplicate packet of a run does not reset the run
- padding moves a run forward in sequence number and does not count
- only a packet with payload ends a run, a skipped sequence number does not
- comments on false positives and on the minimum run duration
Publisher clock rate
- measure only across publisher reports at least 1 s apart
- an older publisher report starts a new measurement
- comment on why Seed does not copy the measurement
- drop the reportTime log field, it repeats the report time
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* rtpstats: test publisher clock rate across sources with different timestamp bases
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* rtpstats: address review comments from Anunay
Addresses the comments from Anunay (anunaym14) on #5220.
- skip a sender report only when the publisher rate is low, a pair of
publisher reports across an unmute reads high and the report is correct
- comment on why a declared restart run is final
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* rtpstats: comment on why a high publisher clock rate is not skipped
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
* agent dispatch: carry thread_id from dispatches to jobs
* agent dispatch: validate thread_id as an AT_ agent thread id on the API
* agent dispatch: validate thread_id with protocol agent.ValidateThreadID
* agent dispatch: report an invalid thread_id as a Twirp InvalidArgument on thread_id
* protocol update for no agent permission update
* test: expect 401 on TURN auth failure
pion/turn v5.1.3 answers a failed authenticated allocate with 401 Unauthorized instead of 400 Bad Request.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* agent: stamp the accept and assignment times of a job attempt
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* deps: pin protocol with the job accept and assignment times
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* service: stamp a new user's join request time as an attribute
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* service: use the lk.rtc.joinRequestTime name
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* deps: pin protocol with the join request time attribute
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* deps: pin protocol main, keep turn and srtp on pion/transport v4
The warp forks of webrtc, dtls and ice are still on pion/transport v4.
Protocol main requires turn 5.1 and srtp 3.1, which moved to v5.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* deps: pin protocol v1.53.2
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test: expect the join request time among a participant's attributes
The server now stamps lk.rtc.joinRequestTime on a new standard participant, so
other participants see it beside the token's attributes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* deps: bump mediatransportutil to the transport-v4 tip
Picks up configurable external-IP discovery: external_ip_retries,
external_ip_retry_interval, external_ip_stun_timeout and
external_ip_validation_timeout on RTCConfig, plus the WithStunPingTimeout and
WithValidationTimeout options. Defaults unchanged, no code change here.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* deps: move mediatransportutil pin to include the NAT mapping fix
Advances the transport-v4 pin to the tip that also carries the per-interface
NAT mapping timeout fix, so the configurable external-IP timeouts apply to both
the boot-time and mapping discovery phases.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* sfu: ignore a nil publisher sender report in the forwarder
A stream restart replaces the receiver stats between the sender report
callback and its read, so the report can be nil. SetRefSenderReport now
keeps the previous report instead of reading the nil one.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* dynacast: skip a codec regression when the target codec has no quality
HandleCodecRegression looked up the target codec after it released the
lock. If the manager closed in between, or the target mime type was
unknown, the lookup returned nil and RegressTo called Restart or Replace on
it. The target is now looked up with the source, and a missing one stops
the regression.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* service: create the internal record for a stored room that has none
RedisStore.LoadRoom returns a nil RoomInternal without an error when the
room exists but its internal field does not, for example after a delete
races a store. CreateRoom then wrote egress, agent, playout delay or sync
settings into the nil record. It now starts from an empty record, which
the store call writes back.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* sfu: drop a dependency descriptor whose chains do not match the structure
The parser takes a new structure from any packet, but DDForwarder keeps
the structure of the last packet it forwarded. When the publisher attached
a structure with fewer chains to a packet this downtrack dropped, the next
descriptor had fewer chain diffs than the forwarder's structure, and the
writer indexed past them. The forwarder now drops such a packet, and the
writer returns an error instead of indexing past the chain diffs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* deps: bump mediatransportutil for the empty VP9 payload fix
A VP9 packet without a dependency descriptor and with a 1-byte payload such
as 0x08 parses to an empty VP9 payload, and IsVP9KeyFrame read its first
byte. mediatransportutil#106 returns false for an empty payload. This pins
the transport-v4 commit that carries it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* sfu: keep the template test comment with its test
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* dynacast: create the target quality only for a valid regression
A target quality starts a timer that notifies the publisher. Look it up
only after the source codec is found, so a rejected regression creates
nothing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* service: restore the internal defaults for a room that lost them
A stored room without an internal record now gets the configured playout
delay and sync streams defaults. Its own settings, such as the empty
timeout and codecs, stay as stored.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Pins the transport-v4 branch of mediatransportutil at 03518fb, which
adds mediatransportutil#103 on top of #101.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* service: send queued webhooks before shutdown completes
Start returned, and the process exited, while the room_finished webhooks
of the rooms closed by the shutdown were still queued. Stop the telemetry
service at the end of Start so it flushes its queue and drains the webhook
notifier, waiting up to 5s.
* Bump protocol to pick up the ResourceURLNotifier drain fix
ResourceURLNotifier.Stop(false) now waits for the queued events to be sent (livekit/protocol#1901), which the shutdown change relies on.
* telemetry: keep the analytics of webhooks sent during stop
The notifier's processed hook queues a WEBHOOK analytics event for each webhook it sends, but Stop stopped the jobs queue before draining the notifier, so those events were dropped. Run the queued events with a barrier, drain the notifier, then stop the queue.
* Pass CPU stats options through prometheus.Init
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Add node_stats.host_cpu config to measure whole-host CPU
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Bump protocol to ignore the CPU request with host CPU stats
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Pins the transport-v4 branch of mediatransportutil (dd8e31a plus
mediatransportutil#101), because master moved to pion/transport/v5,
which the warp forks of ice, webrtc and dtls do not support yet.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* sfu: replace forward scheduling delay with processing per subscriber
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* sfu: describe processing per subscriber as per write
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* telemetry: name forward processing metrics per write
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Pin protocol with NodeStats forward_processing_per_write
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* sfu: report forward scheduling delay next to forwarding latency
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* sfu: keep full forwarding transit when packing scheduling delay
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* sfu: saturate reported forwarding p90s instead of wrapping
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Thread the issuing API key from the /rtc join path to the media node via
StartSession, and include it in the "starting RTC session" log and the
twirp API-request log, so participant activity can be correlated with the
key. Logs the key id only, never the secret.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Pick up protocol#1879 (round-trip 7s, default response 15s) so a
server-initiated PerformRpc tolerates the same ack and response windows
as the client SDK caller.
Also log an RPC response the v1 caller cannot decode (compressed_payload
or data-stream) instead of dropping it, which otherwise surfaces only as
a response timeout.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>