Skip to content

Commit f41fc6f

Browse files
chore(deps): bump tun2 from 2.0.8 to 3.1.0 (shadowsocks#1640)
* chore(deps): bump tun2 from 2.0.8 to 3.1.0 Bumps [tun2](https://github.com/ssrlive/rust-tun) from 2.0.8 to 3.1.0. - [Release notes](https://github.com/ssrlive/rust-tun/releases) - [Commits](https://github.com/ssrlive/rust-tun/commits) --- updated-dependencies: - dependency-name: tun2 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * fix: AsyncDevice impls Deref * fix: fake tun impls Deref --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: zonyitoo <[email protected]>
1 parent 2361f2f commit f41fc6f

File tree

4 files changed

+115
-24
lines changed

4 files changed

+115
-24
lines changed

Cargo.lock

Lines changed: 95 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/shadowsocks-service/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ flate2 = { version = "1.0", optional = true }
186186
brotli = { version = "6.0", optional = true }
187187
zstd = { version = "0.13", optional = true }
188188

189-
tun2 = { version = "2.0.8", optional = true, default-features = false, features = [
189+
tun2 = { version = "3.1.0", optional = true, default-features = false, features = [
190190
"async",
191191
] }
192192
etherparse = { version = "0.15", optional = true }

crates/shadowsocks-service/src/local/tun/fake_tun.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use std::{
44
io::{self, Read, Write},
55
net::IpAddr,
6+
ops::{Deref, DerefMut},
67
pin::Pin,
78
task::{Context, Poll},
89
};
@@ -118,6 +119,20 @@ impl AsMut<FakeDevice> for AsyncDevice {
118119
}
119120
}
120121

122+
impl Deref for AsyncDevice {
123+
type Target = FakeDevice;
124+
125+
fn deref(&self) -> &Self::Target {
126+
&self.0
127+
}
128+
}
129+
130+
impl DerefMut for AsyncDevice {
131+
fn deref_mut(&mut self) -> &mut Self::Target {
132+
&mut self.0
133+
}
134+
}
135+
121136
impl AsyncRead for AsyncDevice {
122137
fn poll_read(self: Pin<&mut Self>, _cx: &mut Context<'_>, _buf: &mut ReadBuf<'_>) -> Poll<io::Result<()>> {
123138
Err(io::Error::new(io::ErrorKind::Other, "not implemented")).into()

crates/shadowsocks-service/src/local/tun/mod.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,7 @@ impl TunBuilder {
128128
self.udp_capacity,
129129
);
130130

131-
let tcp = TcpTun::new(
132-
self.context,
133-
self.balancer,
134-
device.as_ref().mtu().unwrap_or(1500) as u32,
135-
);
131+
let tcp = TcpTun::new(self.context, self.balancer, device.mtu().unwrap_or(1500) as u32);
136132

137133
Ok(Tun {
138134
device,
@@ -160,23 +156,19 @@ impl Tun {
160156
pub async fn run(mut self) -> io::Result<()> {
161157
info!(
162158
"shadowsocks tun device {}, mode {}",
163-
self.device
164-
.as_ref()
165-
.tun_name()
166-
.or_else(|r| Ok::<_, ()>(r.to_string()))
167-
.unwrap(),
159+
self.device.tun_name().or_else(|r| Ok::<_, ()>(r.to_string())).unwrap(),
168160
self.mode,
169161
);
170162

171-
let address = match self.device.as_ref().address() {
163+
let address = match self.device.address() {
172164
Ok(a) => a,
173165
Err(err) => {
174166
error!("[TUN] failed to get device address, error: {}", err);
175167
return Err(io::Error::new(io::ErrorKind::Other, err));
176168
}
177169
};
178170

179-
let netmask = match self.device.as_ref().netmask() {
171+
let netmask = match self.device.netmask() {
180172
Ok(n) => n,
181173
Err(err) => {
182174
error!("[TUN] failed to get device netmask, error: {}", err);

0 commit comments

Comments
 (0)