2020-09-28 17:36:40 +02:00
|
|
|
//go:generate pkger
|
|
|
|
|
2020-10-09 22:36:02 +02:00
|
|
|
// Package main provides the full-featured server with configuration loading
|
|
|
|
// and communication between routines.
|
2020-09-21 17:29:50 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2020-09-21 19:59:41 +02:00
|
|
|
"log"
|
|
|
|
|
2020-09-22 11:42:57 +02:00
|
|
|
"gitlab.crans.org/nounous/ghostream/auth"
|
2020-10-11 21:35:43 +02:00
|
|
|
"gitlab.crans.org/nounous/ghostream/internal/config"
|
2020-09-21 21:38:11 +02:00
|
|
|
"gitlab.crans.org/nounous/ghostream/internal/monitoring"
|
2020-10-19 19:28:30 +02:00
|
|
|
"gitlab.crans.org/nounous/ghostream/messaging"
|
2020-09-30 15:07:36 +02:00
|
|
|
"gitlab.crans.org/nounous/ghostream/stream/forwarding"
|
2020-09-27 11:14:22 +02:00
|
|
|
"gitlab.crans.org/nounous/ghostream/stream/srt"
|
2020-10-13 18:04:00 +02:00
|
|
|
"gitlab.crans.org/nounous/ghostream/stream/telnet"
|
2020-09-29 17:04:23 +02:00
|
|
|
"gitlab.crans.org/nounous/ghostream/stream/webrtc"
|
2020-10-17 19:40:37 +02:00
|
|
|
"gitlab.crans.org/nounous/ghostream/transcoder"
|
2020-09-21 17:47:31 +02:00
|
|
|
"gitlab.crans.org/nounous/ghostream/web"
|
2020-09-21 17:29:50 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2020-10-05 11:38:17 +02:00
|
|
|
// Configure logger
|
|
|
|
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
|
|
|
|
|
2020-09-21 19:59:41 +02:00
|
|
|
// Load configuration
|
2020-10-11 21:35:43 +02:00
|
|
|
cfg, err := config.Load()
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalln("Failed to load configuration:", err)
|
2020-09-21 19:59:41 +02:00
|
|
|
}
|
|
|
|
|
2020-09-22 12:54:12 +02:00
|
|
|
// Init authentification
|
2020-09-22 14:16:52 +02:00
|
|
|
authBackend, err := auth.New(&cfg.Auth)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalln("Failed to load authentification backend:", err)
|
|
|
|
}
|
2020-10-09 22:06:30 +02:00
|
|
|
if authBackend != nil {
|
|
|
|
defer authBackend.Close()
|
|
|
|
}
|
2020-09-22 12:54:12 +02:00
|
|
|
|
2020-10-17 18:22:06 +02:00
|
|
|
// Init streams messaging
|
2020-10-19 19:28:30 +02:00
|
|
|
streams := messaging.New()
|
2020-10-01 12:00:59 +02:00
|
|
|
|
2020-10-11 21:35:43 +02:00
|
|
|
// Start routines
|
2020-10-17 19:40:37 +02:00
|
|
|
go transcoder.Init(streams, &cfg.Transcoder)
|
2020-10-18 11:06:54 +02:00
|
|
|
go forwarding.Serve(streams, cfg.Forwarding)
|
2020-09-29 17:04:23 +02:00
|
|
|
go monitoring.Serve(&cfg.Monitoring)
|
2020-10-17 18:22:06 +02:00
|
|
|
go srt.Serve(streams, authBackend, &cfg.Srt)
|
|
|
|
go telnet.Serve(streams, &cfg.Telnet)
|
2020-10-19 21:45:23 +02:00
|
|
|
go web.Serve(streams, &cfg.Web)
|
|
|
|
go webrtc.Serve(streams, &cfg.WebRTC)
|
2020-09-21 21:33:32 +02:00
|
|
|
|
2020-09-21 21:05:45 +02:00
|
|
|
// Wait for routines
|
|
|
|
select {}
|
2020-09-21 17:29:50 +02:00
|
|
|
}
|