mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-17 02:15:28 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bf7b1c4533 |
@@ -38,7 +38,10 @@ pub const XXHASH_3_HEADER_NAME: &str = "x-amz-checksum-xxhash3";
|
|||||||
pub const XXHASH_64_HEADER_NAME: &str = "x-amz-checksum-xxhash64";
|
pub const XXHASH_64_HEADER_NAME: &str = "x-amz-checksum-xxhash64";
|
||||||
pub const XXHASH_128_HEADER_NAME: &str = "x-amz-checksum-xxhash128";
|
pub const XXHASH_128_HEADER_NAME: &str = "x-amz-checksum-xxhash128";
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(
|
||||||
|
dead_code,
|
||||||
|
reason = "Content-MD5 wire name, resolved by header_name() below and asserted by this crate's tests (backlog#1823)"
|
||||||
|
)]
|
||||||
pub(crate) static MD5_HEADER_NAME: &str = "content-md5";
|
pub(crate) static MD5_HEADER_NAME: &str = "content-md5";
|
||||||
|
|
||||||
pub const CHECKSUM_ALGORITHMS_IN_PRIORITY_ORDER: [&str; 5] =
|
pub const CHECKSUM_ALGORITHMS_IN_PRIORITY_ORDER: [&str; 5] =
|
||||||
|
|||||||
@@ -476,13 +476,19 @@ impl Checksum for Xxhash64 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
|
#[allow(
|
||||||
|
dead_code,
|
||||||
|
reason = "Content-MD5 is not a ChecksumAlgorithm variant and has no arm in into_impl: S3 carries it as its own header, separate from the x-amz-checksum-* family. This impl exists so the two paths share the Checksum trait, and is asserted by this crate's tests (backlog#1823)"
|
||||||
|
)]
|
||||||
struct Md5 {
|
struct Md5 {
|
||||||
hasher: md5::Md5,
|
hasher: md5::Md5,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(
|
||||||
|
dead_code,
|
||||||
|
reason = "Content-MD5 is not a ChecksumAlgorithm variant and has no arm in into_impl: S3 carries it as its own header, separate from the x-amz-checksum-* family. This impl exists so the two paths share the Checksum trait, and is asserted by this crate's tests (backlog#1823)"
|
||||||
|
)]
|
||||||
impl Md5 {
|
impl Md5 {
|
||||||
fn update(&mut self, bytes: &[u8]) {
|
fn update(&mut self, bytes: &[u8]) {
|
||||||
use md5::Digest;
|
use md5::Digest;
|
||||||
|
|||||||
@@ -487,21 +487,22 @@ pub fn record_get_object_completion(total_duration_secs: f64, response_size_byte
|
|||||||
|
|
||||||
/// Record the streaming strategy chosen for a GetObject response body.
|
/// Record the streaming strategy chosen for a GetObject response body.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn record_get_object_stream_strategy(strategy: &'static str, buffer_size_bytes: usize, response_size_bytes: i64) {
|
pub fn record_get_object_stream_strategy(strategy: &str, buffer_size_bytes: usize, response_size_bytes: i64) {
|
||||||
if !get_stage_metrics_enabled() {
|
if !get_stage_metrics_enabled() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
counter!("rustfs_io_get_object_stream_strategy_total", "strategy" => strategy).increment(1);
|
counter!("rustfs_io_get_object_stream_strategy_total", "strategy" => strategy.to_string()).increment(1);
|
||||||
histogram!("rustfs_io_get_object_stream_buffer_size_bytes", "strategy" => strategy).record(usize_to_f64(buffer_size_bytes));
|
histogram!("rustfs_io_get_object_stream_buffer_size_bytes", "strategy" => strategy.to_string())
|
||||||
histogram!("rustfs_io_get_object_stream_response_size_bytes", "strategy" => strategy)
|
.record(usize_to_f64(buffer_size_bytes));
|
||||||
|
histogram!("rustfs_io_get_object_stream_response_size_bytes", "strategy" => strategy.to_string())
|
||||||
.record(i64_non_negative_to_f64(response_size_bytes));
|
.record(i64_non_negative_to_f64(response_size_bytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Record the response-body handoff shape from a GetObject reader into the S3 streaming body.
|
/// Record the response-body handoff shape from a GetObject reader into the S3 streaming body.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn record_get_object_response_handoff(
|
pub fn record_get_object_response_handoff(
|
||||||
strategy: &'static str,
|
strategy: &str,
|
||||||
buffer_source: &'static str,
|
buffer_source: &str,
|
||||||
buffer_size_bytes: usize,
|
buffer_size_bytes: usize,
|
||||||
response_size_bytes: i64,
|
response_size_bytes: i64,
|
||||||
duration_secs: f64,
|
duration_secs: f64,
|
||||||
@@ -511,26 +512,26 @@ pub fn record_get_object_response_handoff(
|
|||||||
}
|
}
|
||||||
counter!(
|
counter!(
|
||||||
"rustfs_io_get_object_response_handoff_total",
|
"rustfs_io_get_object_response_handoff_total",
|
||||||
"strategy" => strategy,
|
"strategy" => strategy.to_string(),
|
||||||
"buffer_source" => buffer_source
|
"buffer_source" => buffer_source.to_string()
|
||||||
)
|
)
|
||||||
.increment(1);
|
.increment(1);
|
||||||
histogram!(
|
histogram!(
|
||||||
"rustfs_io_get_object_response_handoff_buffer_size_bytes",
|
"rustfs_io_get_object_response_handoff_buffer_size_bytes",
|
||||||
"strategy" => strategy,
|
"strategy" => strategy.to_string(),
|
||||||
"buffer_source" => buffer_source
|
"buffer_source" => buffer_source.to_string()
|
||||||
)
|
)
|
||||||
.record(usize_to_f64(buffer_size_bytes));
|
.record(usize_to_f64(buffer_size_bytes));
|
||||||
histogram!(
|
histogram!(
|
||||||
"rustfs_io_get_object_response_handoff_response_size_bytes",
|
"rustfs_io_get_object_response_handoff_response_size_bytes",
|
||||||
"strategy" => strategy,
|
"strategy" => strategy.to_string(),
|
||||||
"buffer_source" => buffer_source
|
"buffer_source" => buffer_source.to_string()
|
||||||
)
|
)
|
||||||
.record(i64_non_negative_to_f64(response_size_bytes));
|
.record(i64_non_negative_to_f64(response_size_bytes));
|
||||||
histogram!(
|
histogram!(
|
||||||
"rustfs_io_get_object_response_handoff_duration_seconds",
|
"rustfs_io_get_object_response_handoff_duration_seconds",
|
||||||
"strategy" => strategy,
|
"strategy" => strategy.to_string(),
|
||||||
"buffer_source" => buffer_source
|
"buffer_source" => buffer_source.to_string()
|
||||||
)
|
)
|
||||||
.record(duration_secs);
|
.record(duration_secs);
|
||||||
record_get_object_response_handoff_duration("s3_handler", duration_secs);
|
record_get_object_response_handoff_duration("s3_handler", duration_secs);
|
||||||
@@ -538,18 +539,14 @@ pub fn record_get_object_response_handoff(
|
|||||||
|
|
||||||
/// Record ReaderStream capacity chosen for GetObject handoff.
|
/// Record ReaderStream capacity chosen for GetObject handoff.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn record_get_object_reader_stream_buffer_size(
|
pub fn record_get_object_reader_stream_buffer_size(strategy: &str, buffer_source: &str, buffer_size_bytes: usize) {
|
||||||
strategy: &'static str,
|
|
||||||
buffer_source: &'static str,
|
|
||||||
buffer_size_bytes: usize,
|
|
||||||
) {
|
|
||||||
if !get_stage_metrics_enabled() {
|
if !get_stage_metrics_enabled() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
histogram!(
|
histogram!(
|
||||||
"rustfs_io_get_object_reader_stream_buffer_size_bytes",
|
"rustfs_io_get_object_reader_stream_buffer_size_bytes",
|
||||||
"strategy" => strategy,
|
"strategy" => strategy.to_string(),
|
||||||
"buffer_source" => buffer_source
|
"buffer_source" => buffer_source.to_string()
|
||||||
)
|
)
|
||||||
.record(usize_to_f64(buffer_size_bytes));
|
.record(usize_to_f64(buffer_size_bytes));
|
||||||
}
|
}
|
||||||
@@ -557,8 +554,8 @@ pub fn record_get_object_reader_stream_buffer_size(
|
|||||||
/// Record ReaderStream poll outcomes for GetObject handoff attribution.
|
/// Record ReaderStream poll outcomes for GetObject handoff attribution.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn record_get_object_reader_stream_poll(
|
pub fn record_get_object_reader_stream_poll(
|
||||||
strategy: &'static str,
|
strategy: &str,
|
||||||
buffer_source: &'static str,
|
buffer_source: &str,
|
||||||
outcome: &'static str,
|
outcome: &'static str,
|
||||||
remaining_before: usize,
|
remaining_before: usize,
|
||||||
bytes: usize,
|
bytes: usize,
|
||||||
@@ -570,36 +567,36 @@ pub fn record_get_object_reader_stream_poll(
|
|||||||
let bytes = u64::try_from(bytes).unwrap_or(u64::MAX);
|
let bytes = u64::try_from(bytes).unwrap_or(u64::MAX);
|
||||||
counter!(
|
counter!(
|
||||||
"rustfs_io_get_object_reader_stream_poll_total",
|
"rustfs_io_get_object_reader_stream_poll_total",
|
||||||
"strategy" => strategy,
|
"strategy" => strategy.to_string(),
|
||||||
"buffer_source" => buffer_source,
|
"buffer_source" => buffer_source.to_string(),
|
||||||
"outcome" => outcome
|
"outcome" => outcome
|
||||||
)
|
)
|
||||||
.increment(1);
|
.increment(1);
|
||||||
counter!(
|
counter!(
|
||||||
"rustfs_io_get_object_reader_stream_poll_bytes_total",
|
"rustfs_io_get_object_reader_stream_poll_bytes_total",
|
||||||
"strategy" => strategy,
|
"strategy" => strategy.to_string(),
|
||||||
"buffer_source" => buffer_source,
|
"buffer_source" => buffer_source.to_string(),
|
||||||
"outcome" => outcome
|
"outcome" => outcome
|
||||||
)
|
)
|
||||||
.increment(bytes);
|
.increment(bytes);
|
||||||
histogram!(
|
histogram!(
|
||||||
"rustfs_io_get_object_reader_stream_poll_remaining_bytes",
|
"rustfs_io_get_object_reader_stream_poll_remaining_bytes",
|
||||||
"strategy" => strategy,
|
"strategy" => strategy.to_string(),
|
||||||
"buffer_source" => buffer_source,
|
"buffer_source" => buffer_source.to_string(),
|
||||||
"outcome" => outcome
|
"outcome" => outcome
|
||||||
)
|
)
|
||||||
.record(usize_to_f64(remaining_before));
|
.record(usize_to_f64(remaining_before));
|
||||||
histogram!(
|
histogram!(
|
||||||
"rustfs_io_get_object_reader_stream_poll_bytes",
|
"rustfs_io_get_object_reader_stream_poll_bytes",
|
||||||
"strategy" => strategy,
|
"strategy" => strategy.to_string(),
|
||||||
"buffer_source" => buffer_source,
|
"buffer_source" => buffer_source.to_string(),
|
||||||
"outcome" => outcome
|
"outcome" => outcome
|
||||||
)
|
)
|
||||||
.record(usize_to_f64(bytes as usize));
|
.record(usize_to_f64(bytes as usize));
|
||||||
histogram!(
|
histogram!(
|
||||||
"rustfs_io_get_object_reader_stream_poll_duration_seconds",
|
"rustfs_io_get_object_reader_stream_poll_duration_seconds",
|
||||||
"strategy" => strategy,
|
"strategy" => strategy.to_string(),
|
||||||
"buffer_source" => buffer_source,
|
"buffer_source" => buffer_source.to_string(),
|
||||||
"outcome" => outcome
|
"outcome" => outcome
|
||||||
)
|
)
|
||||||
.record(duration_secs);
|
.record(duration_secs);
|
||||||
|
|||||||
@@ -31,7 +31,10 @@ pub struct KeystoneClient {
|
|||||||
admin_password: Option<String>,
|
admin_password: Option<String>,
|
||||||
admin_project: Option<String>,
|
admin_project: Option<String>,
|
||||||
admin_domain: String,
|
admin_domain: String,
|
||||||
#[allow(dead_code)]
|
#[allow(
|
||||||
|
dead_code,
|
||||||
|
reason = "TLS verification flag parsed from config; the reqwest client is built before it is consulted, so nothing reads it back (backlog#1823)"
|
||||||
|
)]
|
||||||
verify_ssl: bool,
|
verify_ssl: bool,
|
||||||
/// Request timeout applied to the underlying HTTP client.
|
/// Request timeout applied to the underlying HTTP client.
|
||||||
timeout: std::time::Duration,
|
timeout: std::time::Duration,
|
||||||
|
|||||||
@@ -20,7 +20,10 @@ use tracing::{debug, info};
|
|||||||
|
|
||||||
/// Maps Keystone identities to RustFS concepts
|
/// Maps Keystone identities to RustFS concepts
|
||||||
pub struct KeystoneIdentityMapper {
|
pub struct KeystoneIdentityMapper {
|
||||||
#[allow(dead_code)]
|
#[allow(
|
||||||
|
dead_code,
|
||||||
|
reason = "keeps the Keystone client alive for the mapper's lifetime; the mapping paths do not call through it yet (backlog#1823)"
|
||||||
|
)]
|
||||||
client: Arc<KeystoneClient>,
|
client: Arc<KeystoneClient>,
|
||||||
role_policy_map: HashMap<String, String>,
|
role_policy_map: HashMap<String, String>,
|
||||||
enable_tenant_prefix: bool,
|
enable_tenant_prefix: bool,
|
||||||
|
|||||||
@@ -40,7 +40,10 @@ impl RuleEvents for RuleView {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct CompiledRules {
|
struct CompiledRules {
|
||||||
// Keep RulesMap (can be used later if you want to make more complex judgments during the snapshot reading phase)
|
// Keep RulesMap (can be used later if you want to make more complex judgments during the snapshot reading phase)
|
||||||
#[allow(dead_code)]
|
#[allow(
|
||||||
|
dead_code,
|
||||||
|
reason = "speculative retention: the comment above keeps it for richer snapshot-time judgements that no code performs yet (backlog#1823)"
|
||||||
|
)]
|
||||||
rules_map: RulesMap,
|
rules_map: RulesMap,
|
||||||
// for RulesContainer::iter_rules
|
// for RulesContainer::iter_rules
|
||||||
rule_views: Vec<RuleView>,
|
rule_views: Vec<RuleView>,
|
||||||
|
|||||||
@@ -187,7 +187,6 @@ impl RulesMap {
|
|||||||
/// # Parameters
|
/// # Parameters
|
||||||
/// * `event_name` - The EventName from which to remove the rule.
|
/// * `event_name` - The EventName from which to remove the rule.
|
||||||
/// * `pattern` - The pattern of the rule to be removed.
|
/// * `pattern` - The pattern of the rule to be removed.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn remove_rule(&mut self, event_name: &EventName, pattern: &str) {
|
pub fn remove_rule(&mut self, event_name: &EventName, pattern: &str) {
|
||||||
let mut remove_event = false;
|
let mut remove_event = false;
|
||||||
|
|
||||||
@@ -209,7 +208,6 @@ impl RulesMap {
|
|||||||
///
|
///
|
||||||
/// # Parameters
|
/// # Parameters
|
||||||
/// * `event_names` - A slice of EventNames to be removed.
|
/// * `event_names` - A slice of EventNames to be removed.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn remove_rules(&mut self, event_names: &[EventName]) {
|
pub fn remove_rules(&mut self, event_names: &[EventName]) {
|
||||||
for event_name in event_names {
|
for event_name in event_names {
|
||||||
self.map.remove(event_name);
|
self.map.remove(event_name);
|
||||||
@@ -223,7 +221,6 @@ impl RulesMap {
|
|||||||
/// * `event_name` - The EventName to update.
|
/// * `event_name` - The EventName to update.
|
||||||
/// * `pattern` - The pattern of the rule to be updated.
|
/// * `pattern` - The pattern of the rule to be updated.
|
||||||
/// * `target_id` - The TargetID to be added.
|
/// * `target_id` - The TargetID to be added.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn update_rule(&mut self, event_name: EventName, pattern: String, target_id: TargetID) {
|
pub fn update_rule(&mut self, event_name: EventName, pattern: String, target_id: TargetID) {
|
||||||
self.map.entry(event_name).or_default().add(pattern, target_id);
|
self.map.entry(event_name).or_default().add(pattern, target_id);
|
||||||
self.total_events_mask |= event_name.mask(); // Update only the relevant bitmask
|
self.total_events_mask |= event_name.mask(); // Update only the relevant bitmask
|
||||||
|
|||||||
@@ -18,12 +18,6 @@ use rustfs_targets::arn::TargetID;
|
|||||||
/// TargetIDSet - A collection representation of TargetID.
|
/// TargetIDSet - A collection representation of TargetID.
|
||||||
pub type TargetIdSet = HashSet<TargetID>;
|
pub type TargetIdSet = HashSet<TargetID>;
|
||||||
|
|
||||||
/// Provides a Go-like method for TargetIdSet (can be implemented as trait if needed)
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub(crate) fn new_target_id_set(target_ids: Vec<TargetID>) -> TargetIdSet {
|
|
||||||
target_ids.into_iter().collect()
|
|
||||||
}
|
|
||||||
|
|
||||||
// HashSet has built-in clone, union, difference and other operations.
|
// HashSet has built-in clone, union, difference and other operations.
|
||||||
// But the Go version of the method returns a new Set, and the HashSet method is usually iterator or modify itself.
|
// But the Go version of the method returns a new Set, and the HashSet method is usually iterator or modify itself.
|
||||||
// If you need to exactly match Go's API style, you can add wrapper functions.
|
// If you need to exactly match Go's API style, you can add wrapper functions.
|
||||||
|
|||||||
@@ -219,10 +219,6 @@ impl PartialEq for Functions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize)]
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub struct Value;
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::policy::Functions;
|
use crate::policy::Functions;
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn is_simple_match<P, N>(pattern: P, name: N) -> bool
|
pub fn is_simple_match<P, N>(pattern: P, name: N) -> bool
|
||||||
where
|
where
|
||||||
P: AsRef<str>,
|
P: AsRef<str>,
|
||||||
@@ -29,7 +28,10 @@ where
|
|||||||
inner_match(pattern, name, false)
|
inner_match(pattern, name, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(
|
||||||
|
dead_code,
|
||||||
|
reason = "prefix-matcher asserted by this file's tests; no production caller yet (backlog#1823)"
|
||||||
|
)]
|
||||||
pub fn is_match_as_pattern_prefix<P, N>(pattern: P, text: N) -> bool
|
pub fn is_match_as_pattern_prefix<P, N>(pattern: P, text: N) -> bool
|
||||||
where
|
where
|
||||||
P: AsRef<str>,
|
P: AsRef<str>,
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ use crate::CloudMetadataFetcher;
|
|||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct AwsMetadataFetcher {
|
pub struct AwsMetadataFetcher {
|
||||||
client: Client,
|
client: Client,
|
||||||
|
#[allow(
|
||||||
|
dead_code,
|
||||||
|
reason = "IMDS endpoint retained beside the client it configures; requests build their own URLs (backlog#1823)"
|
||||||
|
)]
|
||||||
metadata_endpoint: String,
|
metadata_endpoint: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,55 +50,6 @@ impl AwsMetadataFetcher {
|
|||||||
metadata_endpoint: "http://169.254.169.254".to_string(),
|
metadata_endpoint: "http://169.254.169.254".to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves an IMDSv2 token for secure metadata access.
|
|
||||||
#[allow(dead_code)]
|
|
||||||
async fn get_metadata_token(&self) -> Result<String, AppError> {
|
|
||||||
let url = format!("{}/latest/api/token", self.metadata_endpoint);
|
|
||||||
|
|
||||||
match self
|
|
||||||
.client
|
|
||||||
.put(&url)
|
|
||||||
.header("X-aws-ec2-metadata-token-ttl-seconds", "21600")
|
|
||||||
.send()
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(response) => {
|
|
||||||
if response.status().is_success() {
|
|
||||||
let token = response
|
|
||||||
.text()
|
|
||||||
.await
|
|
||||||
.map_err(|e| AppError::cloud(format!("Failed to read IMDSv2 token: {}", e)))?;
|
|
||||||
Ok(token)
|
|
||||||
} else {
|
|
||||||
debug!(
|
|
||||||
event = "trusted_proxies.cloud_metadata",
|
|
||||||
component = "trusted_proxies",
|
|
||||||
subsystem = "aws_metadata",
|
|
||||||
provider = "aws",
|
|
||||||
operation = "imdsv2_token",
|
|
||||||
result = "http_error",
|
|
||||||
status = %response.status(),
|
|
||||||
"trusted proxy cloud metadata request failed"
|
|
||||||
);
|
|
||||||
Err(AppError::cloud("Failed to obtain IMDSv2 token"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
debug!(
|
|
||||||
event = "trusted_proxies.cloud_metadata",
|
|
||||||
component = "trusted_proxies",
|
|
||||||
subsystem = "aws_metadata",
|
|
||||||
provider = "aws",
|
|
||||||
operation = "imdsv2_token",
|
|
||||||
result = "request_failed",
|
|
||||||
error = %e,
|
|
||||||
"trusted proxy cloud metadata request failed"
|
|
||||||
);
|
|
||||||
Err(AppError::cloud(format!("IMDSv2 request failed: {}", e)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ pub fn is_env_set(key: &str) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a list of all proxy-related environment variables and their current values.
|
/// Returns a list of all proxy-related environment variables and their current values.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn get_all_proxy_env_vars() -> Vec<(String, String)> {
|
pub fn get_all_proxy_env_vars() -> Vec<(String, String)> {
|
||||||
let vars = [
|
let vars = [
|
||||||
ENV_TRUSTED_PROXY_ENABLED,
|
ENV_TRUSTED_PROXY_ENABLED,
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ pub async fn read_full_or_eof<R: AsyncRead + Send + Sync + Unpin>(
|
|||||||
|
|
||||||
/// Read exactly buf.len() bytes into buf, or return an error if EOF is reached before any bytes are read.
|
/// Read exactly buf.len() bytes into buf, or return an error if EOF is reached before any bytes are read.
|
||||||
/// Like Go's io.ReadFull.
|
/// Like Go's io.ReadFull.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub async fn read_full<R: AsyncRead + Send + Sync + Unpin>(reader: R, buf: &mut [u8]) -> std::io::Result<usize> {
|
pub async fn read_full<R: AsyncRead + Send + Sync + Unpin>(reader: R, buf: &mut [u8]) -> std::io::Result<usize> {
|
||||||
match read_full_or_eof(reader, buf).await? {
|
match read_full_or_eof(reader, buf).await? {
|
||||||
Some(n) => Ok(n),
|
Some(n) => Ok(n),
|
||||||
|
|||||||
@@ -431,7 +431,6 @@ pub fn parse_and_resolve_address(addr_str: &str) -> std::io::Result<SocketAddr>
|
|||||||
Ok(resolved_addr)
|
Ok(resolved_addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn bytes_stream<S, E>(stream: S, content_length: usize) -> impl Stream<Item = Result<Bytes, E>> + Send + 'static
|
pub fn bytes_stream<S, E>(stream: S, content_length: usize) -> impl Stream<Item = Result<Bytes, E>> + Send + 'static
|
||||||
where
|
where
|
||||||
S: Stream<Item = Result<Bytes, E>> + Send + 'static,
|
S: Stream<Item = Result<Bytes, E>> + Send + 'static,
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
///
|
///
|
||||||
/// The table follows Linux `include/uapi/linux/magic.h`; filesystem magic
|
/// The table follows Linux `include/uapi/linux/magic.h`; filesystem magic
|
||||||
/// values without a stable Linux uapi source stay `UNKNOWN`.
|
/// values without a stable Linux uapi source stay `UNKNOWN`.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub(crate) fn get_fs_type(fs_type: u64) -> &'static str {
|
pub(crate) fn get_fs_type(fs_type: u64) -> &'static str {
|
||||||
// Magic numbers for various filesystems.
|
// Magic numbers for various filesystems.
|
||||||
match fs_type {
|
match fs_type {
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ pub fn is_dir_object(object: &str) -> bool {
|
|||||||
///
|
///
|
||||||
/// If the object name ends with `GLOBAL_DIR_SUFFIX`, it is replaced with a slash.
|
/// If the object name ends with `GLOBAL_DIR_SUFFIX`, it is replaced with a slash.
|
||||||
/// Otherwise, the name is returned as is.
|
/// Otherwise, the name is returned as is.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn decode_dir_object(object: &str) -> String {
|
pub fn decode_dir_object(object: &str) -> String {
|
||||||
if has_suffix(object, GLOBAL_DIR_SUFFIX) {
|
if has_suffix(object, GLOBAL_DIR_SUFFIX) {
|
||||||
format!("{}{}", object.trim_end_matches(GLOBAL_DIR_SUFFIX), SLASH_SEPARATOR)
|
format!("{}{}", object.trim_end_matches(GLOBAL_DIR_SUFFIX), SLASH_SEPARATOR)
|
||||||
|
|||||||
Reference in New Issue
Block a user