Netstack Smoltcp
Is this really a fork? No, it's definitely not what you think. I lost my admin privileges on the original upstream org, but that wasn't me. Imagine how many orgs on GitHub are backed by companies, individuals, or something else entirely. You should submit issues and pull requests in this repository, not the upstream org. I'm fed up with those orgs masquerading as open source. They manipulate my privileges at will, and I've lost the confidence to continue maintaining them. Perhaps that's not confidence, but trust.
A netstack for the special purpose of turning packets from/to a TUN interface into TCP streams and UDP packets. It uses smoltcp-rs as the backend netstack.
Features
- Supports Future Send and non-Send, mostly pepole use Send.
- Supports ICMP protocol drive by TCP runner to use ICMP ping.
- Supports filtering packets by source and destination IP addresses.
- Can read IP packets from netstack, write IP packets to netstack.
- Can receive TcpStream from TcpListener exposed from netstack.
- Can receive UDP datagram from UdpSocket exposed from netstack.
- Implements popular future streaming traits and asynchronous IO traits:
- TcpListener implements futures Stream/Sink trait
- TcpStream implements tokio AsyncRead/AsyncWrite trait
- UdpSocket(ReadHalf/WriteHalf) implements futures Stream/Sink trait.
Platforms
This crate provides lightweight netstack support for Linux, iOS, macOS, Android and Windows. Currently, it works on most targets, but mainly tested the popular platforms which includes:
- linux-amd64: x86_64-unknown-linux-gnu
- android-arm64: aarch64-linux-android
- android-amd64: x86_64-linux-android
- macos-amd64: x86_64-apple-darwin
- macos-arm64: aarch64-apple-darwin
- ios-arm64: aarch64-apple-ios
- windows-amd64: x86_64-pc-windows-msvc
- windows-arm64: aarch64-pc-windows-msvc
Example
// let device = tun2::create_as_async(&cfg)?;
// let framed = device.into_framed();
let = default
.stack_buffer_size
.tcp_buffer_size
.enable_udp
.enable_tcp
.enable_icmp
.build
.unwrap;
let mut udp_socket = udp_socket.unwrap; // udp enabled
let mut tcp_listener = tcp_listener.unwrap; // tcp/icmp enabled
if let Some = runner
let = stack.split;
let = framed.split;
// Reads packet from stack and sends to TUN.
spawn;
// Reads packet from TUN and sends to stack.
spawn;
// Extracts TCP connections from stack and sends them to the dispatcher.
spawn;
// Receive and send UDP packets between netstack and NAT manager. The NAT
// manager would maintain UDP sessions and send them to the dispatcher.
spawn;
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in netstack-smoltcp by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Inspired By
Special thanks to these amazing projects that inspired netstack-smoltcp (in no particular order):