improve code

This commit is contained in:
houseme
2025-05-27 19:07:09 +08:00
parent ade4d33eb1
commit a95138868e
38 changed files with 1388 additions and 1421 deletions
+3 -3
View File
@@ -174,9 +174,9 @@ async fn license_handler() -> impl IntoResponse {
.unwrap()
}
fn _is_private_ip(ip: std::net::IpAddr) -> bool {
fn _is_private_ip(ip: IpAddr) -> bool {
match ip {
std::net::IpAddr::V4(ip) => {
IpAddr::V4(ip) => {
let octets = ip.octets();
// 10.0.0.0/8
octets[0] == 10 ||
@@ -185,7 +185,7 @@ fn _is_private_ip(ip: std::net::IpAddr) -> bool {
// 192.168.0.0/16
(octets[0] == 192 && octets[1] == 168)
}
std::net::IpAddr::V6(_) => false,
IpAddr::V6(_) => false,
}
}
+3 -3
View File
@@ -34,7 +34,7 @@ pub fn get_license() -> Option<Token> {
#[allow(unreachable_code)]
pub fn license_check() -> Result<()> {
return Ok(());
let inval_license = LICENSE.get().map(|token| {
let invalid_license = LICENSE.get().map(|token| {
if token.expired < SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs() {
error!("License expired");
return Err(Error::from_string("Incorrect license, please contact RustFS.".to_string()));
@@ -43,7 +43,7 @@ pub fn license_check() -> Result<()> {
Ok(())
});
// let inval_license = config::get_config().license.as_ref().map(|license| {
// let invalid_license = config::get_config().license.as_ref().map(|license| {
// if license.is_empty() {
// error!("License is empty");
// return Err(Error::from_string("Incorrect license, please contact RustFS.".to_string()));
@@ -58,7 +58,7 @@ pub fn license_check() -> Result<()> {
// Ok(())
// });
if inval_license.is_none() || inval_license.is_some_and(|v| v.is_err()) {
if invalid_license.is_none() || invalid_license.is_some_and(|v| v.is_err()) {
return Err(Error::from_string("Incorrect license, please contact RustFS.".to_string()));
}