Skip to content

Commit

Permalink
Check stream key in WHIP DELETE call (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
biglittlebigben authored Jun 30, 2023
1 parent 6e5d29f commit 3a24338
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/livekit/go-rtmp v0.0.0-20230317185657-6e9cfa387c7e
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1
github.com/livekit/mediatransportutil v0.0.0-20230612070454-d5299b956135
github.com/livekit/protocol v1.5.8-0.20230629015034-5cff0336ab5e
github.com/livekit/protocol v1.5.9-0.20230630215251-8e67918879b2
github.com/livekit/psrpc v0.3.1
github.com/livekit/server-sdk-go v1.0.12-0.20230614223322-5fdaa0386d4a
github.com/pion/interceptor v0.1.17
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1 h1:jm09419p0lqTkD
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ=
github.com/livekit/mediatransportutil v0.0.0-20230612070454-d5299b956135 h1:lWYbsondvqG69czxoACDwaJ/BoyD57BahCo70ZH+m4U=
github.com/livekit/mediatransportutil v0.0.0-20230612070454-d5299b956135/go.mod h1:MRc0zSOSzXuFt0X218SgabzlaKevkvCckPgBEoHYc34=
github.com/livekit/protocol v1.5.8-0.20230629015034-5cff0336ab5e h1:DtTFuErvQGEydKgdgv8f39wlvdUpuob33EznKoKA8f4=
github.com/livekit/protocol v1.5.8-0.20230629015034-5cff0336ab5e/go.mod h1:B6hJiuXT84dHsUgaKHBo+ZLPX4XhklptYA2UbANSiNg=
github.com/livekit/protocol v1.5.9-0.20230630215251-8e67918879b2 h1:SVspXbSeIclQ5CvKcUmNe08hAfzpbfkl3kZtoVtMMi0=
github.com/livekit/protocol v1.5.9-0.20230630215251-8e67918879b2/go.mod h1:B6hJiuXT84dHsUgaKHBo+ZLPX4XhklptYA2UbANSiNg=
github.com/livekit/psrpc v0.3.1 h1:KfylgJHvoLQcc22t/oflwMOeSnx0c14G7cWsS+9MYS4=
github.com/livekit/psrpc v0.3.1/go.mod h1:n6JntEg+zT6Ji8InoyTpV7wusPNwGqqtxmHlkNhDN0U=
github.com/livekit/server-sdk-go v1.0.12-0.20230614223322-5fdaa0386d4a h1:hMCE2b1txjepy0tWv4rBfu+QHPuVUyTfgDmaO70AXwU=
Expand Down
2 changes: 1 addition & 1 deletion pkg/stats/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (m *Monitor) checkCPUConfig(costConfig config.CPUCostConfig) error {
)
}

logger.Infow(fmt.Sprintf("available CPU cores: %d max cost: %f", m.cpuStats.NumCPU(), m.maxCost))
logger.Infow(fmt.Sprintf("available CPU cores: %f max cost: %f", m.cpuStats.NumCPU(), m.maxCost))

return nil
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/whip/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,14 @@ func (s *WHIPServer) Start(
}()

vars := mux.Vars(r)
streamKey := vars["stream_key"]
resourceID := vars["resource_id"]

logger.Infow("handling WHIP delete request", "resourceID", resourceID)

req := &rpc.DeleteWHIPResourceRequest{
ResourceId: resourceID,
StreamKey: streamKey,
}

w.Header().Set("Access-Control-Allow-Origin", "*")
Expand Down
5 changes: 5 additions & 0 deletions pkg/whip/whip_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,11 @@ func (h *whipHandler) DeleteWHIPResource(ctx context.Context, req *rpc.DeleteWHI
_, span := tracer.Start(ctx, "whipHandler.DeleteWHIPResource")
defer span.End()

// only test for stream key correctness if it is part of the request for backward compatibility
if req.StreamKey != "" && h.params.StreamKey != req.StreamKey {
h.logger.Infow("received delete request with wrong stream key", "streamKey", req.StreamKey)
}

h.Close()

return &google_protobuf2.Empty{}, nil
Expand Down

0 comments on commit 3a24338

Please sign in to comment.