uni-stream
uni-stream is a Rust library for unified operation of TcpStream and UdpStream, designed to make your service support UDP and TCP (such as proxy services) with a single code implementation. On top of that the library provides the ability to customize dns server resolution.
Features
-
Generic:
uni-streamprovides an abstraction of UDP and TCP streams, which is exposed through some traits, making it easy for users to make secondary abstractions. -
Customizable:
uni-streamprovides functions that allow users to customize the resolution of dns services for TCP or UDP connections.
Usage
To use uni-stream in your Rust project, simply add it as a dependency in your Cargo.toml file:
[]
= "0.0.1"
Then, you can import and use the library in your Rust code.The following is a generic-based implementation of echo_server:
use AsyncReadExt;
use AsyncWriteExt;
use ListenerProvider;
use StreamAccept;
use TcpListenerProvider;
use UdpListenerProvider;
async
async
Customized dns resolution servers:
use set_custom_dns_server;
// use google and alibaba dns server
set_custom_dns_server.unwrap;
For more details on how to use uni-stream, please refer to the examples.
Contributing
Contributions to uni-stream are welcome! If you would like to contribute to the library, please follow the standard Rust community guidelines for contributing, including opening issues, submitting pull requests, and providing feedback.
License
uni-stream is licensed under the MIT License, which allows for free use, modification, and distribution, subject to the terms and conditions outlined in the license.
We hope that uni-stream is useful for your projects! If you have any questions or need further assistance, please don't hesitate to contact us or open an issue in the repository.