From cc72962d37930ea491bde9e88a491cca46d45b01 Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 2 Sep 2023 08:55:01 +0800 Subject: [PATCH] 2023.09.02: Enable CORS and timestamp in HLS. v5.8.30 --- platform/main.go | 2 +- platform/service.go | 2 +- platform/utils.go | 8 ++------ platform/version.go | 2 +- scripts/setup-aapanel/info.json | 2 +- scripts/setup-bt/info.json | 2 +- 6 files changed, 7 insertions(+), 11 deletions(-) diff --git a/platform/main.go b/platform/main.go index 330521d1..298b1dd7 100644 --- a/platform/main.go +++ b/platform/main.go @@ -357,7 +357,7 @@ func initPlatform(ctx context.Context) error { } // Run only once for a special version. - bootRelease := "v28" + bootRelease := "v202328" if firstRun, err := rdb.HGet(ctx, SRS_FIRST_BOOT, bootRelease).Result(); err != nil && err != redis.Nil { return errors.Wrapf(err, "hget %v %v", SRS_FIRST_BOOT, bootRelease) } else if firstRun == "" { diff --git a/platform/service.go b/platform/service.go index 57b693b8..21ee1956 100644 --- a/platform/service.go +++ b/platform/service.go @@ -300,7 +300,7 @@ func handleHTTPService(ctx context.Context, handler *http.ServeMux) error { } if strings.HasSuffix(r.URL.Path, ".ts") { httpAllowCORS(w, r) - w.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%v", 300)) + w.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%v", 600)) hlsFileServer.ServeHTTP(w, r) return } diff --git a/platform/utils.go b/platform/utils.go index be7778fa..c958beb3 100644 --- a/platform/utils.go +++ b/platform/utils.go @@ -446,7 +446,7 @@ func srsGenerateConfig(ctx context.Context) error { " hls_window 60;", " hls_path ./objs/nginx/html;", " hls_m3u8_file [app]/[stream].m3u8;", - " hls_ts_file [app]/[stream]-[seq].ts;", + " hls_ts_file [app]/[stream]-[seq]-[timestamp].ts;", " hls_wait_keyframe on;", " hls_dispose 10;", } @@ -1248,12 +1248,8 @@ func Authenticate(ctx context.Context, apiSecret, token string, header http.Head } // httpAllowCORS allow CORS for HTTP request. +// Note that we always enable CROS because we enable HTTP cache. func httpAllowCORS(w http.ResponseWriter, r *http.Request) { - // Ignore if no CORS required. - if r.Header.Get("Origin") == "" { - return - } - // SRS does not need cookie or credentials, so we disable CORS credentials, and use * for CORS origin, // headers, expose headers and methods. w.Header().Set("Access-Control-Allow-Origin", "*") diff --git a/platform/version.go b/platform/version.go index 300abcdc..22833305 100644 --- a/platform/version.go +++ b/platform/version.go @@ -6,4 +6,4 @@ package main // The version for platform. -const version = "v5.8.28" +const version = "v5.8.30" diff --git a/scripts/setup-aapanel/info.json b/scripts/setup-aapanel/info.json index 54472143..0b2d6676 100644 --- a/scripts/setup-aapanel/info.json +++ b/scripts/setup-aapanel/info.json @@ -2,7 +2,7 @@ "title": "SRS Stack", "name": "srs_stack", "ps": "SRS is a simple, high efficiency and realtime video server, supports RTMP, WebRTC, HLS, HTTP-FLV, and SRT.", - "versions": "5.8.28", + "versions": "5.8.30", "checks": "/www/server/panel/plugin/srs_stack", "author": "Winlin", "home": "https://github.com/ossrs/srs-stack" diff --git a/scripts/setup-bt/info.json b/scripts/setup-bt/info.json index df4a4811..a78ee3b9 100644 --- a/scripts/setup-bt/info.json +++ b/scripts/setup-bt/info.json @@ -2,7 +2,7 @@ "title": "SRS音视频服务器", "name": "srs_stack", "ps": "直播和WebRTC音视频能力,支持RTMP、WebRTC、HLS、HTTP-FLV、SRT、MPEG-DASH和GB28181等常用协议", - "versions": "5.8.28", + "versions": "5.8.30", "checks": "/www/server/panel/plugin/srs_stack", "author": "Winlin", "home": "https://github.com/ossrs/srs-stack"