From d39796a9760a160a37bcb9bfe4c0e0e9e5ff619b Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Jacquier Date: Thu, 7 Nov 2019 14:31:01 +0100 Subject: [PATCH] Fix gin panic on duplicate endpoint in m3u playlist (#21) --- pkg/routes/routes.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/routes/routes.go b/pkg/routes/routes.go index c217b828..59896a35 100644 --- a/pkg/routes/routes.go +++ b/pkg/routes/routes.go @@ -84,6 +84,7 @@ func Routes(proxyConfig *config.ProxyConfig, r *gin.RouterGroup) { } p.newM3U = newM3U + checkList := map[string]int8{} for i, track := range proxyConfig.Playlist.Tracks { oriURL, err := url.Parse(track.URI) if err != nil { @@ -94,7 +95,15 @@ func Routes(proxyConfig *config.ProxyConfig, r *gin.RouterGroup) { &proxyConfig.Playlist.Tracks[i], nil, } + _, ok := checkList[oriURL.Path] + if ok { + log.Printf("[iptv-proxy] WARNING endpoint %q already exist, skipping it", oriURL.Path) + continue + } + r.GET(oriURL.Path, p.authenticate, tmp.reverseProxy) + + checkList[oriURL.Path] = 0 } }