Skip to content

Commit

Permalink
Use redacting function from protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
biglittlebigben committed May 9, 2024
1 parent 40832fa commit 0327871
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 75 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/gorilla/websocket v1.5.1
github.com/livekit/livekit-server v1.6.0
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1
github.com/livekit/protocol v1.12.1-0.20240425173505-6d5a8047e6d8
github.com/livekit/protocol v1.15.1-0.20240509222622-dd69a5f0110a
github.com/livekit/psrpc v0.5.3-0.20240403150641-811331b106d9
github.com/livekit/server-sdk-go/v2 v2.1.2-0.20240425022832-17b2be53a0d7
github.com/pion/rtp v1.8.6
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,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-20240406063423-a67d961689df h1:DVhJRlF6/CtiyxJVy3QsbS9bf7GyUMuRZONMwZxIWpY=
github.com/livekit/mediatransportutil v0.0.0-20240406063423-a67d961689df/go.mod h1:jwKUCmObuiEDH0iiuJHaGMXwRs3RjrB4G6qqgkr/5oE=
github.com/livekit/protocol v1.12.1-0.20240425173505-6d5a8047e6d8 h1:epjLFWYfOF0GLptPY0dsNGTDcEph3J4b3qGFiSLP6NI=
github.com/livekit/protocol v1.12.1-0.20240425173505-6d5a8047e6d8/go.mod h1:pnn0Dv+/0K0OFqKHX6J6SreYO1dZxl6tDuAZ1ns8L/w=
github.com/livekit/protocol v1.15.1-0.20240509222622-dd69a5f0110a h1:qlJfJOoHfD4y5Z8Ztr6nfHs2BGq8FvU6GRbBj5Gp+ts=
github.com/livekit/protocol v1.15.1-0.20240509222622-dd69a5f0110a/go.mod h1:pnn0Dv+/0K0OFqKHX6J6SreYO1dZxl6tDuAZ1ns8L/w=
github.com/livekit/psrpc v0.5.3-0.20240403150641-811331b106d9 h1:4CngtPIJ58WcQ1sUDGdxJDkTndQpN6M/T8jXvRAd7Oc=
github.com/livekit/psrpc v0.5.3-0.20240403150641-811331b106d9/go.mod h1:CQUBSPfYYAaevg1TNCc6/aYsa8DJH4jSRFdCeSZk5u0=
github.com/livekit/server-sdk-go/v2 v2.1.2-0.20240425022832-17b2be53a0d7 h1:iZJnxZ0ZHMbiiUKHR3mV2CBWR5quNWv1disk7H4Iw5A=
Expand Down
30 changes: 0 additions & 30 deletions pkg/config/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/livekit/egress/pkg/types"
"github.com/livekit/protocol/egress"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/utils"
)

type OutputConfig interface {
Expand Down Expand Up @@ -227,32 +226,3 @@ func (p *PipelineConfig) updateImageOutputs(images []*livekit.ImageOutput) error

return nil
}

func redactEncodedOutputs(out egress.EncodedOutput) {
if files := out.GetFileOutputs(); len(files) == 1 {
redactUpload(files[0])
}
if streams := out.GetStreamOutputs(); len(streams) == 1 {
redactStreamKeys(streams[0])
}
if segments := out.GetSegmentOutputs(); len(segments) == 1 {
redactUpload(segments[0])
}
if o, ok := out.(egress.EncodedOutputDeprecated); ok {
if file := o.GetFile(); file != nil {
redactUpload(file)
} else if stream := o.GetStream(); stream != nil {
redactStreamKeys(stream)
} else if segment := o.GetSegments(); segment != nil {
redactUpload(segment)
}
}
}

func redactStreamKeys(stream *livekit.StreamOutput) {
for i, url := range stream.Urls {
if redacted, ok := utils.RedactStreamKey(url); ok {
stream.Urls[i] = redacted
}
}
}
3 changes: 2 additions & 1 deletion pkg/config/output_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"time"

"github.com/livekit/egress/pkg/types"
"github.com/livekit/protocol/egress"
"github.com/livekit/protocol/livekit"
)

