@@ -28,6 +28,9 @@ type Cli struct {
2828 Verbosity string
2929 ConfOutput string
3030 SQLOutput string
31+ Network string
32+ EthURL string
33+ Keystore string
3134}
3235
3336type DBObject map [string ]any
@@ -92,53 +95,14 @@ func GenerateConfig(cli *Cli) ([]byte, []byte, error) {
9295 privateBucket := ObjectStore (adminID , cli .PublicURL , privateBucketID , "os-vod" )
9396 inserts = append (inserts , recordingBucket , vodBucket , vodBucketCatalyst , privateBucket )
9497
98+ newProtocols := []* Protocol {}
9599 for _ , protocol := range conf .Config .Protocols {
96- if protocol .Connector == "livepeer-api" && ! protocol .StreamInfoService {
97- protocol .RecordCatalystObjectStoreID = recordingBucketID
98- protocol .VODCatalystObjectStoreID = vodBucketCatalystID
99- protocol .VODCatalystPrivateAssetsObjectStore = privateBucketID
100- protocol .VODObjectStoreID = vodBucketID
101- protocol .CORSJWTAllowlist = fmt .Sprintf (`["%s"]` , cli .PublicURL )
102- protocol .Ingest = fmt .Sprintf (
103- `[{"ingest":"rtmp://%s/live","ingests":{"rtmp":"rtmp://%s/live","srt":"srt://%s:8889"},"playback":"%s/mist/hls","base":"%s","origin":"%s"}]` ,
104- u .Hostname (),
105- u .Hostname (),
106- u .Hostname (),
107- cli .PublicURL ,
108- cli .PublicURL ,
109- cli .PublicURL ,
110- )
111- } else if protocol .Connector == "livepeer-catalyst-api" {
112- protocol .APIToken = cli .Secret
113- protocol .Tags = fmt .Sprintf ("node=media,http=%s/mist,https=%s/mist" , cli .PublicURL , cli .PublicURL )
114- } else if protocol .Connector == "livepeer-task-runner" {
115- protocol .CatalystSecret = cli .Secret
116- protocol .LivepeerAccessToken = cli .Secret
117- } else if protocol .Connector == "livepeer-analyzer" {
118- protocol .LivepeerAccessToken = cli .Secret
119- } else if protocol .Connector == "livepeer" && protocol .Broadcaster && protocol .MetadataQueueURI != "" {
120- protocol .
AuthWebhookURL = fmt .
Sprintf (
"http://%s:%[email protected] :3004/api/stream/hook" ,
adminID ,
cli .
Secret )
121- } else if protocol .Connector == "WebRTC" {
122- protocol .ICEServers = []ICEServer {
123- {
124- URLs : fmt .Sprintf ("stun:%s:3478" , u .Hostname ()),
125- },
126- {
127- Credential : "livepeer" ,
128- URLs : fmt .Sprintf ("turn:%s:3478" , u .Hostname ()),
129- Username : "livepeer" ,
130- },
131- {
132- URLs : fmt .Sprintf ("stun:%s:5349" , u .Hostname ()),
133- },
134- {
135- Credential : "livepeer" ,
136- URLs : fmt .Sprintf ("turn:%s:5349" , u .Hostname ()),
137- Username : "livepeer" ,
138- },
139- }
100+ ok := tweakProtocol (protocol , cli , u )
101+ if ok {
102+ newProtocols = append (newProtocols , protocol )
140103 }
141104 }
105+ conf .Config .Protocols = newProtocols
142106
143107 video := conf .Streams ["video" ]
144108 for _ , process := range video .Processes {
@@ -174,6 +138,56 @@ func GenerateConfig(cli *Cli) ([]byte, []byte, error) {
174138 return out , []byte (sql ), nil
175139}
176140
141+ // returns true if this protocol should be included
142+ func tweakProtocol (protocol * Protocol , cli * Cli , u * url.URL ) bool {
143+ if protocol .Connector == "livepeer-api" && ! protocol .StreamInfoService {
144+ protocol .RecordCatalystObjectStoreID = recordingBucketID
145+ protocol .VODCatalystObjectStoreID = vodBucketCatalystID
146+ protocol .VODCatalystPrivateAssetsObjectStore = privateBucketID
147+ protocol .VODObjectStoreID = vodBucketID
148+ protocol .CORSJWTAllowlist = fmt .Sprintf (`["%s"]` , cli .PublicURL )
149+ protocol .Ingest = fmt .Sprintf (
150+ `[{"ingest":"rtmp://%s/live","ingests":{"rtmp":"rtmp://%s/live","srt":"srt://%s:8889"},"playback":"%s/mist/hls","base":"%s","origin":"%s"}]` ,
151+ u .Hostname (),
152+ u .Hostname (),
153+ u .Hostname (),
154+ cli .PublicURL ,
155+ cli .PublicURL ,
156+ cli .PublicURL ,
157+ )
158+ } else if protocol .Connector == "livepeer-catalyst-api" {
159+ protocol .APIToken = cli .Secret
160+ protocol .Tags = fmt .Sprintf ("node=media,http=%s/mist,https=%s/mist" , cli .PublicURL , cli .PublicURL )
161+ } else if protocol .Connector == "livepeer-task-runner" {
162+ protocol .CatalystSecret = cli .Secret
163+ protocol .LivepeerAccessToken = cli .Secret
164+ } else if protocol .Connector == "livepeer-analyzer" {
165+ protocol .LivepeerAccessToken = cli .Secret
166+ } else if protocol .Connector == "livepeer" && protocol .Broadcaster && protocol .MetadataQueueURI != "" {
167+ protocol .
AuthWebhookURL = fmt .
Sprintf (
"http://%s:%[email protected] :3004/api/stream/hook" ,
adminID ,
cli .
Secret )
168+ } else if protocol .Connector == "WebRTC" {
169+ protocol .ICEServers = []ICEServer {
170+ {
171+ URLs : fmt .Sprintf ("stun:%s:3478" , u .Hostname ()),
172+ },
173+ {
174+ Credential : "livepeer" ,
175+ URLs : fmt .Sprintf ("turn:%s:3478" , u .Hostname ()),
176+ Username : "livepeer" ,
177+ },
178+ {
179+ URLs : fmt .Sprintf ("stun:%s:5349" , u .Hostname ()),
180+ },
181+ {
182+ Credential : "livepeer" ,
183+ URLs : fmt .Sprintf ("turn:%s:5349" , u .Hostname ()),
184+ Username : "livepeer" ,
185+ },
186+ }
187+ }
188+ return true
189+ }
190+
177191func ObjectStore (userID , publicURL , id , bucket string ) DBObject {
178192 return DBObject {
179193 "createdAt" : 0 ,
0 commit comments