Merge branch 'sentriz:master' into ldap_auth
This commit is contained in:
No files matched your search
+12
-17
@@ -10,6 +10,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/pprof"
|
"net/http/pprof"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path"
|
"path"
|
||||||
@@ -263,7 +264,9 @@ func main() {
|
|||||||
scrobblers := []scrobble.Scrobbler{lastfmClient, listenbrainzClient}
|
scrobblers := []scrobble.Scrobbler{lastfmClient, listenbrainzClient}
|
||||||
|
|
||||||
resolveProxyPath := func(in string) string {
|
resolveProxyPath := func(in string) string {
|
||||||
return path.Join(*confProxyPrefix, in)
|
url, _ := url.Parse(in)
|
||||||
|
url.Path = path.Join(*confProxyPrefix, url.Path)
|
||||||
|
return url.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
ctrlAdmin, err := ctrladmin.New(dbc, sessDB, scannr, podcast, lastfmClient, resolveProxyPath, ldapConfig)
|
ctrlAdmin, err := ctrladmin.New(dbc, sessDB, scannr, podcast, lastfmClient, resolveProxyPath, ldapConfig)
|
||||||
@@ -317,7 +320,9 @@ func main() {
|
|||||||
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
|
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
|
||||||
}
|
}
|
||||||
|
|
||||||
errgrp, ctx := errgroup.WithContext(context.Background())
|
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
defer cancel()
|
||||||
|
errgrp, ctx := errgroup.WithContext(ctx)
|
||||||
|
|
||||||
errgrp.Go(func() error {
|
errgrp.Go(func() error {
|
||||||
defer logJob("http")()
|
defer logJob("http")()
|
||||||
@@ -334,7 +339,10 @@ func main() {
|
|||||||
if *confTLSCert != "" && *confTLSKey != "" {
|
if *confTLSCert != "" && *confTLSKey != "" {
|
||||||
return server.ListenAndServeTLS(*confTLSCert, *confTLSKey)
|
return server.ListenAndServeTLS(*confTLSCert, *confTLSKey)
|
||||||
}
|
}
|
||||||
return server.ListenAndServe()
|
if err := server.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
errgrp.Go(func() error {
|
errgrp.Go(func() error {
|
||||||
@@ -458,20 +466,7 @@ func main() {
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
errShutdown := errors.New("shutdown")
|
if err := errgrp.Wait(); err != nil {
|
||||||
|
|
||||||
errgrp.Go(func() error {
|
|
||||||
sigChan := make(chan os.Signal, 1)
|
|
||||||
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
|
|
||||||
select {
|
|
||||||
case <-ctx.Done():
|
|
||||||
return nil
|
|
||||||
case <-sigChan:
|
|
||||||
return errShutdown
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if err := errgrp.Wait(); err != nil && !errors.Is(err, errShutdown) {
|
|
||||||
log.Panic(err)
|
log.Panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -291,7 +291,11 @@ func (c *Client) GetCurrentUser(user *db.User) (User, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) makeRequest(method string, params url.Values) (LastFM, error) {
|
func (c *Client) makeRequest(method string, params url.Values) (LastFM, error) {
|
||||||
req, _ := http.NewRequest(method, BaseURL, nil)
|
req, err := http.NewRequest(method, BaseURL, nil)
|
||||||
|
if err != nil {
|
||||||
|
return LastFM{}, fmt.Errorf("create request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
req.URL.RawQuery = params.Encode()
|
req.URL.RawQuery = params.Encode()
|
||||||
|
|
||||||
resp, err := c.httpClient.Do(req)
|
resp, err := c.httpClient.Do(req)
|
||||||
|
|||||||
@@ -75,7 +75,11 @@ func (c *Client) Scrobble(user db.User, track scrobble.Track, stamp time.Time, s
|
|||||||
submitURL := fmt.Sprintf("%s%s", user.ListenBrainzURL, submitPath)
|
submitURL := fmt.Sprintf("%s%s", user.ListenBrainzURL, submitPath)
|
||||||
authHeader := fmt.Sprintf("Token %s", user.ListenBrainzToken)
|
authHeader := fmt.Sprintf("Token %s", user.ListenBrainzToken)
|
||||||
|
|
||||||
req, _ := http.NewRequest(http.MethodPost, submitURL, &payloadBuf)
|
req, err := http.NewRequest(http.MethodPost, submitURL, &payloadBuf)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("create submit request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
req.Header.Add("Content-Type", "application/json")
|
req.Header.Add("Content-Type", "application/json")
|
||||||
req.Header.Add("Authorization", authHeader)
|
req.Header.Add("Authorization", authHeader)
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
type TagLib struct{}
|
type TagLib struct{}
|
||||||
|
|
||||||
func (TagLib) CanRead(absPath string) bool {
|
func (TagLib) CanRead(absPath string) bool {
|
||||||
switch ext := filepath.Ext(absPath); ext {
|
switch ext := strings.ToLower(filepath.Ext(absPath)); ext {
|
||||||
case ".mp3", ".flac", ".aac", ".m4a", ".m4b", ".ogg", ".opus", ".wma", ".wav", ".wv":
|
case ".mp3", ".flac", ".aac", ".m4a", ".m4b", ".ogg", ".opus", ".wma", ".wav", ".wv":
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user