Applied clippy fixes

This commit is contained in:
AB
2025-12-01 01:48:36 +02:00
parent 1249d15aad
commit 1a4a296fae
15 changed files with 78 additions and 85 deletions

View File

@@ -7,25 +7,19 @@ pub struct InboundGenerationOptions {
pub fn generate_inbound_config(options: InboundGenerationOptions) -> Vec<config_models::Inbound> {
let mut inbounds: Vec<config_models::Inbound> = vec![];
match options.socks_port {
Some(port) => {
inbounds.push(generate_socks_inbound(port));
}
None => {}
if let Some(port) = options.socks_port {
inbounds.push(generate_socks_inbound(port));
}
match options.http_port {
Some(port) => {
inbounds.push(generate_http_inbound(port));
}
None => {}
if let Some(port) = options.http_port {
inbounds.push(generate_http_inbound(port));
}
return inbounds;
inbounds
}
pub fn generate_http_inbound(http_port: u16) -> config_models::Inbound {
return config_models::Inbound {
config_models::Inbound {
protocol: String::from("http"),
port: http_port,
tag: String::from("http-in"),
@@ -42,11 +36,11 @@ pub fn generate_http_inbound(http_port: u16) -> config_models::Inbound {
String::from("quic"),
]),
}),
};
}
}
pub fn generate_socks_inbound(socks_port: u16) -> config_models::Inbound {
return config_models::Inbound {
config_models::Inbound {
protocol: String::from("socks"),
port: socks_port,
tag: String::from("socks-in"),
@@ -63,5 +57,5 @@ pub fn generate_socks_inbound(socks_port: u16) -> config_models::Inbound {
String::from("quic"),
]),
}),
};
}
}

View File

@@ -1,17 +1,17 @@
pub mod inbound_generator;
pub fn url_decode_str(value: &str) -> Option<String> {
return urlencoding::decode(value)
urlencoding::decode(value)
.ok()
.map(|decoded| decoded.into_owned());
.map(|decoded| decoded.into_owned())
}
pub fn url_decode(value: Option<String>) -> Option<String> {
return value.and_then(|s| {
value.and_then(|s| {
urlencoding::decode(&s)
.ok()
.map(|decoded| decoded.into_owned())
});
})
}
pub fn parse_raw_json(input: &str) -> Option<serde_json::Value> {
@@ -24,8 +24,8 @@ pub fn parse_raw_json(input: &str) -> Option<serde_json::Value> {
}
pub fn get_parameter_value(query: &Vec<(&str, &str)>, param: &str) -> Option<String> {
return query
query
.iter()
.find(|q| String::from(q.0) == String::from(param))
.map(|q| q.1.to_string());
.find(|q| q.0 == param)
.map(|q| q.1.to_string())
}