Skip to content

Commit

Permalink
gateway: ai authWebhook: send gatewayHost to auth webhook (#3320)
Browse files Browse the repository at this point in the history
* gateway: AIauthWebhook: send additional node info to webhook

* use gateway host

* remove region from livepeernode

* descriptive cfg

* formatting

* Improve new flag description

* remove todo comment

---------

Co-authored-by: Thom Shutt <[email protected]>
  • Loading branch information
gioelecerati and thomshutt authored Dec 17, 2024
1 parent 7fe7949 commit a842a0d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/livepeer/livepeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ func parseLivepeerConfig() starter.LivepeerConfig {
cfg.IgnoreMaxPriceIfNeeded = flag.Bool("ignoreMaxPriceIfNeeded", *cfg.IgnoreMaxPriceIfNeeded, "Set to true to allow exceeding max price condition if there is no O that meets this requirement")
cfg.MinPerfScore = flag.Float64("minPerfScore", *cfg.MinPerfScore, "The minimum orchestrator's performance score a broadcaster is willing to accept")
cfg.DiscoveryTimeout = flag.Duration("discoveryTimeout", *cfg.DiscoveryTimeout, "Time to wait for orchestrators to return info to be included in transcoding sessions for manifest (default = 500ms)")
cfg.GatewayHost = flag.String("gatewayHost", *cfg.GatewayHost, "External hostname on which the Gateway node is running. Used when telling external services how to reach the node.")

// Transcoding:
cfg.Orchestrator = flag.Bool("orchestrator", *cfg.Orchestrator, "Set to true to be an orchestrator")
Expand Down
7 changes: 7 additions & 0 deletions cmd/livepeer/starter/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ type LivepeerConfig struct {
Netint *string
HevcDecoding *bool
TestTranscoder *bool
GatewayHost *string
EthAcctAddr *string
EthPassword *string
EthKeystorePath *string
Expand Down Expand Up @@ -215,6 +216,7 @@ func DefaultLivepeerConfig() LivepeerConfig {
defaultAIRunnerImage := "livepeer/ai-runner:latest"
defaultLiveAIAuthWebhookURL := ""
defaultLivePaymentInterval := 5 * time.Second
defaultGatewayHost := ""

// Onchain:
defaultEthAcctAddr := ""
Expand Down Expand Up @@ -323,6 +325,7 @@ func DefaultLivepeerConfig() LivepeerConfig {
AIRunnerImage: &defaultAIRunnerImage,
LiveAIAuthWebhookURL: &defaultLiveAIAuthWebhookURL,
LivePaymentInterval: &defaultLivePaymentInterval,
GatewayHost: &defaultGatewayHost,

// Onchain:
EthAcctAddr: &defaultEthAcctAddr,
Expand Down Expand Up @@ -1414,6 +1417,10 @@ func StartLivepeer(ctx context.Context, cfg LivepeerConfig) {
*cfg.HttpAddr = defaultAddr(*cfg.HttpAddr, "127.0.0.1", BroadcasterRpcPort)
*cfg.CliAddr = defaultAddr(*cfg.CliAddr, "127.0.0.1", BroadcasterCliPort)

if *cfg.GatewayHost != "" {
n.GatewayHost = *cfg.GatewayHost
}

bcast := core.NewBroadcaster(n)
orchBlacklist := parseOrchBlacklist(cfg.OrchBlacklist)
if *cfg.OrchPerfStatsURL != "" && *cfg.Region != "" {
Expand Down
3 changes: 3 additions & 0 deletions core/livepeernode.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ type LivepeerNode struct {
LiveAITrickleHostForRunner string
LiveAIAuthApiKey string
LivePaymentInterval time.Duration

// Gateway
GatewayHost string
}

type LivePipeline struct {
Expand Down
1 change: 1 addition & 0 deletions server/ai_mediaserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ func (ls *LivepeerServer) StartLiveVideo() http.Handler {
Stream: streamName,
Type: sourceTypeStr,
QueryParams: queryParams,
GatewayHost: ls.LivepeerNode.GatewayHost,
})
if err != nil {
kickErr := mediaMTXClient.KickInputConnection(ctx)
Expand Down
3 changes: 3 additions & 0 deletions server/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ type AIAuthRequest struct {
// Query parameters that came with the stream, if any
QueryParams string `json:"query_params,omitempty"`

// Gateway host
GatewayHost string `json:"gateway_host"`

// TODO not sure what params we need yet
}

Expand Down

0 comments on commit a842a0d

Please sign in to comment.