mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-11-18 00:16:30 +00:00
fix(local): local-tun Device::name now returns Result
This commit is contained in:
@@ -143,7 +143,11 @@ impl Tun {
|
||||
|
||||
info!(
|
||||
"shadowsocks tun device {}, mode {}",
|
||||
self.device.get_ref().name(),
|
||||
self.device
|
||||
.get_ref()
|
||||
.name()
|
||||
.or_else(|r| Ok::<_, ()>(r.to_string()))
|
||||
.unwrap(),
|
||||
self.mode,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
use std::{
|
||||
ffi::CStr,
|
||||
io::{self, ErrorKind},
|
||||
mem,
|
||||
ptr,
|
||||
mem, ptr,
|
||||
};
|
||||
|
||||
use log::{error, trace};
|
||||
use tun::{platform::Device as TunDevice, Device};
|
||||
use tun::{platform::Device as TunDevice, Device, Error as TunError};
|
||||
|
||||
/// These numbers are used by reliable protocols for determining
|
||||
/// retransmission behavior and are included in the routing structure.
|
||||
@@ -75,7 +74,13 @@ pub async fn set_route_configuration(device: &TunDevice) -> io::Result<()> {
|
||||
}
|
||||
};
|
||||
|
||||
let tun_name = device.name();
|
||||
let tun_name = match device.name() {
|
||||
Ok(n) => n,
|
||||
Err(err) => match err {
|
||||
TunError::Io(err) => return Err(err),
|
||||
e => return Err(io::Error::new(ErrorKind::Other, e)),
|
||||
},
|
||||
};
|
||||
|
||||
// routing packets that saddr & daddr are in the subnet of the Tun interface
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user