Expand Down Expand Up @@ -66,7 +67,7 @@ func (p *PipelineConfig) getDirectFileConfig(file *livekit.DirectFileOutput) (*F
type fileRequest interface {
GetFilepath() string
GetDisableManifest() bool
uploadRequest
egress.UploadRequest
}

func (p *PipelineConfig) getFileConfig(outputType types.OutputType, req fileRequest) (*FileConfig, error) {
Expand Down
12 changes: 5 additions & 7 deletions pkg/config/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (p *PipelineConfig) Update(request *rpc.StartEgressRequest) error {
p.Info.Request = &livekit.EgressInfo_RoomComposite{
RoomComposite: clone,
}
redactEncodedOutputs(clone)
egress.RedactEncodedOutputs(clone)

p.SourceType = types.SourceTypeWeb
p.AwaitStartSignal = true
Expand Down Expand Up @@ -240,7 +240,7 @@ func (p *PipelineConfig) Update(request *rpc.StartEgressRequest) error {
p.Info.Request = &livekit.EgressInfo_Web{
Web: clone,
}
redactEncodedOutputs(clone)
egress.RedactEncodedOutputs(clone)

connectionInfoRequired = false
p.SourceType = types.SourceTypeWeb
Expand Down Expand Up @@ -288,7 +288,7 @@ func (p *PipelineConfig) Update(request *rpc.StartEgressRequest) error {
p.Info.Request = &livekit.EgressInfo_Participant{
Participant: clone,
}
redactEncodedOutputs(clone)
egress.RedactEncodedOutputs(clone)

p.SourceType = types.SourceTypeSDK

Expand Down Expand Up @@ -324,7 +324,7 @@ func (p *PipelineConfig) Update(request *rpc.StartEgressRequest) error {
p.Info.Request = &livekit.EgressInfo_TrackComposite{
TrackComposite: clone,
}
redactEncodedOutputs(clone)
egress.RedactEncodedOutputs(clone)

p.SourceType = types.SourceTypeSDK

Expand Down Expand Up @@ -365,9 +365,7 @@ func (p *PipelineConfig) Update(request *rpc.StartEgressRequest) error {
p.Info.Request = &livekit.EgressInfo_Track{
Track: clone,
}
if f := clone.GetFile(); f != nil {
redactUpload(f)
}
egress.RedactDirectOutputs(clone)

p.SourceType = types.SourceTypeSDK

Expand Down
36 changes: 2 additions & 34 deletions pkg/config/uploads.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,12 @@ import (

"github.com/aws/aws-sdk-go/aws"

"github.com/livekit/protocol/egress"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/utils"
)

type UploadConfig interface{}

type uploadRequest interface {
GetS3() *livekit.S3Upload
GetGcp() *livekit.GCPUpload
GetAzure() *livekit.AzureBlobUpload
GetAliOSS() *livekit.AliOSSUpload
}

type EgressS3Upload struct {
*livekit.S3Upload
MaxRetries int
Expand All @@ -40,7 +33,7 @@ type EgressS3Upload struct {
AwsLogLevel aws.LogLevelType
}

func (p *PipelineConfig) getUploadConfig(req uploadRequest) UploadConfig {
func (p *PipelineConfig) getUploadConfig(req egress.UploadRequest) UploadConfig {
if s3 := req.GetS3(); s3 != nil {
s3Conf := &EgressS3Upload{
S3Upload: s3,
Expand Down Expand Up @@ -160,28 +153,3 @@ func (c StorageConfig) ToUploadConfig() UploadConfig {
}
return nil
}

func redactUpload(req uploadRequest) {
if s3 := req.GetS3(); s3 != nil {
s3.AccessKey = utils.Redact(s3.AccessKey, "{access_key}")
s3.Secret = utils.Redact(s3.Secret, "{secret}")
return
}

if gcp := req.GetGcp(); gcp != nil {
gcp.Credentials = utils.Redact(gcp.Credentials, "{credentials}")
return
}

if azure := req.GetAzure(); azure != nil {
azure.AccountName = utils.Redact(azure.AccountName, "{account_name}")
azure.AccountKey = utils.Redact(azure.AccountKey, "{account_key}")
return
}

if aliOSS := req.GetAliOSS(); aliOSS != nil {
aliOSS.AccessKey = utils.Redact(aliOSS.AccessKey, "{access_key}")
aliOSS.Secret = utils.Redact(aliOSS.Secret, "{secret}")
return
}
}

0 comments on commit 0327871

Please sign in to comment.