Skip to content

Commit

Permalink
Deny unused dependencies (#2843)
Browse files Browse the repository at this point in the history
* medschool

* mirrord-agent

* mirrord-analytics

* mirrord-auth

* Changed doc in mirrord-agent

* mirrord

* mirrord-config

* mirrord-console

* mirrord-intproxy

* mirrord-kube

* mirrord-layer

* mirrord-macros

* mirrord-operator

* mirrord-progress

* mirrord-protocol

* mirrord-sip

* mirrord-vpn

* one global cfg for mirrord-agent

* Remove obsolete linux cfgs

* Moved silencers to the bottom of imports

* Fmt

* Bumped mirrord-protocol version

* Changelog

* silence reqwest in mirrord-auth

* Fix doc

* Moved libc to linux deps in mirrord-protocol

* Fixed mirrord-layer deps

* Apply suggestions from code review

Co-authored-by: meowjesty <[email protected]>

---------

Co-authored-by: meowjesty <[email protected]>
  • Loading branch information
Razz4780 and meowjesty authored Dec 24, 2024
1 parent 9620ec0 commit bdc4a04
Show file tree
Hide file tree
Showing 37 changed files with 268 additions and 324 deletions.
43 changes: 1 addition & 42 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions changelog.d/2843.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added lint for unused crate dependencies.
1 change: 1 addition & 0 deletions medschool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#![feature(iterator_try_collect)]
#![deny(clippy::missing_docs_in_private_items)]
#![deny(missing_docs)]
#![deny(unused_crate_dependencies)]

use std::{fs, fs::File, io::Read, path::PathBuf};

Expand Down
7 changes: 2 additions & 5 deletions mirrord/agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
[target.'cfg(target_os = "linux")'.dependencies]
containerd-client = "0.6"
tokio = { workspace = true, features = [
"rt",
Expand Down Expand Up @@ -49,7 +49,6 @@ streammap-ext.workspace = true
libc.workspace = true
faccess = "0.2"
bytes.workspace = true
regex.workspace = true
wildmatch = "2"
enum_dispatch.workspace = true
http-body-util = { workspace = true }
Expand All @@ -70,13 +69,11 @@ x509-parser = "0.16"
rustls.workspace = true
envy = "0.4"
socket2.workspace = true

[target.'cfg(target_os = "linux")'.dependencies]
iptables = { git = "https://github.com/metalbear-co/rust-iptables.git", rev = "e66c7332e361df3c61a194f08eefe3f40763d624" }
rawsocket = { git = "https://github.com/metalbear-co/rawsocket.git" }
procfs = "0.17.0"

[dev-dependencies]
[target.'cfg(target_os = "linux")'.dev-dependencies]
rstest.workspace = true
mockall = "0.13"
test_bin = "0.4"
Expand Down
33 changes: 9 additions & 24 deletions mirrord/agent/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,52 +1,37 @@
#![cfg(target_os = "linux")]
#![feature(hash_extract_if)]
#![feature(let_chains)]
#![feature(iterator_try_collect)]
#![feature(try_blocks)]
#![cfg_attr(target_os = "linux", feature(tcp_quickack))]
#![feature(tcp_quickack)]
#![warn(clippy::indexing_slicing)]
#![deny(unused_crate_dependencies)]

/// Silences `deny(unused_crate_dependencies)`.
///
/// This dependency is only used in integration tests.
#[cfg(test)]
use test_bin as _;

#[cfg(target_os = "linux")]
mod cli;
#[cfg(target_os = "linux")]
mod client_connection;
#[cfg(target_os = "linux")]
mod container_handle;
#[cfg(target_os = "linux")]
mod dns;
#[cfg(target_os = "linux")]
mod entrypoint;
#[cfg(target_os = "linux")]
mod env;
#[cfg(target_os = "linux")]
mod error;
#[cfg(target_os = "linux")]
mod file;
#[cfg(target_os = "linux")]
mod http;
#[cfg(target_os = "linux")]
mod namespace;
#[cfg(target_os = "linux")]
mod outgoing;
#[cfg(target_os = "linux")]
mod runtime;
#[cfg(target_os = "linux")]
mod sniffer;
#[cfg(target_os = "linux")]
mod steal;
#[cfg(target_os = "linux")]
mod util;
#[cfg(target_os = "linux")]
mod vpn;
#[cfg(target_os = "linux")]
mod watched_task;

#[cfg(target_os = "linux")]
#[tokio::main(flavor = "current_thread")]
async fn main() -> crate::error::Result<()> {
crate::entrypoint::main().await
}

#[cfg(not(target_os = "linux"))]
fn main() {
panic!("This program is only supported on Linux");
}
30 changes: 0 additions & 30 deletions mirrord/agent/src/steal/ip_tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,6 @@ use crate::{
},
};

#[cfg(not(target_os = "linux"))]
mod iptables {
pub struct IPTables;

impl IPTables {
pub fn list(&self, _: &str, _: &str) -> Result<Vec<String>, String> {
todo!()
}
pub fn insert(&self, _: &str, _: &str, _: &str, _: i32) -> Result<(), String> {
todo!()
}
pub fn append(&self, _: &str, _: &str, _: &str) -> Result<(), String> {
todo!()
}
pub fn delete(&self, _: &str, _: &str, _: &str) -> Result<(), String> {
todo!()
}

pub fn new_chain(&self, _: &str, _: &str) -> Result<(), String> {
todo!()
}
pub fn delete_chain(&self, _: &str, _: &str) -> Result<(), String> {
todo!()
}
pub fn flush_chain(&self, _: &str, _: &str) -> Result<(), String> {
todo!()
}
}
}

pub(crate) mod chain;
pub(crate) mod flush_connections;
pub(crate) mod mesh;
Expand Down
10 changes: 0 additions & 10 deletions mirrord/agent/src/steal/orig_dst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::{io, net::SocketAddr};

use tokio::net::TcpStream;

#[cfg(target_os = "linux")]
#[allow(unsafe_code)]
#[tracing::instrument(level = "trace")]
pub(super) fn orig_dst_addr(sock: &TcpStream) -> io::Result<SocketAddr> {
Expand All @@ -14,15 +13,6 @@ pub(super) fn orig_dst_addr(sock: &TcpStream) -> io::Result<SocketAddr> {
unsafe { linux::so_original_dst(fd) }
}

#[cfg(not(target_os = "linux"))]
pub(super) fn orig_dst_addr(_: &TcpStream) -> io::Result<SocketAddr> {
Err(io::Error::new(
io::ErrorKind::Other,
"SO_ORIGINAL_DST not supported on this operating system",
))
}

#[cfg(target_os = "linux")]
#[allow(unsafe_code)]
mod linux {
use std::{
Expand Down
Loading

0 comments on commit bdc4a04

Please sign in to comment.