0.2.57 - Traliers bug fixes
This commit is contained in:
@@ -3,6 +3,7 @@ package api
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"net"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
@@ -173,7 +174,8 @@ func isPlaybackItemPath(path string) bool {
|
||||
// Fetching a subtitle is two segments deep rather than one, and matching its trailing
|
||||
// "search" on its own would claim any future per-item search as playback. A seek
|
||||
// preview is the same shape: the frame number is the last segment, not the word.
|
||||
if strings.Contains(path, "/subtitles/") || strings.Contains(path, "/trickplay") {
|
||||
if strings.Contains(path, "/subtitles/") || strings.Contains(path, "/trickplay") ||
|
||||
strings.Contains(path, "/trailers") {
|
||||
return true
|
||||
}
|
||||
switch path[strings.LastIndex(path, "/")+1:] {
|
||||
@@ -182,3 +184,28 @@ func isPlaybackItemPath(path string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// requestClientIP is the viewer-facing address recorded for trailer playback. The first
|
||||
// Forwarded address is the original client when the gateway is behind its normal reverse
|
||||
// proxy; direct deployments fall back to RemoteAddr. This value is for operational logs,
|
||||
// never authentication or access control.
|
||||
func requestClientIP(r *http.Request) string {
|
||||
for _, value := range strings.Split(r.Header.Get("X-Forwarded-For"), ",") {
|
||||
if ip := net.ParseIP(strings.TrimSpace(value)); ip != nil {
|
||||
return ip.String()
|
||||
}
|
||||
}
|
||||
if ip := net.ParseIP(strings.TrimSpace(r.Header.Get("X-Real-IP"))); ip != nil {
|
||||
return ip.String()
|
||||
}
|
||||
host, _, err := net.SplitHostPort(strings.TrimSpace(r.RemoteAddr))
|
||||
if err == nil {
|
||||
if ip := net.ParseIP(host); ip != nil {
|
||||
return ip.String()
|
||||
}
|
||||
}
|
||||
if ip := net.ParseIP(strings.TrimSpace(r.RemoteAddr)); ip != nil {
|
||||
return ip.String()
|
||||
}
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user