mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-06-18 15:15:22 +00:00
error issues
This commit is contained in:
parent
53daaed385
commit
8adfd8a0c1
2 changed files with 12 additions and 3 deletions
11
src/error.rs
11
src/error.rs
|
@ -6,7 +6,7 @@ pub enum Error {
|
||||||
#[error("ctrlc::Error {0:?}")]
|
#[error("ctrlc::Error {0:?}")]
|
||||||
InterruptHandler(#[from] ctrlc::Error),
|
InterruptHandler(#[from] ctrlc::Error),
|
||||||
|
|
||||||
#[error("std::io::Error {0}")]
|
#[error(transparent)]
|
||||||
Io(#[from] std::io::Error),
|
Io(#[from] std::io::Error),
|
||||||
|
|
||||||
#[error("TryFromIntError {0:?}")]
|
#[error("TryFromIntError {0:?}")]
|
||||||
|
@ -84,4 +84,13 @@ impl From<&String> for Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<Error> for std::io::Error {
|
||||||
|
fn from(err: Error) -> Self {
|
||||||
|
match err {
|
||||||
|
Error::Io(err) => err,
|
||||||
|
_ => std::io::Error::new(std::io::ErrorKind::Other, err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub type Result<T, E = Error> = std::result::Result<T, E>;
|
pub type Result<T, E = Error> = std::result::Result<T, E>;
|
||||||
|
|
|
@ -77,7 +77,7 @@ impl WinTunInterface {
|
||||||
let mask = Ipv4Addr::new(255, 255, 255, 0);
|
let mask = Ipv4Addr::new(255, 255, 255, 0);
|
||||||
let gateway = Some(IpAddr::V4(Ipv4Addr::new(10, 1, 0, 1)));
|
let gateway = Some(IpAddr::V4(Ipv4Addr::new(10, 1, 0, 1)));
|
||||||
adapter
|
adapter
|
||||||
.set_network_addresses_tuple(IpAddr::V4(address), IpAddr::V4(mask), gateway)
|
.set_network_addresses_tuple(address.into(), mask.into(), gateway)
|
||||||
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
|
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
|
||||||
|
|
||||||
let session = adapter
|
let session = adapter
|
||||||
|
@ -99,7 +99,7 @@ impl WinTunInterface {
|
||||||
let packet = reader_session.receive_blocking()?;
|
let packet = reader_session.receive_blocking()?;
|
||||||
let bytes = packet.bytes();
|
let bytes = packet.bytes();
|
||||||
|
|
||||||
let result = { pipe_client_clone.lock().unwrap().write(bytes) };
|
let result = { pipe_client_clone.lock()?.write(bytes) };
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(err) if err.kind() == io::ErrorKind::WouldBlock => {
|
Err(err) if err.kind() == io::ErrorKind::WouldBlock => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue