mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-11-06 16:14:11 +00:00
local-tun also obey "mode" configuration
This commit is contained in:
@@ -385,15 +385,6 @@ sslocal --protocol tun -s "[::1]:8388" -m "aes-256-gcm" -k "hello-kitty" --outbo
|
||||
|
||||
It will create a Tun interface with address `10.255.0.1` and netmask `255.255.255.0`.
|
||||
|
||||
(OPTIONAL) macOS requires adding a route entry to redirect packets that destinated to `10.155.0.1` (the address of the Tun interface) to the Tun interface itself.
|
||||
|
||||
```bash
|
||||
# 10.255.0.1 address
|
||||
# 255.255.255.0 netmask
|
||||
# utun8 tun's interface name
|
||||
route add -net 10.255.0.1 -netmask 255.255.255.0 -interface utun8
|
||||
```
|
||||
|
||||
### Server
|
||||
|
||||
```bash
|
||||
|
||||
@@ -192,6 +192,11 @@ impl Tun {
|
||||
|
||||
match packet.protocol() {
|
||||
IpProtocol::Tcp => {
|
||||
if !self.mode.enable_tcp() {
|
||||
trace!("received TCP packet but mode is {}, throwing away", self.mode);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let tcp_packet = match TcpPacket::new_checked(packet.payload()) {
|
||||
Ok(p) => p,
|
||||
Err(err) => {
|
||||
@@ -225,6 +230,11 @@ impl Tun {
|
||||
self.tcp.drive_interface_state(frame);
|
||||
}
|
||||
IpProtocol::Udp => {
|
||||
if !self.mode.enable_udp() {
|
||||
trace!("received UDP packet but mode is {}, throwing away", self.mode);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let udp_packet = match UdpPacket::new_checked(packet.payload()) {
|
||||
Ok(p) => p,
|
||||
Err(err) => {
|
||||
|
||||
Reference in New Issue
Block a user