Merge branch 'main' into feature/shuffle
This commit is contained in:
+19
-7
@@ -16,11 +16,12 @@ const (
|
||||
)
|
||||
|
||||
type ServerConnection struct {
|
||||
ServerType ServerType
|
||||
Hostname string
|
||||
AltHostname string
|
||||
Username string
|
||||
LegacyAuth bool
|
||||
ServerType ServerType
|
||||
Hostname string
|
||||
AltHostname string
|
||||
Username string
|
||||
LegacyAuth bool
|
||||
SkipSSLVerify bool
|
||||
}
|
||||
|
||||
type ServerConfig struct {
|
||||
@@ -50,7 +51,7 @@ type AppConfig struct {
|
||||
EnableLrcLib bool
|
||||
CustomLrcLibUrl string
|
||||
EnablePasswordStorage bool
|
||||
SkipSSLVerify bool
|
||||
SkipSSLVerify bool // Deprecated: use per-server SkipSSLVerify. Drop in future version.
|
||||
EnqueueBatchSize int
|
||||
Language string
|
||||
DisableDPIDetection bool
|
||||
@@ -212,7 +213,6 @@ func DefaultConfig(appVersionTag string) *Config {
|
||||
ShowTrackChangeNotification: false,
|
||||
EnableLrcLib: true,
|
||||
EnablePasswordStorage: true,
|
||||
SkipSSLVerify: false,
|
||||
EnqueueBatchSize: 100,
|
||||
Language: "auto",
|
||||
EnableAutoUpdateChecker: true,
|
||||
@@ -311,6 +311,7 @@ func ReadConfigFile(filepath, appVersionTag string) (*Config, error) {
|
||||
if err := toml.NewDecoder(f).Decode(c); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.migrateDeprecatedSettings()
|
||||
|
||||
// Backfill Subsonic to empty ServerType fields
|
||||
// for updating configs created before multiple MediaProviders were added
|
||||
@@ -331,6 +332,8 @@ func (c *Config) WriteConfigFile(filepath string) error {
|
||||
}
|
||||
defer writeLock.Unlock()
|
||||
|
||||
// clear deprecated global SkipSSLVerify after migrating to per-server settings
|
||||
c.Application.SkipSSLVerify = false
|
||||
b, err := toml.Marshal(c)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -339,3 +342,12 @@ func (c *Config) WriteConfigFile(filepath string) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Config) migrateDeprecatedSettings() {
|
||||
// Migrate deprecated global SkipSSLVerify to per-server settings
|
||||
if c.Application.SkipSSLVerify {
|
||||
for _, s := range c.Servers {
|
||||
s.SkipSSLVerify = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ func (s *ServerManager) connect(connection ServerConnection, password string) (m
|
||||
log.Printf("error creating Jellyfin client: %s", err.Error())
|
||||
return nil, err
|
||||
}
|
||||
s.checkSetInsecureSkipVerify(client.HTTPClient)
|
||||
s.checkSetInsecureSkipVerify(connection.SkipSSLVerify, client.HTTPClient)
|
||||
cli = &jellyfinMP.JellyfinServer{
|
||||
Client: *client,
|
||||
}
|
||||
@@ -196,7 +196,7 @@ func (s *ServerManager) connect(connection ServerConnection, password string) (m
|
||||
log.Printf("error creating Jellyfin alternative client: %s", err.Error())
|
||||
return nil, err
|
||||
}
|
||||
s.checkSetInsecureSkipVerify(altClient.HTTPClient)
|
||||
s.checkSetInsecureSkipVerify(connection.SkipSSLVerify, altClient.HTTPClient)
|
||||
altCli = &jellyfinMP.JellyfinServer{
|
||||
Client: *altClient,
|
||||
}
|
||||
@@ -213,7 +213,7 @@ func (s *ServerManager) connect(connection ServerConnection, password string) (m
|
||||
ClientName: res.AppName,
|
||||
},
|
||||
}
|
||||
s.checkSetInsecureSkipVerify(cli.(*subsonicMP.SubsonicServer).Client.Client)
|
||||
s.checkSetInsecureSkipVerify(connection.SkipSSLVerify, cli.(*subsonicMP.SubsonicServer).Client.Client)
|
||||
altCli = &subsonicMP.SubsonicServer{
|
||||
Client: subsonic.Client{
|
||||
UserAgent: ua,
|
||||
@@ -224,7 +224,7 @@ func (s *ServerManager) connect(connection ServerConnection, password string) (m
|
||||
ClientName: res.AppName,
|
||||
},
|
||||
}
|
||||
s.checkSetInsecureSkipVerify(altCli.(*subsonicMP.SubsonicServer).Client.Client)
|
||||
s.checkSetInsecureSkipVerify(connection.SkipSSLVerify, altCli.(*subsonicMP.SubsonicServer).Client.Client)
|
||||
}
|
||||
var authError error
|
||||
pingChan := make(chan bool, 2) // false for primary hostname, true for alternate
|
||||
@@ -255,8 +255,8 @@ func (s *ServerManager) connect(connection ServerConnection, password string) (m
|
||||
}
|
||||
}
|
||||
|
||||
func (s *ServerManager) checkSetInsecureSkipVerify(cli *http.Client) {
|
||||
if s.config.Application.SkipSSLVerify {
|
||||
func (s *ServerManager) checkSetInsecureSkipVerify(skip bool, cli *http.Client) {
|
||||
if skip {
|
||||
cli.Transport = &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user