drop broken proxy setting and rely on ENV['http_proxy'] instead

fixes #118
fixes #119
This commit is contained in:
Henrik Friedrichsen
2020-02-05 21:50:46 +01:00
parent d9356e445e
commit 90d19b1b2d
3 changed files with 10 additions and 4 deletions

View File

@@ -109,10 +109,12 @@ the search view.
Configuration is saved to `~/.config/ncspot/config.toml`. Possible configuration
values are:
* `proxy`: Set an HTTP proxy
* `use_nerdfont`: Turn nerdfont glyphs on/off <true/false>
* `theme`: Set a custom color palette (see below)
ncspot will respect system proxy settings defined via the `http_proxy`
environment variable.
### Theming
The color palette can be modified in the configuration. For instance, to have

View File

@@ -13,7 +13,6 @@ pub struct Config {
pub keybindings: Option<HashMap<String, String>>,
pub theme: Option<ConfigTheme>,
pub use_nerdfont: Option<bool>,
pub proxy: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone)]

View File

@@ -37,6 +37,7 @@ use tokio_core::reactor::Core;
use tokio_timer;
use url::Url;
use std::env;
use std::sync::atomic::{AtomicU16, Ordering};
use std::sync::RwLock;
use std::thread;
@@ -246,8 +247,12 @@ impl Spotify {
pub fn session_config(cfg: &Config) -> SessionConfig {
let mut session_config = SessionConfig::default();
if let Some(ref proxy) = cfg.proxy {
session_config.proxy = Url::parse(&proxy).ok();
match env::var("http_proxy") {
Ok(proxy) => {
info!("Setting HTTP proxy {}", proxy);
session_config.proxy = Url::parse(&proxy).ok();
}
Err(_) => debug!("No HTTP proxy set"),
}
session_config
}