All Projects → wzhd → ustcp

wzhd / ustcp

Licence: other
Pure Rust TCP stack in user-space running on TUN/TAP

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to ustcp

opengnb
GNB is open source de-centralized VPN to achieve layer3 network via p2p with the ultimate capability of NAT Traversal.GNB是一个开源的去中心化的具有极致内网穿透能力的通过P2P进行三层网络交换的VPN。
Stars: ✭ 440 (+1319.35%)
Mutual labels:  tcp, tun
net-protocol
golang模拟内核协议栈 实现链路层、网络层、传输层、应用层 用户态协议栈 ,基于虚拟网卡TUN/TAP
Stars: ✭ 129 (+316.13%)
Mutual labels:  tcp, tun
sdr-modem
Modem based on software defined radios.
Stars: ✭ 15 (-51.61%)
Mutual labels:  tcp
packetdrill
packetdrill with UDPLite and SCTP support and bug fixes for FreeBSD
Stars: ✭ 37 (+19.35%)
Mutual labels:  tcp
EasyFileTransfer
An easy way to transfer file with any size on network with tcp protocol.
Stars: ✭ 30 (-3.23%)
Mutual labels:  tcp
epump
ePump是一个基于I/O事件通知、非阻塞通信、多路复用、多线程等机制开发的事件驱动模型的 C 语言应用开发框架,利用该框架可以很容易地开发出高性能、大并发连接的服务器程序。
Stars: ✭ 26 (-16.13%)
Mutual labels:  tcp
sol
Lightweight MQTT broker, written from scratch. IO is handled by a super simple event loop based upon the most common IO multiplexing implementations.
Stars: ✭ 72 (+132.26%)
Mutual labels:  tcp
Cerberus
A complete Grabber, sending data to a TCP server that you have to host and stocking all in a database.
Stars: ✭ 32 (+3.23%)
Mutual labels:  tcp
natcross2
内网穿透工具
Stars: ✭ 111 (+258.06%)
Mutual labels:  tcp
ip2socks
ip flow to socks, support tun and tap.
Stars: ✭ 35 (+12.9%)
Mutual labels:  tun
packet
📦 Send network packets over a TCP or UDP connection.
Stars: ✭ 68 (+119.35%)
Mutual labels:  tcp
spear
Spear轻量级微服务框架,高扩展性,目前已支持TCP、HTTP、WebSocket以及GRPC协议,采用Consul/Nacos作为服务注册与发现组件,TCP协议采用DotNetty底层实现,HTTP协议采用ASP.NET CORE MVC实现。
Stars: ✭ 49 (+58.06%)
Mutual labels:  tcp
Tiginx
Tiginx is a Shanzhai Nginx project , please buyao use it xian , if meet problem , I no fuze ...
Stars: ✭ 29 (-6.45%)
Mutual labels:  tcp
FuckDPI V2
FuckDPIv2 can fuck the Korean Government's internet censorship by fragmenting SSL ClientHello.
Stars: ✭ 44 (+41.94%)
Mutual labels:  tcp
ParallelCollectionMonitoring
使用数十个.NET客户端控制硬件设备进行工作,采集数据并进行处理,管理人员通过 Android 应用实时控制各设备的工作。本作品获得第十二届中国研究生电子设计竞赛华南赛区一等奖。
Stars: ✭ 21 (-32.26%)
Mutual labels:  tcp
mocket
Reliable UDP server client for flaky networks
Stars: ✭ 21 (-32.26%)
Mutual labels:  tcp
tcping
⚡️ Just like icmp ping
Stars: ✭ 138 (+345.16%)
Mutual labels:  tcp
monte
The bare minimum for high performance, fully-encrypted bidirectional RPC over TCP in Go with zero memory allocations.
Stars: ✭ 103 (+232.26%)
Mutual labels:  tcp
PsNetTools
PsNetTools is a cross platform PowerShell module to test network features on Windows, Linux and Mac.
Stars: ✭ 13 (-58.06%)
Mutual labels:  tcp
databento-python
Official Python client library for Databento
Stars: ✭ 16 (-48.39%)
Mutual labels:  tcp

ustunet

A pure Rust TCP library that can be simply used in place of TCP implementations provided by operating systems, enabling services to be built with uncommon flexibility.

Usage

At a high level, it provides APIs similar to any asynchronous TCP socket library.

To start listening, use TcpListener. But instead of binding to a single SocketAddr, give it the name of a TUN network interface:

use ustunet::TcpListener;

let mut listener = TcpListener::bind("tuna").unwrap();

And it will process all IP packets going to the interface, accepting incoming TCP connections destined to any SocketAddr. It's like binding to all possible IP and ports. (But without the complexity or the cost. Only one file descriptor is used.)

Accept TcpStreams:

while let Some(tcp_stream) = listener.next().await {
}

Use tokio::io::AsyncRead and AsyncWrite implementations:

let mut buf = [0u8; 1024];
let n = tcp_stream.read(&mut buf).await.unwrap();

tcp_stream.write("Aloha!".as_bytes()).await.unwrap();

Since the listener is not bound to an address, the SocketAddr actually used by a connection can be of more interest.

let server_addr = socket.local_addr();
println!("Provided service on port {}, IP: {}.", server_addr.port(), server_addr.ip());

Similarly, call peer_addr to get the address of the host that initiated the connection.

Adding the dependency

Add to Cargo.toml

[dependencies.ustunet]
git = "https://github.com/ustcp/ustcp.git"

Setting up a TUN network interface

TUN allows a user to send and receive IP packets on the interface with no permission requirements at runtime.

Create a TUN interface with name set to tuna, and ownership given to user yuki. And bring it up.

sudo ip tuntap add dev tuna mode tun user yuki
sudo ip link set up dev tuna

Give it an IP address (and a subnet mask) that's not currently in use:

sudo ip addr add 192.168.9.100/24 dev tuna

With the subnet mask /24, ustunet will be able to respond on any address in the range from 192.168.9.1 to 192.168.9.254.

The command can be repeated to add more addresses, but adding routes can be more flexible. Configure any address in the subnet as a gateway for a different range of IPs to instruct the operating systems to contact those addresses also via tuna.

sudo ip route add 10.33.0.0/16 via 192.168.9.4 dev tuna
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].