Skip to content

Commit

Permalink
fix: resolve invalid port override
Browse files Browse the repository at this point in the history
  • Loading branch information
tekulvw committed Jan 16, 2025
1 parent dba01a7 commit 2b5683e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions internal/arr/config/xml_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func (p *XML) Marshal(o map[string]interface{}) ([]byte, error) {

func (p *XML) Merge(baseURL string) func(src, dest map[string]interface{}) error {
return func(src, dest map[string]interface{}) error {

if src["api-key"] != nil && src["api-key"].(string) != "" {
dest["api-key"] = src["api-key"]
}
Expand All @@ -50,7 +49,18 @@ func (p *XML) Merge(baseURL string) func(src, dest map[string]interface{}) error
}

// Add or replace target port
u.Host = u.Hostname() + ":" + src["target-port"].(string)
target_port := src["target-port"].(string)
if len(target_port) > 0 {
// AKA Port is defined in the config xml so we use this value as the source
// of truth.
u.Host = u.Hostname() + ":" + target_port

// If Port is NOT defined in the XML it may be configured by the
// *ARR__SERVER__PORT environment varible passed directly to *arr services.
// In this case, we do not want to override whatever URL (that may include
// the port) passed to exportarr by other means.
}

u = u.JoinPath(src["url-base"].(string))
dest["url"] = u.String()
return nil
Expand Down

0 comments on commit 2b5683e

Please sign in to comment.