Skip to content

Commit

Permalink
Implement #88. SSL support with a flag. Defaults to false if the flag…
Browse files Browse the repository at this point in the history
… isn't set.
  • Loading branch information
aetaric committed Jan 11, 2024
1 parent fe68834 commit c7d51b1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
5 changes: 5 additions & 0 deletions checkrr.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ arr:
apikey: ""
baseurl: /
port: 7878
ssl: false
mappings: # maps directories between docker and arr services
"/mnt/user/Movies/": "/Movies/" # what radarr sees: what checkrr sees
radarr-4k:
Expand All @@ -42,6 +43,7 @@ arr:
apikey: ""
baseurl: /
port: 7979
ssl: true
mappings:
"/mnt/user/Movies-4k/": "/Movies-4k/"
sonarr:
Expand All @@ -51,6 +53,7 @@ arr:
apikey: ""
baseurl: /
port: 8989
ssl: false
mappings:
"/mnt/user/tv/": "/tv/"
anime:
Expand All @@ -60,6 +63,7 @@ arr:
apikey: ""
baseurl: /
port: 8888
ssl: false
mappings:
"/mnt/user/anime/": "/anime/"
lidarr:
Expand All @@ -69,6 +73,7 @@ arr:
apikey: ""
baseurl: /
port: 8686
ssl: false
mappings:
"/mnt/user/Music/": "/Music"
notifications:
Expand Down
8 changes: 7 additions & 1 deletion connections/lidarr.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Lidarr struct {
Address string
Port int
BaseURL string
SSL bool
pathMaps map[string]string
}

Expand All @@ -29,6 +30,7 @@ func (l *Lidarr) FromConfig(conf *viper.Viper) {
l.Port = conf.GetInt("port")
l.BaseURL = conf.GetString("baseurl")
l.pathMaps = conf.GetStringMapString("mappings")
l.SSL = conf.GetBool("ssl")
log.Debugf("Lidarr Path Maps: %v", l.pathMaps)
} else {
l.Process = false
Expand Down Expand Up @@ -87,7 +89,11 @@ func (l *Lidarr) RemoveFile(path string) bool {
func (l *Lidarr) Connect() (bool, string) {
if l.Process {
if l.ApiKey != "" {
l.config = starr.New(l.ApiKey, fmt.Sprintf("http://%s:%v%v", l.Address, l.Port, l.BaseURL), 0)
protocol := "http"
if l.SSL {
protocol = "https"
}
l.config = starr.New(l.ApiKey, fmt.Sprintf("%s://%s:%v%v", protocol, l.Address, l.Port, l.BaseURL), 0)
l.server = lidarr.New(l.config)
status, err := l.server.GetSystemStatus()
if err != nil {
Expand Down
8 changes: 7 additions & 1 deletion connections/radarr.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Radarr struct {
Address string
Port int
BaseURL string
SSL bool
pathMaps map[string]string
}

Expand All @@ -29,6 +30,7 @@ func (r *Radarr) FromConfig(conf *viper.Viper) {
r.Port = conf.GetInt("port")
r.BaseURL = conf.GetString("baseurl")
r.pathMaps = conf.GetStringMapString("mappings")
r.SSL = conf.GetBool("ssl")
log.Debugf("Radarr Path Maps: %v", r.pathMaps)
} else {
r.Process = false
Expand Down Expand Up @@ -66,7 +68,11 @@ func (r *Radarr) RemoveFile(path string) bool {
func (r *Radarr) Connect() (bool, string) {
if r.Process {
if r.ApiKey != "" {
r.config = starr.New(r.ApiKey, fmt.Sprintf("http://%s:%v%v", r.Address, r.Port, r.BaseURL), 0)
protocol := "http"
if r.SSL {
protocol = "https"
}
r.config = starr.New(r.ApiKey, fmt.Sprintf("%s://%s:%v%v", protocol, r.Address, r.Port, r.BaseURL), 0)
r.server = radarr.New(r.config)
status, err := r.server.GetSystemStatus()
if err != nil {
Expand Down
8 changes: 7 additions & 1 deletion connections/sonarr.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Sonarr struct {
Address string
Port int
BaseURL string
SSL bool
pathMaps map[string]string
}

Expand All @@ -29,6 +30,7 @@ func (s *Sonarr) FromConfig(conf *viper.Viper) {
s.Port = conf.GetInt("port")
s.BaseURL = conf.GetString("baseurl")
s.pathMaps = conf.GetStringMapString("mappings")
s.SSL = conf.GetBool("ssl")
log.Debugf("Sonarr Path Maps: %v", s.pathMaps)
} else {
s.Process = false
Expand Down Expand Up @@ -69,7 +71,11 @@ func (s *Sonarr) RemoveFile(path string) bool {
func (s *Sonarr) Connect() (bool, string) {
if s.Process {
if s.ApiKey != "" {
s.config = starr.New(s.ApiKey, fmt.Sprintf("http://%s:%v%v", s.Address, s.Port, s.BaseURL), 0)
protocol := "http"
if s.SSL {
protocol = "https"
}
s.config = starr.New(s.ApiKey, fmt.Sprintf("%s://%s:%v%v", protocol, s.Address, s.Port, s.BaseURL), 0)
s.server = sonarr.New(s.config)
status, err := s.server.GetSystemStatus()
if err != nil {
Expand Down

0 comments on commit c7d51b1

Please sign in to comment.