lint
This commit is contained in:
parent
677b29bedf
commit
2dd99130fa
14 changed files with 140 additions and 161 deletions
src/restrictions
|
@ -90,7 +90,7 @@ impl RestrictionsRulesReloader {
|
|||
self.restrictions = Arc::new(restrictions);
|
||||
}
|
||||
|
||||
pub fn restrictions_rules(&self) -> &Arc<RestrictionsRules> {
|
||||
pub const fn restrictions_rules(&self) -> &Arc<RestrictionsRules> {
|
||||
&self.restrictions
|
||||
}
|
||||
|
||||
|
|
|
@ -17,15 +17,12 @@ pub mod config_reloader;
|
|||
pub mod types;
|
||||
|
||||
impl RestrictionsRules {
|
||||
pub fn from_config_file(config_path: &Path) -> anyhow::Result<RestrictionsRules> {
|
||||
let restrictions: RestrictionsRules = serde_yaml::from_reader(BufReader::new(File::open(config_path)?))?;
|
||||
pub fn from_config_file(config_path: &Path) -> anyhow::Result<Self> {
|
||||
let restrictions: Self = serde_yaml::from_reader(BufReader::new(File::open(config_path)?))?;
|
||||
Ok(restrictions)
|
||||
}
|
||||
|
||||
pub fn from_path_prefix(
|
||||
path_prefixes: &[String],
|
||||
restrict_to: &[(String, u16)],
|
||||
) -> anyhow::Result<RestrictionsRules> {
|
||||
pub fn from_path_prefix(path_prefixes: &[String], restrict_to: &[(String, u16)]) -> anyhow::Result<Self> {
|
||||
let tunnels_restrictions = if restrict_to.is_empty() {
|
||||
let r = types::AllowConfig::Tunnel(types::AllowTunnelConfig {
|
||||
protocol: vec![],
|
||||
|
@ -108,6 +105,6 @@ impl RestrictionsRules {
|
|||
.collect::<Result<Vec<_>, anyhow::Error>>()?
|
||||
};
|
||||
|
||||
Ok(RestrictionsRules { restrictions })
|
||||
Ok(Self { restrictions })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,11 +160,11 @@ impl From<&LocalProtocol> for ReverseTunnelConfigProtocol {
|
|||
| LocalProtocol::Socks5 { .. }
|
||||
| LocalProtocol::TProxyTcp { .. }
|
||||
| LocalProtocol::TProxyUdp { .. }
|
||||
| LocalProtocol::Unix { .. } => ReverseTunnelConfigProtocol::Unknown,
|
||||
LocalProtocol::ReverseTcp => ReverseTunnelConfigProtocol::Tcp,
|
||||
LocalProtocol::ReverseUdp { .. } => ReverseTunnelConfigProtocol::Udp,
|
||||
LocalProtocol::ReverseSocks5 => ReverseTunnelConfigProtocol::Socks5,
|
||||
LocalProtocol::ReverseUnix { .. } => ReverseTunnelConfigProtocol::Unix,
|
||||
| LocalProtocol::Unix { .. } => Self::Unknown,
|
||||
LocalProtocol::ReverseTcp => Self::Tcp,
|
||||
LocalProtocol::ReverseUdp { .. } => Self::Udp,
|
||||
LocalProtocol::ReverseSocks5 => Self::Socks5,
|
||||
LocalProtocol::ReverseUnix { .. } => Self::Unix,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -179,9 +179,9 @@ impl From<&LocalProtocol> for TunnelConfigProtocol {
|
|||
| LocalProtocol::Socks5 { .. }
|
||||
| LocalProtocol::TProxyTcp { .. }
|
||||
| LocalProtocol::TProxyUdp { .. }
|
||||
| LocalProtocol::Unix { .. } => TunnelConfigProtocol::Unknown,
|
||||
LocalProtocol::Tcp { .. } => TunnelConfigProtocol::Tcp,
|
||||
LocalProtocol::Udp { .. } => TunnelConfigProtocol::Udp,
|
||||
| LocalProtocol::Unix { .. } => Self::Unknown,
|
||||
LocalProtocol::Tcp { .. } => Self::Tcp,
|
||||
LocalProtocol::Udp { .. } => Self::Udp,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue