Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
2a708c8d1a | |||
88d550f947 | |||
af068f70e8 | |||
b83f2df025 |
@ -4,7 +4,7 @@ a little container to fix [this bug](https://github.com/jellyfin/jellyfin/issues
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
it can take a config file as first argument.
|
it can take a config file as first argument. if `external_url` is not defined, the JSON response wont include it at all!
|
||||||
|
|
||||||
## config example
|
## config example
|
||||||
|
|
||||||
@ -41,8 +41,8 @@ it can take a config file as first argument.
|
|||||||
networks:
|
networks:
|
||||||
- nginx_backend
|
- nginx_backend
|
||||||
environment:
|
environment:
|
||||||
JELLYFIXER_INTERNAL_URL: http://jellycontainer:8096
|
- JELLYFIXER_INTERNAL_URL=http://jellycontainer:8096
|
||||||
JELLYFIXER_EXTERNAL_URL: https://jellyfin.foo.tld
|
- JELLYFIXER_EXTERNAL_URL=https://jellyfin.foo.tld
|
||||||
labels:
|
labels:
|
||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
- "traefik.http.routers.jellyfixer-secured.rule=Host(`jellyfin.foo.tld`) && Path(`/System/Info/Public`)"
|
- "traefik.http.routers.jellyfixer-secured.rule=Host(`jellyfin.foo.tld`) && Path(`/System/Info/Public`)"
|
||||||
|
40
main.go
40
main.go
@ -24,15 +24,16 @@ type Logic struct {
|
|||||||
|
|
||||||
// PublicInfo Chromecast configuration Payload.
|
// PublicInfo Chromecast configuration Payload.
|
||||||
type PublicInfo struct {
|
type PublicInfo struct {
|
||||||
ID string
|
LocalAddress string `json:"LocalAddress,omitempty"`
|
||||||
LocalAddress string
|
ServerName string `json:"ServerName"`
|
||||||
OperatingSystem string
|
Version string `json:"Version"`
|
||||||
ProductName string
|
ProductName string `json:"ProductName"`
|
||||||
ServerName string
|
OperatingSystem string `json:"OperatingSystem"`
|
||||||
StartupWizardCompleted bool
|
ID string `json:"Id"`
|
||||||
Version string
|
StartupWizardCompleted bool `json:"StartupWizardCompleted"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nolint:funlen
|
||||||
func (l Logic) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (l Logic) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
logger := logginghandler.Logger(r)
|
logger := logginghandler.Logger(r)
|
||||||
|
|
||||||
@ -64,7 +65,10 @@ func (l Logic) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.Debug().Str("body", string(body)).Msg("read body")
|
||||||
|
|
||||||
var jd PublicInfo
|
var jd PublicInfo
|
||||||
|
|
||||||
if err := json.Unmarshal(body, &jd); err != nil {
|
if err := json.Unmarshal(body, &jd); err != nil {
|
||||||
logger.Error().Msg(err.Error())
|
logger.Error().Msg(err.Error())
|
||||||
http.Error(w, "could not unmarshal body", http.StatusInternalServerError)
|
http.Error(w, "could not unmarshal body", http.StatusInternalServerError)
|
||||||
@ -72,9 +76,21 @@ func (l Logic) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
jd.LocalAddress = l.ExternalURL
|
var nd PublicInfo
|
||||||
|
|
||||||
nd, err := json.Marshal(jd)
|
nd.ServerName = jd.ServerName
|
||||||
|
nd.Version = jd.Version
|
||||||
|
nd.ProductName = jd.ProductName
|
||||||
|
nd.OperatingSystem = jd.OperatingSystem
|
||||||
|
nd.ID = jd.ID
|
||||||
|
nd.StartupWizardCompleted = jd.StartupWizardCompleted
|
||||||
|
|
||||||
|
// When there is no external url defined, it wont include it in the response.
|
||||||
|
if l.ExternalURL != "" {
|
||||||
|
nd.LocalAddress = l.ExternalURL
|
||||||
|
}
|
||||||
|
|
||||||
|
bd, err := json.Marshal(nd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error().Msg(err.Error())
|
logger.Error().Msg(err.Error())
|
||||||
http.Error(w, "could not marshal body", http.StatusInternalServerError)
|
http.Error(w, "could not marshal body", http.StatusInternalServerError)
|
||||||
@ -82,7 +98,7 @@ func (l Logic) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := w.Write(nd); err != nil {
|
if _, err := w.Write(bd); err != nil {
|
||||||
logger.Error().Msg(err.Error())
|
logger.Error().Msg(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,10 +127,6 @@ func main() {
|
|||||||
log.Fatal().Msg("needs key 'internal_url'")
|
log.Fatal().Msg("needs key 'internal_url'")
|
||||||
}
|
}
|
||||||
|
|
||||||
if viper.GetString("external_url") == "" {
|
|
||||||
log.Fatal().Msg("needs key 'external_url'")
|
|
||||||
}
|
|
||||||
|
|
||||||
l := Logic{
|
l := Logic{
|
||||||
InternalURL: viper.GetString("internal_url"),
|
InternalURL: viper.GetString("internal_url"),
|
||||||
ExternalURL: viper.GetString("external_url"),
|
ExternalURL: viper.GetString("external_url"),
|
||||||
|
Loading…
Reference in New Issue
Block a user