Skip to content

Commit

Permalink
Fix gin panic on duplicate endpoint in m3u playlist (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-emmanuelJ authored Nov 7, 2019
1 parent d85ffb6 commit d39796a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
}

Expand Down

0 comments on commit d39796a

Please sign in to comment.