diff --git a/Cargo.lock b/Cargo.lock index e64ac0b8..b146568f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1668,6 +1668,16 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "sys-info" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b3a0d0aba8bf96a0e1ddfdc352fc53b3df7f39318c71854910c3c4b024ae52c" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "tar" version = "0.4.37" @@ -1843,6 +1853,7 @@ dependencies = [ "shellexpand", "structopt", "strum 0.22.0", + "sys-info", "tempfile", "thiserror", "tokio", diff --git a/Cargo.toml b/Cargo.toml index c5a7b85a..8a1243c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,7 @@ cfg-if = "1.0.0" tokio = { version = "1.5.0", features = ["process", "rt-multi-thread"] } futures = "0.3.14" regex = "1.5.3" +sys-info = "0.9" [target.'cfg(target_os = "macos")'.dependencies] notify-rust = "4.5.0" diff --git a/src/config.rs b/src/config.rs index 7bc48762..3185375a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,19 +1,22 @@ -use super::utils::editor; +use std::collections::BTreeMap; +use std::fs::write; +use std::path::PathBuf; +use std::process::Command; +use std::{env, fs}; + use anyhow::Result; use directories::BaseDirs; use log::{debug, LevelFilter}; use pretty_env_logger::formatted_timed_builder; use regex::Regex; use serde::Deserialize; -use std::collections::BTreeMap; -use std::fs::write; -use std::path::PathBuf; -use std::process::Command; -use std::{env, fs}; use structopt::StructOpt; use strum::{EnumIter, EnumString, EnumVariantNames, IntoEnumIterator, VariantNames}; +use sys_info::hostname; use which_crate::which; +use super::utils::editor; + pub static EXAMPLE_CONFIG: &str = include_str!("../config.example.toml"); #[allow(unused_macros)] @@ -826,10 +829,16 @@ impl Config { str_value!(linux, emerge_update_flags); pub fn should_execute_remote(&self, remote: &str) -> bool { - self.opt - .remote_host_limit - .as_ref() - .map(|h| h.is_match(remote)) - .unwrap_or(true) + if let Ok(hostname) = hostname() { + if remote == hostname { + return false; + } + } + + if let Some(limit) = self.opt.remote_host_limit.as_ref() { + return limit.is_match(remote); + } + + true } }