diff --git a/backend/config.go b/backend/config.go index 139c497..d02679f 100644 --- a/backend/config.go +++ b/backend/config.go @@ -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 + } + } +} diff --git a/backend/servermanager.go b/backend/servermanager.go index e37c8d0..77b617c 100644 --- a/backend/servermanager.go +++ b/backend/servermanager.go @@ -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}, } diff --git a/ui/controller/serverconnection.go b/ui/controller/serverconnection.go index 3699efc..6d4b68e 100644 --- a/ui/controller/serverconnection.go +++ b/ui/controller/serverconnection.go @@ -27,11 +27,12 @@ func (m *Controller) PromptForFirstServer() { m.doModalClosed() }) conn := backend.ServerConnection{ - ServerType: d.ServerType, - Hostname: d.Host, - AltHostname: d.AltHost, - Username: d.Username, - LegacyAuth: d.LegacyAuth, + ServerType: d.ServerType, + Hostname: d.Host, + AltHostname: d.AltHost, + Username: d.Username, + LegacyAuth: d.LegacyAuth, + SkipSSLVerify: d.SkipSSLVerify, } server := m.App.ServerManager.AddServer(d.Nickname, conn) if err := m.trySetPasswordAndConnectToServer(server, d.Password); err != nil { @@ -138,6 +139,7 @@ func (m *Controller) PromptForLoginAndConnect() { server.Nickname = editD.Nickname server.Username = editD.Username server.LegacyAuth = editD.LegacyAuth + server.SkipSSLVerify = editD.SkipSSLVerify m.trySetPasswordAndConnectToServer(server, editD.Password) m.doModalClosed() } @@ -164,11 +166,12 @@ func (m *Controller) PromptForLoginAndConnect() { // connection is good newPop.Hide() conn := backend.ServerConnection{ - ServerType: newD.ServerType, - Hostname: newD.Host, - AltHostname: newD.AltHost, - Username: newD.Username, - LegacyAuth: newD.LegacyAuth, + ServerType: newD.ServerType, + Hostname: newD.Host, + AltHostname: newD.AltHost, + Username: newD.Username, + LegacyAuth: newD.LegacyAuth, + SkipSSLVerify: newD.SkipSSLVerify, } server := m.App.ServerManager.AddServer(newD.Nickname, conn) m.trySetPasswordAndConnectToServer(server, newD.Password) @@ -233,11 +236,12 @@ func (c *Controller) tryConnectToServer(ctx context.Context, server *backend.Ser func (c *Controller) testConnectionAndUpdateDialogText(dlg *dialogs.AddEditServerDialog) bool { fyne.Do(func() { dlg.SetInfoText(lang.L("Testing connection") + "...") }) conn := backend.ServerConnection{ - ServerType: dlg.ServerType, - Hostname: dlg.Host, - AltHostname: dlg.AltHost, - Username: dlg.Username, - LegacyAuth: dlg.LegacyAuth, + ServerType: dlg.ServerType, + Hostname: dlg.Host, + AltHostname: dlg.AltHost, + Username: dlg.Username, + LegacyAuth: dlg.LegacyAuth, + SkipSSLVerify: dlg.SkipSSLVerify, } ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() diff --git a/ui/dialogs/addeditserverdialog.go b/ui/dialogs/addeditserverdialog.go index ee99845..0574c55 100644 --- a/ui/dialogs/addeditserverdialog.go +++ b/ui/dialogs/addeditserverdialog.go @@ -17,15 +17,16 @@ import ( type AddEditServerDialog struct { widget.BaseWidget - ServerType backend.ServerType - Nickname string - Host string - AltHost string - Username string - Password string - LegacyAuth bool - OnSubmit func() - OnCancel func() + ServerType backend.ServerType + Nickname string + Host string + AltHost string + Username string + Password string + LegacyAuth bool + SkipSSLVerify bool + OnSubmit func() + OnCancel func() passField *widget.Entry submitBtn *widget.Button @@ -45,6 +46,7 @@ func NewAddEditServerDialog(title string, cancelable bool, prefillServer *backen a.AltHost = prefillServer.AltHostname a.Username = prefillServer.Username a.LegacyAuth = prefillServer.LegacyAuth + a.SkipSSLVerify = prefillServer.SkipSSLVerify } titleLabel := widget.NewLabel(title) @@ -58,6 +60,7 @@ func NewAddEditServerDialog(title string, cancelable bool, prefillServer *backen legacyAuthCheck.Hide() } }) + skipSSLCheck := widget.NewCheckWithData(lang.L("Skip SSL certificate verification"), binding.BindBool(&a.SkipSSLVerify)) serverTypeChoice.Required = true serverTypeChoice.Horizontal = true selected := backend.ServerTypeSubsonic @@ -113,7 +116,7 @@ func NewAddEditServerDialog(title string, cancelable bool, prefillServer *backen widget.NewLabel(lang.L("Password")), a.passField, ), - container.NewHBox(layout.NewSpacer(), legacyAuthCheck), + container.NewHBox(layout.NewSpacer(), legacyAuthCheck, skipSSLCheck), widget.NewSeparator(), bottomRow, ) diff --git a/ui/dialogs/settingsdialog.go b/ui/dialogs/settingsdialog.go index 9173289..8c65e20 100644 --- a/ui/dialogs/settingsdialog.go +++ b/ui/dialogs/settingsdialog.go @@ -617,7 +617,6 @@ func (s *SettingsDialog) createAppearanceTab(window fyne.Window) *container.TabI func (s *SettingsDialog) createAdvancedTab() *container.TabItem { multi := widget.NewCheckWithData(lang.L("Allow multiple app instances"), binding.BindBool(&s.config.Application.AllowMultiInstance)) - sslSkip := widget.NewCheckWithData(lang.L("Skip SSL certificate verification"), binding.BindBool(&s.config.Application.SkipSSLVerify)) update := widget.NewCheckWithData(lang.L("Automatically check for updates"), binding.BindBool(&s.config.Application.EnableAutoUpdateChecker)) lrclib := widget.NewCheckWithData(lang.L("Enable LrcLib lyrics fetcher"), binding.BindBool(&s.config.Application.EnableLrcLib)) @@ -659,7 +658,6 @@ func (s *SettingsDialog) createAdvancedTab() *container.TabItem { return container.NewTabItem(lang.L("Advanced"), container.NewVBox( multi, - sslSkip, update, lrclib, osMediaAPIs,