-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
#[cfg(unix)] | ||
#[cfg(target_os = "linux")] | ||
mod unix; | ||
|
||
#[cfg(unix)] | ||
#[cfg(target_os = "linux")] | ||
pub use self::unix::{ | ||
interface_from_name, | ||
list_interfaces, | ||
Socket, | ||
}; | ||
|
||
#[cfg(not(target_os = "linux"))] | ||
mod stub; | ||
|
||
#[cfg(not(target_os = "linux"))] | ||
pub use self::stub::{ | ||
interface_from_name, | ||
list_interfaces, | ||
Socket, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use std::{io::Error, os::fd::{AsRawFd, RawFd}}; | ||
|
||
use tokio::io::ReadBuf; | ||
|
||
use crate::proxy::pcap::{interface::Interface, socket::Mode}; | ||
|
||
|
||
fn warn_stub() { | ||
tracing::warn!("Packet capture is not available on this platform"); | ||
} | ||
|
||
pub fn list_interfaces() -> Result<Vec<Interface>, Error> { | ||
warn_stub(); | ||
Ok(vec![]) | ||
} | ||
|
||
pub fn interface_from_name(_name: &str) -> Result<Option<Interface>, Error> { | ||
warn_stub(); | ||
Ok(None) | ||
} | ||
|
||
#[derive(Debug)] | ||
pub enum Socket {} | ||
|
||
impl Socket { | ||
pub fn open(_interface: &Interface, _mode: Mode) -> Result<Self, Error> { | ||
unreachable!(); | ||
} | ||
|
||
pub async fn receive(&self, _buf: &mut ReadBuf<'_>) -> Result<usize, Error> { | ||
unreachable!(); | ||
} | ||
|
||
pub async fn send(&self, _buf: &[u8]) -> Result<(), Error> { | ||
unreachable!(); | ||
} | ||
} | ||
|
||
impl AsRawFd for Socket { | ||
fn as_raw_fd(&self) -> RawFd { | ||
unreachable!(); | ||
} | ||
} |