From 675eb867da1714032d5949f889d60224b4c36a1b Mon Sep 17 00:00:00 2001 From: Carlo Bortolan <106114526+carlobortolan@users.noreply.github.com> Date: Tue, 5 Nov 2024 11:38:44 +0100 Subject: [PATCH 01/10] Update notification target to be included in model (de-)serialization (#1397) Signed-off-by: carlobortolan --- model/notification.go | 3 +-- web/ts/notification-management.ts | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/model/notification.go b/model/notification.go index 2fe9f6e31..08277198f 100644 --- a/model/notification.go +++ b/model/notification.go @@ -23,10 +23,9 @@ const ( // Notification is a message (e.g. a feature alert) that is displayed to users type Notification struct { Model - Title *string `json:"title,omitempty"` Body string `json:"-" gorm:"not null"` - Target NotificationTarget `json:"-" gorm:"not null; default:1"` + Target NotificationTarget `json:"target" gorm:"not null; default:1"` // SanitizedBody is the body of the notification, converted from markdown to HTML SanitizedBody string `json:"body" gorm:"-"` diff --git a/web/ts/notification-management.ts b/web/ts/notification-management.ts index 0d1217f1a..83ed3522c 100644 --- a/web/ts/notification-management.ts +++ b/web/ts/notification-management.ts @@ -7,7 +7,11 @@ export function createNotification(body: string, target: number, title: string | headers: { "Content-Type": "application/json", }, - body: JSON.stringify(notification), + body: JSON.stringify({ + title: notification.title, + body: notification.body, + target: Number(notification.target), + }), }) .then((r) => r.json()) .then((r) => { From 9b7aebb8d9c6e258defe04ec869d2e08477cc7e3 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sun, 10 Nov 2024 09:21:51 +0100 Subject: [PATCH 02/10] Fixed non working admin download (#1388) * Rollback to working worker version * Fixed Admin Download by Signing the VODs * Revert "Rollback to working worker version" This reverts commit fd82d6db76c894a853bc5145f8310031c66d108b. --- api/courses.go | 2 +- model/course.go | 10 ---------- model/stream.go | 2 +- tools/json-generator.go | 20 ++++++++++++++++++++ 4 files changed, 22 insertions(+), 12 deletions(-) create mode 100644 tools/json-generator.go diff --git a/api/courses.go b/api/courses.go index d9d1bafb4..f8c7f924d 100644 --- a/api/courses.go +++ b/api/courses.go @@ -1059,7 +1059,7 @@ func (r coursesRoutes) fetchLectures(c *gin.Context) { tlctx := c.MustGet("TUMLiveContext").(tools.TUMLiveContext) lectureHalls := r.LectureHallsDao.GetAllLectureHalls() - streams := tlctx.Course.AdminJson(lectureHalls) + streams := tools.AdminCourseJson(tlctx.Course, lectureHalls, tlctx.User) c.JSON(http.StatusOK, gin.H{ "streams": streams, diff --git a/model/course.go b/model/course.go index 00e80b330..7b83661a8 100755 --- a/model/course.go +++ b/model/course.go @@ -6,7 +6,6 @@ import ( "log" "time" - "github.com/gin-gonic/gin" "gorm.io/gorm" ) @@ -332,12 +331,3 @@ func (c Course) IsLoggedIn() bool { func (c Course) IsEnrolled() bool { return c.Visibility == "enrolled" } - -// AdminJson is the JSON representation of a courses streams for the admin panel -func (c Course) AdminJson(lhs []LectureHall) []gin.H { - var res []gin.H - for _, s := range c.Streams { - res = append(res, s.getJson(lhs, c)) - } - return res -} diff --git a/model/stream.go b/model/stream.go index 08d070c4b..4231a17af 100755 --- a/model/stream.go +++ b/model/stream.go @@ -307,7 +307,7 @@ func (s Stream) Color() string { } } -func (s Stream) getJson(lhs []LectureHall, course Course) gin.H { +func (s Stream) GetJson(lhs []LectureHall, course Course) gin.H { var files []gin.H for _, file := range s.Files { files = append(files, gin.H{ diff --git a/tools/json-generator.go b/tools/json-generator.go new file mode 100644 index 000000000..0aac0c47e --- /dev/null +++ b/tools/json-generator.go @@ -0,0 +1,20 @@ +package tools + +import ( + "github.com/TUM-Dev/gocast/model" + "github.com/gin-gonic/gin" +) + +// AdminCourseJson is the JSON representation of a courses streams for the admin panel +func AdminCourseJson(c *model.Course, lhs []model.LectureHall, u *model.User) []gin.H { + var res []gin.H + streams := c.Streams + for _, s := range streams { + err := SetSignedPlaylists(&s, u, true) + if err != nil { + logger.Error("Could not sign playlist for admin", "err", err) + } + res = append(res, s.GetJson(lhs, *c)) + } + return res +} From 7364d478fd3856b01bcc8dfb2a7a57604b6bb58a Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sun, 10 Nov 2024 10:59:25 +0100 Subject: [PATCH 03/10] Fixed bad readability issue (#1401) --- web/assets/css/main.css | 5 +++++ web/template/watch.gohtml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/web/assets/css/main.css b/web/assets/css/main.css index 56d5f0612..cb1e693b3 100644 --- a/web/assets/css/main.css +++ b/web/assets/css/main.css @@ -66,6 +66,11 @@ @apply text-gray-700 dark:text-gray-300; } + /*low contrast text*/ + .important-text-4 { + @apply text-gray-700 dark:text-gray-300 !important; + } + /*full contrast text*/ .text-5 { @apply text-gray-600 dark:text-gray-400; diff --git a/web/template/watch.gohtml b/web/template/watch.gohtml index 07ed1960c..04b32d66c 100644 --- a/web/template/watch.gohtml +++ b/web/template/watch.gohtml @@ -63,7 +63,7 @@ class="flex justify-start items-center pt-2"> - + From 4dda857e8b4343188225d1193417e6c3d6ceea0d Mon Sep 17 00:00:00 2001 From: kajo24 <67791504+karjo24@users.noreply.github.com> Date: Tue, 12 Nov 2024 09:50:44 +0100 Subject: [PATCH 04/10] fixed playback speeds when user is nil (#1400) --- model/user.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/model/user.go b/model/user.go index 04be99a44..7cab0e14d 100755 --- a/model/user.go +++ b/model/user.go @@ -99,9 +99,6 @@ func (s PlaybackSpeedSettings) GetEnabled() (res []float32) { } func (u *User) GetEnabledPlaybackSpeeds() (res []float32) { - if u == nil { - return []float32{1} - } // Possibly, this could be collapsed into a single line, but readibility suffers. res = append(res, u.GetPlaybackSpeeds().GetEnabled()...) res = append(res, u.GetCustomSpeeds()...) From 66804753e1f57dbeff358662e41b062daba983fa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Nov 2024 15:11:45 +0100 Subject: [PATCH 05/10] Bump github.com/golang-jwt/jwt/v4 from 4.5.0 to 4.5.1 (#1399) Bumps [github.com/golang-jwt/jwt/v4](https://github.com/golang-jwt/jwt) from 4.5.0 to 4.5.1. - [Release notes](https://github.com/golang-jwt/jwt/releases) - [Changelog](https://github.com/golang-jwt/jwt/blob/main/VERSION_HISTORY.md) - [Commits](https://github.com/golang-jwt/jwt/compare/v4.5.0...v4.5.1) --- updated-dependencies: - dependency-name: github.com/golang-jwt/jwt/v4 dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index d96e9e757..3c6be9da0 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/go-gormigrate/gormigrate/v2 v2.1.1 github.com/go-ldap/ldap/v3 v3.4.6 github.com/go-sql-driver/mysql v1.7.1 - github.com/golang-jwt/jwt/v4 v4.5.0 + github.com/golang-jwt/jwt/v4 v4.5.1 github.com/golang/glog v1.2.0 // indirect github.com/gorilla/websocket v1.5.1 // indirect github.com/jinzhu/now v1.1.5 diff --git a/go.sum b/go.sum index 29298ec97..ca33e8707 100644 --- a/go.sum +++ b/go.sum @@ -123,8 +123,9 @@ github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGF github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo= +github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68= github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= From f4bf9417cb861123a95f3aab0a7076af82577169 Mon Sep 17 00:00:00 2001 From: Joscha Henningsen Date: Tue, 12 Nov 2024 19:26:51 +0100 Subject: [PATCH 06/10] add some hints to compose file --- docker-compose.yml | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 4e1780b7a..fa7b8024f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,6 @@ +#################################################### +# Not production ready, only for local development # +#################################################### version: "3.8" services: @@ -20,7 +23,7 @@ services: container_name: tum-live-worker depends_on: - tum-live - - vod-service + #- vod-service # Omitted for local development due to size. Comment out to use voice-service build: worker platform: linux/amd64 environment: @@ -68,16 +71,17 @@ services: - ./init.sql:/data/application/init.sql - mariadb-data:/var/lib/mysql restart: always - voice-service: - container_name: tum-live-voice-service - image: ghcr.io/tum-dev/tum-live-voice-service:latest - environment: - - TRANSCRIBER=whisper - - WHISPER_MODEL=tiny - - MAX_WORKERS=10 - - DEBUG=1 - volumes: - - mass:/mass +# Omitted for local development due to size. Comment out to use voice-service +# voice-service: +# container_name: tum-live-voice-service +# image: ghcr.io/tum-dev/tum-live-voice-service:latest +# environment: +# - TRANSCRIBER=whisper +# - WHISPER_MODEL=tiny +# - MAX_WORKERS=10 +# - DEBUG=1 +# volumes: +# - mass:/mass volumes: recordings: From c6c3f16d4f4f85b68ed5854e726ac467a3897959 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 14 Nov 2024 12:40:27 +0100 Subject: [PATCH 07/10] Rollback to 1.4.15 which should be the latest version without any errors in the worker (#1398) --- worker/api/api_server.go | 3 +- worker/api/api_server_test.go | 6 +-- worker/cfg/cfg.go | 5 +- worker/client/main.go | 3 +- worker/cmd/worker/worker.go | 26 +++++----- worker/edge/edge.go | 16 +++---- worker/edge/go.mod | 2 +- worker/edge/go.sum | 6 +-- worker/edge/metrics.go | 5 +- worker/go.mod | 34 ++++++------- worker/go.sum | 79 ++++++++++++++++--------------- worker/rest/selfstream.go | 4 +- worker/rest/selfstream_test.go | 10 ++-- worker/rest/vod_upload.go | 5 +- worker/worker/ffmegtools.go | 4 +- worker/worker/notify.go | 3 +- worker/worker/persist.go | 5 +- worker/worker/premiere.go | 7 ++- worker/worker/request_handlers.go | 4 +- worker/worker/silence.go | 5 +- worker/worker/stream.go | 2 +- worker/worker/thumbnails.go | 7 ++- worker/worker/transcode.go | 16 +++---- worker/worker/upload.go | 5 +- worker/worker/upload_test.go | 5 +- worker/worker/vmstat/vmstat.go | 7 +-- worker/worker/waveform.go | 10 ++-- worker/worker/worker.go | 5 +- 28 files changed, 134 insertions(+), 155 deletions(-) diff --git a/worker/api/api_server.go b/worker/api/api_server.go index 1b895d7af..fb8a8ec16 100644 --- a/worker/api/api_server.go +++ b/worker/api/api_server.go @@ -4,13 +4,12 @@ import ( "context" "errors" "fmt" + "github.com/joschahenningsen/thumbgen" "net" "os" "os/exec" "time" - "github.com/joschahenningsen/thumbgen" - "github.com/u2takey/go-utils/uuid" "github.com/TUM-Dev/gocast/worker/cfg" diff --git a/worker/api/api_server_test.go b/worker/api/api_server_test.go index a6db31713..609ef0b18 100644 --- a/worker/api/api_server_test.go +++ b/worker/api/api_server_test.go @@ -2,10 +2,9 @@ package api import ( "context" - "testing" - "github.com/TUM-Dev/gocast/worker/cfg" "github.com/TUM-Dev/gocast/worker/pb" + "testing" ) var mockServer = server{} @@ -17,8 +16,7 @@ func setup() { func TestServer_RequestStream(t *testing.T) { setup() _, err := mockServer.RequestStream(context.Background(), &pb.StreamRequest{ - WorkerId: "234", - }) + WorkerId: "234"}) if err == nil { t.Errorf("Request with wrong WorkerID should be rejected") return diff --git a/worker/cfg/cfg.go b/worker/cfg/cfg.go index 051f3d93d..858639d02 100644 --- a/worker/cfg/cfg.go +++ b/worker/cfg/cfg.go @@ -77,11 +77,11 @@ func SetConfig() { if PersistDir == "" { PersistDir = "." } - err := os.MkdirAll(PersistDir, 0o755) + err := os.MkdirAll(PersistDir, 0755) if err != nil { log.Error(err) } - err = os.MkdirAll(LogDir, 0o755) + err = os.MkdirAll(LogDir, 0755) if err != nil { log.Warn("Could not create log directory: ", err) } @@ -112,4 +112,5 @@ func SetConfig() { defer sentry.Recover() log.AddHook(sentryhook.New([]log.Level{log.PanicLevel, log.FatalLevel, log.ErrorLevel, log.WarnLevel})) } + } diff --git a/worker/client/main.go b/worker/client/main.go index fb17c1584..b10886755 100644 --- a/worker/client/main.go +++ b/worker/client/main.go @@ -4,13 +4,12 @@ import ( "context" "encoding/base64" "fmt" - "time" - "github.com/TUM-Dev/gocast/worker/pb" log "github.com/sirupsen/logrus" "google.golang.org/grpc" "google.golang.org/grpc/backoff" "google.golang.org/grpc/credentials/insecure" + "time" ) // interactively test your implementation here diff --git a/worker/cmd/worker/worker.go b/worker/cmd/worker/worker.go index 95ede65de..85d2de84f 100644 --- a/worker/cmd/worker/worker.go +++ b/worker/cmd/worker/worker.go @@ -3,14 +3,6 @@ package main import ( "context" "fmt" - "net/http" - _ "net/http/pprof" - "os" - "os/exec" - "os/signal" - "syscall" - "time" - "github.com/TUM-Dev/gocast/worker/api" "github.com/TUM-Dev/gocast/worker/cfg" "github.com/TUM-Dev/gocast/worker/pb" @@ -21,18 +13,23 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/backoff" "google.golang.org/grpc/credentials/insecure" + "net/http" + _ "net/http/pprof" + "os" + "os/exec" + "os/signal" + "syscall" + "time" ) // OsSignal contains the current os signal received. // Application exits when it's terminating (kill, int, sigusr, term) -var ( - OsSignal chan os.Signal - VersionTag = "dev" -) +var OsSignal chan os.Signal +var VersionTag = "dev" // prepare checks if the required dependencies are installed func prepare() { - // check if ffmpeg is installed + //check if ffmpeg is installed _, err := exec.LookPath("ffmpeg") if err != nil { log.Fatal("ffmpeg is not installed") @@ -49,8 +46,7 @@ func main() { BaseDelay: 1 * time.Second, Multiplier: 1.6, MaxDelay: 30 * time.Second, - }, - }), grpc.WithBlock()) + }}), grpc.WithBlock()) if err != nil { log.Fatalf("Could not connect to main base: %v", err) } diff --git a/worker/edge/edge.go b/worker/edge/edge.go index a29682d2d..bb0fa7424 100644 --- a/worker/edge/edge.go +++ b/worker/edge/edge.go @@ -5,6 +5,8 @@ import ( "crypto/rsa" "encoding/json" "fmt" + "github.com/golang-jwt/jwt/v4" + "github.com/prometheus/client_golang/prometheus/promhttp" "io" "log" "mime" @@ -22,9 +24,6 @@ import ( "sync" "syscall" "time" - - "github.com/golang-jwt/jwt/v4" - "github.com/prometheus/client_golang/prometheus/promhttp" ) var ( @@ -35,15 +34,13 @@ var ( inflight = make(map[string]*sync.Mutex) allowedRe = regexp.MustCompile(`^/[a-zA-Z0-9]+/([a-zA-Z0-9_]+/)*[a-zA-Z0-9_]+\.(ts|m3u8)$`) // e.g. /vm123/live/stream/1234.ts - // allowedRe = regexp.MustCompile("^.*$") // e.g. /vm123/live/strean/1234.ts + //allowedRe = regexp.MustCompile("^.*$") // e.g. /vm123/live/strean/1234.ts ) var port = ":8089" -var ( - originPort = "8085" - originProto = "http://" -) +var originPort = "8085" +var originProto = "http://" var VersionTag = "dev" @@ -230,6 +227,7 @@ func vodHandler(w http.ResponseWriter, r *http.Request) { } r.URL.Path = strings.TrimPrefix(r.URL.Path, "/vod") f, err := os.Open(path.Join(vodPath, path.Clean(r.URL.Path))) + if err != nil { err404Playlists.WithLabelValues(claims.StreamID, claims.Playlist).Inc() w.WriteHeader(http.StatusNotFound) @@ -374,7 +372,7 @@ func fetchFile(host, file string) error { return fmt.Errorf("parse file path: %s", file) } d := filepath.Dir(diskDir) - err = os.MkdirAll(d, 0o755) + err = os.MkdirAll(d, 0755) if err != nil { return err } diff --git a/worker/edge/go.mod b/worker/edge/go.mod index 320393e2b..e5aef3a6b 100644 --- a/worker/edge/go.mod +++ b/worker/edge/go.mod @@ -16,5 +16,5 @@ require ( github.com/prometheus/common v0.44.0 // indirect github.com/prometheus/procfs v0.11.1 // indirect golang.org/x/sys v0.11.0 // indirect - google.golang.org/protobuf v1.33.0 // indirect + google.golang.org/protobuf v1.31.0 // indirect ) diff --git a/worker/edge/go.sum b/worker/edge/go.sum index e6005261f..562ab5b2d 100644 --- a/worker/edge/go.sum +++ b/worker/edge/go.sum @@ -3,7 +3,6 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -12,7 +11,6 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= @@ -29,5 +27,5 @@ golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= diff --git a/worker/edge/metrics.go b/worker/edge/metrics.go index f8f38d58d..776139280 100644 --- a/worker/edge/metrics.go +++ b/worker/edge/metrics.go @@ -1,11 +1,10 @@ package main import ( - "sync" - "time" - "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" + "sync" + "time" ) var ( diff --git a/worker/go.mod b/worker/go.mod index 573cdb8db..43bc86de3 100644 --- a/worker/go.mod +++ b/worker/go.mod @@ -4,18 +4,18 @@ go 1.21 // Direct dependencies require ( - github.com/getsentry/sentry-go v0.25.0 + github.com/getsentry/sentry-go v0.23.0 github.com/golang/protobuf v1.5.3 // indirect - github.com/icza/gox v0.0.0-20230924165045-adcb03233bb5 + github.com/icza/gox v0.0.0-20230330130131-23e1aaac139e github.com/iris-contrib/go.uuid v2.0.0+incompatible github.com/joschahenningsen/thumbgen v0.1.2 github.com/robfig/cron/v3 v3.0.1 - github.com/shirou/gopsutil/v3 v3.23.12 + github.com/shirou/gopsutil/v3 v3.23.7 github.com/sirupsen/logrus v1.9.3 - github.com/tidwall/gjson v1.17.0 - golang.org/x/sync v0.7.0 - google.golang.org/grpc v1.60.1 - google.golang.org/protobuf v1.33.0 + github.com/tidwall/gjson v1.16.0 + golang.org/x/sync v0.3.0 + google.golang.org/grpc v1.57.0 + google.golang.org/protobuf v1.31.0 ) require ( @@ -26,25 +26,25 @@ require ( // Indirect dependencies require ( github.com/go-ole/go-ole v1.3.0 // indirect - github.com/lufia/plan9stats v0.0.0-20231016141302-07b5767bb0ed // indirect + github.com/lufia/plan9stats v0.0.0-20230326075908-cb1d2100619a // indirect github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect github.com/rogpeppe/go-internal v1.8.1 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect - github.com/tklauser/go-sysconf v0.3.13 // indirect - github.com/tklauser/numcpus v0.7.0 // indirect + github.com/tklauser/go-sysconf v0.3.12 // indirect + github.com/tklauser/numcpus v0.6.1 // indirect github.com/u2takey/go-utils v0.3.1 github.com/yusufpapurcu/wmi v1.2.3 // indirect - golang.org/x/net v0.23.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/net v0.14.0 // indirect + golang.org/x/sys v0.11.0 // indirect + golang.org/x/text v0.12.0 // indirect ) require ( github.com/felixge/fgprof v0.9.3 // indirect - github.com/google/pprof v0.0.0-20231229205709-960ae82b1e42 // indirect - github.com/google/uuid v1.5.0 // indirect + github.com/google/pprof v0.0.0-20230811205829-9131a7e9cc17 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect - golang.org/x/image v0.18.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1 // indirect + golang.org/x/image v0.11.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230814215434-ca7cfce7776a // indirect ) diff --git a/worker/go.sum b/worker/go.sum index dc87f60a8..0210eed1b 100644 --- a/worker/go.sum +++ b/worker/go.sum @@ -102,8 +102,8 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/getsentry/sentry-go v0.17.0/go.mod h1:B82dxtBvxG0KaPD8/hfSV+VcHD+Lg/xUS4JuQn1P4cM= -github.com/getsentry/sentry-go v0.25.0 h1:q6Eo+hS+yoJlTO3uu/azhQadsD8V+jQn2D8VvX1eOyI= -github.com/getsentry/sentry-go v0.25.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= +github.com/getsentry/sentry-go v0.23.0 h1:dn+QRCeJv4pPt9OjVXiMcGIBIefaTJPw/h0bZWO05nE= +github.com/getsentry/sentry-go v0.23.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= @@ -181,9 +181,8 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= @@ -202,14 +201,13 @@ github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg= -github.com/google/pprof v0.0.0-20231229205709-960ae82b1e42 h1:dHLYa5D8/Ta0aLR2XcPsrkpAgGeFs6thhMcQK0oQ0n8= -github.com/google/pprof v0.0.0-20231229205709-960ae82b1e42/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= +github.com/google/pprof v0.0.0-20230811205829-9131a7e9cc17 h1:0h35ESZ02+hN/MFZb7XZOXg+Rl9+Rk8fBIf5YLws9gA= +github.com/google/pprof v0.0.0-20230811205829-9131a7e9cc17/go.mod h1:Jh3hGz2jkYak8qXPD19ryItVnUgpgeqzdkY/D0EaeuA= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= -github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -243,8 +241,8 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= -github.com/icza/gox v0.0.0-20230924165045-adcb03233bb5 h1:K7KEFpKgVcjj98jOu2Z3xMBTtTwfYVT90Zmo3ZuWmbE= -github.com/icza/gox v0.0.0-20230924165045-adcb03233bb5/go.mod h1:VbcN86fRkkUMPX2ufM85Um8zFndLZswoIW1eYtpAcVk= +github.com/icza/gox v0.0.0-20230330130131-23e1aaac139e h1:aIs1rPxsH8t12+eWzEfrvK2o99fwiC0P9Qr8roW0vsU= +github.com/icza/gox v0.0.0-20230330130131-23e1aaac139e/go.mod h1:VbcN86fRkkUMPX2ufM85Um8zFndLZswoIW1eYtpAcVk= github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/iris-contrib/go.uuid v2.0.0+incompatible h1:XZubAYg61/JwnJNbZilGjf3b3pB80+OQg2qf6c8BfWE= @@ -292,8 +290,8 @@ github.com/labstack/echo/v4 v4.9.0/go.mod h1:xkCDAdFCIf8jsFQ5NnbK7oqaF/yU1A1X20L github.com/labstack/gommon v0.3.1/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= -github.com/lufia/plan9stats v0.0.0-20231016141302-07b5767bb0ed h1:036IscGBfJsFIgJQzlui7nK1Ncm0tp2ktmPj8xO4N/0= -github.com/lufia/plan9stats v0.0.0-20231016141302-07b5767bb0ed/go.mod h1:ilwx/Dta8jXAgpFYFvSWEMwxmbWXyiUHkd5FwyKhb5k= +github.com/lufia/plan9stats v0.0.0-20230326075908-cb1d2100619a h1:N9zuLhTvBSRt0gWSiJswwQ2HqDmtX/ZCDJURnKUt1Ik= +github.com/lufia/plan9stats v0.0.0-20230326075908-cb1d2100619a/go.mod h1:JKx41uQRwqlTZabZc+kILPrO/3jlKnQ2Z8b7YiVw5cE= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mailgun/raymond/v2 v2.0.46/go.mod h1:lsgvL50kgt1ylcFJYZiULi5fjPBkkhNfj4KA0W54Z18= @@ -386,8 +384,8 @@ github.com/schollz/closestmatch v2.1.0+incompatible/go.mod h1:RtP1ddjLong6gTkbtm github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shirou/gopsutil/v3 v3.22.8/go.mod h1:s648gW4IywYzUfE/KjXxUsqrqx/T2xO5VqOXxONeRfI= -github.com/shirou/gopsutil/v3 v3.23.12 h1:z90NtUkp3bMtmICZKpC4+WaknU1eXtp5vtbQ11DgpE4= -github.com/shirou/gopsutil/v3 v3.23.12/go.mod h1:1FrWgea594Jp7qmjHUUPlJDTPgcsb9mGnXDxavtikzM= +github.com/shirou/gopsutil/v3 v3.23.7 h1:C+fHO8hfIppoJ1WdsVm1RoI0RwXoNdfTK7yWXV0wVj4= +github.com/shirou/gopsutil/v3 v3.23.7/go.mod h1:c4gnmoRC0hQuaLqvxnx1//VXQ0Ms/X9UnJF8pddY5z4= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= @@ -440,21 +438,21 @@ github.com/tdewolff/minify/v2 v2.12.4/go.mod h1:h+SRvSIX3kwgwTFOpSckvSxgax3uy8kZ github.com/tdewolff/parse/v2 v2.6.3/go.mod h1:woz0cgbLwFdtbjJu8PIKxhW05KplTFQkOdX78o+Jgrs= github.com/tdewolff/parse/v2 v2.6.4/go.mod h1:woz0cgbLwFdtbjJu8PIKxhW05KplTFQkOdX78o+Jgrs= github.com/tdewolff/test v1.0.7/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE= -github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM= -github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.16.0 h1:SyXa+dsSPpUlcwEDuKuEBJEz5vzTvOea+9rjyYodQFg= +github.com/tidwall/gjson v1.16.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk= +github.com/tklauser/go-sysconf v0.3.11/go.mod h1:GqXfhXY3kiPa0nAXPDIQIWzJbMCB7AmcWpGR8lSZfqI= +github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= -github.com/tklauser/go-sysconf v0.3.13 h1:GBUpcahXSpR2xN01jhkNAbTLRk2Yzgggk8IM08lq3r4= -github.com/tklauser/go-sysconf v0.3.13/go.mod h1:zwleP4Q4OehZHGn4CYZDipCgg9usW5IJePewFCGVEa0= github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ= +github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4= +github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= -github.com/tklauser/numcpus v0.7.0 h1:yjuerZP127QG9m5Zh/mSO4wqurYil27tHrqwRoRjpr4= -github.com/tklauser/numcpus v0.7.0/go.mod h1:bb6dMVcj8A42tSE7i32fsIUCbQNllK5iDguyOZRUzAY= github.com/u2takey/go-utils v0.3.1 h1:TaQTgmEZZeDHQFYfd+AdUT1cT4QJgJn/XVPELhHw4ys= github.com/u2takey/go-utils v0.3.1/go.mod h1:6e+v5vEZ/6gu12w/DC2ixZdZtCrNokVxD0JUklcqdCs= github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= @@ -528,8 +526,8 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ= -golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E= +golang.org/x/image v0.11.0 h1:ds2RoQvBvYTiJkwpSFDwCcDFNX7DqjL2WsUgTNk0Ooo= +golang.org/x/image v0.11.0/go.mod h1:bglhjqbqVuEb9e9+eNR45Jfu7D+T4Qan+NhQk8Ck2P8= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -554,6 +552,7 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -602,8 +601,9 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221002022538-bcab6841153b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -629,8 +629,9 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -705,14 +706,16 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -723,8 +726,9 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -787,6 +791,7 @@ golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -861,8 +866,8 @@ google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1 h1:gphdwh0npgs8elJ4T6J+DQJHPVF7RsuJHCfwztUb4J4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1/go.mod h1:daQN87bsDqDoe316QbbvX60nMoJQa4r6Ds0ZuoAe5yA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230814215434-ca7cfce7776a h1:5rTPHLf5eLPfqGvw3fLpEmUpko2Ky91ft14LxGs5BZc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230814215434-ca7cfce7776a/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -883,8 +888,8 @@ google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAG google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= -google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= +google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= +google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -899,8 +904,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/worker/rest/selfstream.go b/worker/rest/selfstream.go index f6b667d59..c8edde1be 100644 --- a/worker/rest/selfstream.go +++ b/worker/rest/selfstream.go @@ -2,11 +2,10 @@ package rest import ( "encoding/json" + "google.golang.org/grpc" "io" "net/http" - "google.golang.org/grpc" - "github.com/TUM-Dev/gocast/worker/cfg" "github.com/TUM-Dev/gocast/worker/pb" "github.com/TUM-Dev/gocast/worker/worker" @@ -75,6 +74,7 @@ func (s *safeStreams) onPublish(w http.ResponseWriter, r *http.Request) { return } go func() { + s.mutex.Lock() if streamCtx, ok := s.streams[streamKey]; ok { log.Debug("SelfStream already exists, stopping it.") diff --git a/worker/rest/selfstream_test.go b/worker/rest/selfstream_test.go index 80767989d..ad100c0f1 100644 --- a/worker/rest/selfstream_test.go +++ b/worker/rest/selfstream_test.go @@ -12,12 +12,10 @@ import ( log "github.com/sirupsen/logrus" ) -var ( - r *http.Request - w *httptest.ResponseRecorder - streamID string - testSlug string -) +var r *http.Request +var w *httptest.ResponseRecorder +var streamID string +var testSlug string func setup() { r = httptest.NewRequest(http.MethodGet, "https://test.de", nil) diff --git a/worker/rest/vod_upload.go b/worker/rest/vod_upload.go index 4feaee7c4..de1df6c23 100644 --- a/worker/rest/vod_upload.go +++ b/worker/rest/vod_upload.go @@ -1,12 +1,11 @@ package rest import ( + "github.com/TUM-Dev/gocast/worker/worker" + log "github.com/sirupsen/logrus" "io" "net/http" "os" - - "github.com/TUM-Dev/gocast/worker/worker" - log "github.com/sirupsen/logrus" ) // handleUpload handles VOD upload requests proxied by TUM-Live. diff --git a/worker/worker/ffmegtools.go b/worker/worker/ffmegtools.go index 7b00fd258..acb9a64f0 100644 --- a/worker/worker/ffmegtools.go +++ b/worker/worker/ffmegtools.go @@ -1,13 +1,13 @@ package worker import ( - "os/exec" - "github.com/tidwall/gjson" + "os/exec" ) func getDuration(file string) (float64, error) { probe, err := probe(file) + if err != nil { return 0, err } diff --git a/worker/worker/notify.go b/worker/worker/notify.go index 41575f6f3..56c806994 100644 --- a/worker/worker/notify.go +++ b/worker/worker/notify.go @@ -3,13 +3,12 @@ package worker import ( "context" "fmt" - "time" - "github.com/TUM-Dev/gocast/worker/cfg" "github.com/TUM-Dev/gocast/worker/pb" log "github.com/sirupsen/logrus" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" + "time" ) func closeConnection(conn *grpc.ClientConn) { diff --git a/worker/worker/persist.go b/worker/worker/persist.go index 8eb45f733..c7df26ff7 100644 --- a/worker/worker/persist.go +++ b/worker/worker/persist.go @@ -3,11 +3,10 @@ package worker import ( "encoding/gob" "errors" + "github.com/TUM-Dev/gocast/worker/cfg" "os" "sync" "time" - - "github.com/TUM-Dev/gocast/worker/cfg" ) var persisted *Persistable @@ -26,7 +25,7 @@ const persistFileName = "/persist.gob" // writeOut writes out the persistable object to disk func (p *Persistable) writeOut() error { - f, err := os.OpenFile(cfg.PersistDir+persistFileName, os.O_RDWR|os.O_CREATE, 0o666) + f, err := os.OpenFile(cfg.PersistDir+persistFileName, os.O_RDWR|os.O_CREATE, 0666) if err != nil { return err } diff --git a/worker/worker/premiere.go b/worker/worker/premiere.go index 56d3a7130..80511f2f8 100644 --- a/worker/worker/premiere.go +++ b/worker/worker/premiere.go @@ -2,11 +2,10 @@ package worker import ( "fmt" - "os" - "os/exec" - "github.com/TUM-Dev/gocast/worker/cfg" log "github.com/sirupsen/logrus" + "os" + "os/exec" ) func streamPremiere(ctx *StreamContext) { @@ -20,7 +19,7 @@ func streamPremiere(ctx *StreamContext) { "-acodec", "aac", "-b:a", "128k", "-ac", "2", "-ar", "48000", "-af", "aresample=async=1:min_hard_comp=0.100000:first_pts=0", "-f", "flv", fmt.Sprintf("%s%s", ctx.ingestServer, ctx.streamName)) log.WithField("cmd", cmd.String()).Info("Starting premiere") - ffmpegErr, errFfmpegErrFile := os.OpenFile(fmt.Sprintf("%s/ffmpeg_%s.log", cfg.LogDir, ctx.getStreamName()), os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0o644) + ffmpegErr, errFfmpegErrFile := os.OpenFile(fmt.Sprintf("%s/ffmpeg_%s.log", cfg.LogDir, ctx.getStreamName()), os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0644) if errFfmpegErrFile == nil { cmd.Stderr = ffmpegErr } else { diff --git a/worker/worker/request_handlers.go b/worker/worker/request_handlers.go index a1b0c7683..b66cea99a 100644 --- a/worker/worker/request_handlers.go +++ b/worker/worker/request_handlers.go @@ -218,7 +218,7 @@ func cancelCmd(cmd *exec.Cmd) { func HandleStreamRequest(request *pb.StreamRequest) { log.WithField("request", request).Info("Request to stream") - // setup context with relevant information to pass to other subprocesses + //setup context with relevant information to pass to other subprocesses streamCtx := &StreamContext{ streamId: request.GetStreamID(), sourceUrl: "rtsp://" + request.GetSourceUrl(), @@ -475,7 +475,7 @@ type StreamContext struct { discardVoD bool // whether the VoD should be discarded // calculated after stream: - duration uint32 // duration of the stream in seconds + duration uint32 //duration of the stream in seconds thumbInterval uint32 // interval between thumbnails in seconds TranscodingSuccessful bool // TranscodingSuccessful is true if the transcoding was successful diff --git a/worker/worker/silence.go b/worker/worker/silence.go index ee9d6bcaa..845db604a 100644 --- a/worker/worker/silence.go +++ b/worker/worker/silence.go @@ -1,11 +1,10 @@ package worker import ( + log "github.com/sirupsen/logrus" "os/exec" "strconv" "strings" - - log "github.com/sirupsen/logrus" ) type SilenceDetect struct { @@ -56,7 +55,7 @@ func (s *SilenceDetect) ParseSilence() error { return nil } -// postprocess merges short duration of silence into units of silence +//postprocess merges short duration of silence into units of silence func (s *SilenceDetect) postprocess() { oldSilences := *s.Silences if len(oldSilences) < 2 { diff --git a/worker/worker/stream.go b/worker/worker/stream.go index ebe062909..8c73c2294 100644 --- a/worker/worker/stream.go +++ b/worker/worker/stream.go @@ -45,7 +45,7 @@ func stream(streamCtx *StreamContext) { // persist stream command in context, so it can be killed later streamCtx.streamCmd = cmd log.WithField("cmd", cmd.String()).Info("Starting stream") - ffmpegErr, errFfmpegErrFile := os.OpenFile(fmt.Sprintf("%s/ffmpeg_%s.log", cfg.LogDir, streamCtx.getStreamName()), os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0o644) + ffmpegErr, errFfmpegErrFile := os.OpenFile(fmt.Sprintf("%s/ffmpeg_%s.log", cfg.LogDir, streamCtx.getStreamName()), os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0644) if errFfmpegErrFile == nil { cmd.Stderr = ffmpegErr } else { diff --git a/worker/worker/thumbnails.go b/worker/worker/thumbnails.go index f621028c7..2dfb7be4b 100644 --- a/worker/worker/thumbnails.go +++ b/worker/worker/thumbnails.go @@ -1,12 +1,11 @@ package worker import ( + "github.com/joschahenningsen/thumbgen" + log "github.com/sirupsen/logrus" "io" "os" "time" - - "github.com/joschahenningsen/thumbgen" - log "github.com/sirupsen/logrus" ) const ( @@ -50,7 +49,7 @@ func createVideoThumbnail(ctx *StreamContext, source string) error { if err != nil { return err } - file, err := os.OpenFile(ctx.getLargeThumbnailSpriteFileName(), os.O_CREATE|os.O_WRONLY, 0o644) + file, err := os.OpenFile(ctx.getLargeThumbnailSpriteFileName(), os.O_CREATE|os.O_WRONLY, 0644) if err != nil { return err } diff --git a/worker/worker/transcode.go b/worker/worker/transcode.go index a58c0a94b..c1a4c18d2 100644 --- a/worker/worker/transcode.go +++ b/worker/worker/transcode.go @@ -4,16 +4,15 @@ import ( "bufio" "context" "fmt" + "github.com/TUM-Dev/gocast/worker/cfg" + "github.com/TUM-Dev/gocast/worker/pb" + log "github.com/sirupsen/logrus" "io" "os" "os/exec" "path/filepath" "strings" "time" - - "github.com/TUM-Dev/gocast/worker/cfg" - "github.com/TUM-Dev/gocast/worker/pb" - log "github.com/sirupsen/logrus" ) func buildCommand(niceness int, infile string, outfile string, tune string, crf int, self bool) *exec.Cmd { @@ -22,8 +21,7 @@ func buildCommand(niceness int, infile string, outfile string, tune string, crf "ffmpeg", "-nostats", "-loglevel", "error", "-y", "-progress", "-", "-i", infile, - "-vsync", "2", "-c:v", "libx264", "-level", "4.0", "-movflags", "+faststart", - } + "-vsync", "2", "-c:v", "libx264", "-level", "4.0", "-movflags", "+faststart"} if tune != "" { c = append(c, "-tune", tune) } @@ -78,7 +76,7 @@ func transcode(streamCtx *StreamContext) error { case "COMB": cmd = buildCommand(8, in, out, "", 24, streamCtx.isSelfStream) default: - // unknown source, use higher compression and less priority + //unknown source, use higher compression and less priority cmd = buildCommand(10, in, out, "", 26, streamCtx.isSelfStream) } log.WithFields(log.Fields{"input": in, "output": out, "command": cmd.String()}).Info("Transcoding") @@ -149,7 +147,7 @@ func handleTranscodingOutput(stderr io.ReadCloser, inputTime float64, progressCh // creates folder for output file if it doesn't exist func prepare(out string) error { dir := filepath.Dir(out) - err := os.MkdirAll(dir, 0o750) + err := os.MkdirAll(dir, 0750) if err != nil { return fmt.Errorf("create output directory for transcoding: %s", err) } @@ -159,7 +157,7 @@ func prepare(out string) error { // markForDeletion moves the file to $recfolder/.trash/ func markForDeletion(ctx *StreamContext) error { trashName := ctx.getRecordingTrashName() - err := os.MkdirAll(filepath.Dir(trashName), 0o750) + err := os.MkdirAll(filepath.Dir(trashName), 0750) if err != nil { return fmt.Errorf("create trash directory: %s", err) } diff --git a/worker/worker/upload.go b/worker/worker/upload.go index 9dc27bd54..b70920b34 100644 --- a/worker/worker/upload.go +++ b/worker/worker/upload.go @@ -1,15 +1,14 @@ package worker import ( + "github.com/TUM-Dev/gocast/worker/cfg" + log "github.com/sirupsen/logrus" "io" "mime/multipart" "net/http" "os" "strings" "time" - - "github.com/TUM-Dev/gocast/worker/cfg" - log "github.com/sirupsen/logrus" ) func upload(streamCtx *StreamContext) { diff --git a/worker/worker/upload_test.go b/worker/worker/upload_test.go index 416cebb88..903bebcde 100644 --- a/worker/worker/upload_test.go +++ b/worker/worker/upload_test.go @@ -1,12 +1,11 @@ package worker import ( + "github.com/TUM-Dev/gocast/worker/cfg" "net/http" "os" "sync" "testing" - - "github.com/TUM-Dev/gocast/worker/cfg" ) func TestUpload(t *testing.T) { @@ -72,7 +71,7 @@ func createDummyFile(filesize uint) (string, error) { if err != nil { return "", err } - f, err := os.OpenFile(file.Name(), os.O_APPEND|os.O_WRONLY, 0o600) + f, err := os.OpenFile(file.Name(), os.O_APPEND|os.O_WRONLY, 0600) if err != nil { return "", err } diff --git a/worker/worker/vmstat/vmstat.go b/worker/worker/vmstat/vmstat.go index 095c84e04..c683e3f57 100644 --- a/worker/worker/vmstat/vmstat.go +++ b/worker/worker/vmstat/vmstat.go @@ -3,13 +3,12 @@ package vmstat import ( "context" "fmt" - "time" - "github.com/icza/gox/fmtx" "github.com/shirou/gopsutil/v3/cpu" "github.com/shirou/gopsutil/v3/disk" "github.com/shirou/gopsutil/v3/mem" "golang.org/x/sync/errgroup" + "time" ) type VmStat struct { @@ -25,7 +24,9 @@ type VmStat struct { DiskUsed uint64 } -var ErrCPUInvalid = fmt.Errorf("len (cpu.Percent) != 1") +var ( + ErrCPUInvalid = fmt.Errorf("len (cpu.Percent) != 1") +) func New() *VmStat { return &VmStat{diskPath: "/"} diff --git a/worker/worker/waveform.go b/worker/worker/waveform.go index a163f6cb7..6d3d6e819 100644 --- a/worker/worker/waveform.go +++ b/worker/worker/waveform.go @@ -2,14 +2,13 @@ package worker import ( "fmt" + uuid "github.com/iris-contrib/go.uuid" + "github.com/TUM-Dev/gocast/worker/pb" + log "github.com/sirupsen/logrus" "io" "os" "os/exec" "strings" - - "github.com/TUM-Dev/gocast/worker/pb" - uuid "github.com/iris-contrib/go.uuid" - log "github.com/sirupsen/logrus" ) const ( @@ -29,8 +28,7 @@ func GetWaveform(request *pb.WaveformRequest) ([]byte, error) { return nil, err } tempFile := "/tmp/" + v4.String() + ".png" - c := []string{ - "ffmpeg", "-i", request.File, + c := []string{"ffmpeg", "-i", request.File, "-filter_complex", fmt.Sprintf("aformat=channel_layouts=mono,showwavespic=s=%dx%d:filter=average:colors=white|white:scale=lin", waveFormWitdth, waveFormHeight), "-frames:v", "1", tempFile, diff --git a/worker/worker/worker.go b/worker/worker/worker.go index c67660ec2..40e0582aa 100644 --- a/worker/worker/worker.go +++ b/worker/worker/worker.go @@ -1,13 +1,12 @@ package worker import ( - "os" - "time" - "github.com/TUM-Dev/gocast/worker/cfg" "github.com/TUM-Dev/gocast/worker/worker/vmstat" "github.com/robfig/cron/v3" log "github.com/sirupsen/logrus" + "os" + "time" ) // Setup starts all recurring jobs of the worker From ca1b6a1c38955f7f9e7b388d3dbde6c4e6bdd984 Mon Sep 17 00:00:00 2001 From: kajo24 <67791504+karjo24@users.noreply.github.com> Date: Fri, 15 Nov 2024 15:23:51 +0100 Subject: [PATCH 08/10] added missing return after abort (#1407) --- api/courses.go | 1 + 1 file changed, 1 insertion(+) diff --git a/api/courses.go b/api/courses.go index f8c7f924d..4b2c6c4a9 100644 --- a/api/courses.go +++ b/api/courses.go @@ -362,6 +362,7 @@ func (r coursesRoutes) getCourseBySlug(c *gin.Context) { if (course.IsLoggedIn() && tumLiveContext.User == nil) || (course.IsEnrolled() && !tumLiveContext.User.IsEligibleToWatchCourse(course)) { c.AbortWithStatus(http.StatusUnauthorized) + return } user := tumLiveContext.User From acca75db1e64ecd913706440c519cbc2824e2a38 Mon Sep 17 00:00:00 2001 From: Carlo Bortolan <106114526+carlobortolan@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:03:05 +0100 Subject: [PATCH 09/10] Add alerts for test courses and outdated semesters (#1408) --- web/admin.go | 5 +++ .../admin/admin_tabs/edit-course.gohtml | 31 ++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/web/admin.go b/web/admin.go index 8ee7389b9..c6bddef7a 100644 --- a/web/admin.go +++ b/web/admin.go @@ -248,8 +248,13 @@ func (r mainRoutes) EditCoursePage(c *gin.Context) { if err != nil { logger.Error("Error getting invited users for course", "err", err) } + y, t := tum.GetCurrentSemester() + indexData := NewIndexData() indexData.TUMLiveContext = tumLiveContext + indexData.CurrentYear = y + indexData.CurrentTerm = t + courses, err := r.CoursesDao.GetAdministeredCoursesByUserId(context.Background(), tumLiveContext.User.ID, "", 0) if err != nil { logger.Error("couldn't query courses for user.", "err", err) diff --git a/web/template/admin/admin_tabs/edit-course.gohtml b/web/template/admin/admin_tabs/edit-course.gohtml index 92a4ac014..cbb052d73 100644 --- a/web/template/admin/admin_tabs/edit-course.gohtml +++ b/web/template/admin/admin_tabs/edit-course.gohtml @@ -5,6 +5,9 @@ {{- /*gotype: github.com/TUM-Dev/gocast/web.AdminPageData*/ -}} {{$course := .IndexData.TUMLiveContext.Course}} {{$lecture := .IndexData.TUMLiveContext.Stream}} +{{$currentYear := .IndexData.CurrentYear}} +{{$currentTerm := .IndexData.CurrentTerm}} +
@@ -20,6 +23,32 @@ role="alert"> Course was created successfully.
+ {{if (eq $course.TeachingTerm "Test")}} + + {{else if or (ne $course.TeachingTerm $currentTerm) (ne $course.Year $currentYear)}} + + {{end}}