Skip to content

Commit d30ef92

Browse files
committed
wip
1 parent 7ba3672 commit d30ef92

18 files changed

Lines changed: 1378 additions & 85 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ members = [
66
]
77

88
[workspace.package]
9-
version = "0.7.6"
9+
version = "0.1.0"
1010
repository = "https://github.com/zephry-works/wind"
1111
edition = "2024"
1212
description = "Placeholder"

crates/wind-core/Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@ version.workspace = true
44
repository.workspace = true
55
edition.workspace = true
66
description.workspace = true
7-
license = "MIT OR Apache-2.0"
7+
license = "MIT OR Apache-2.0"
8+
9+
[dependencies]
10+
tokio = { version = "*", default-features = false }
11+
12+
serde = { version = "*", features = ["derive"] }

crates/wind-core/src/interface.rs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
2+
3+
use serde::{Deserialize, Serialize};
4+
5+
#[derive(Serialize, Deserialize, Debug, Clone)]
6+
pub struct Iface {
7+
pub name: String,
8+
pub ipv4: Option<Ipv4Addr>,
9+
pub ipv6: Option<Ipv6Addr>,
10+
pub index: u32,
11+
}
12+
13+
#[derive(Debug, Clone, Default)]
14+
pub enum Stack {
15+
#[default]
16+
V4,
17+
V6,
18+
}
19+
impl From<&SocketAddr> for Stack {
20+
fn from(value: &SocketAddr) -> Self {
21+
match value {
22+
SocketAddr::V4(..) => Self::V4,
23+
SocketAddr::V6(..) => Self::V6,
24+
}
25+
}
26+
}
27+
impl From<&IpAddr> for Stack {
28+
fn from(value: &IpAddr) -> Self {
29+
match value {
30+
IpAddr::V4(..) => Self::V4,
31+
IpAddr::V6(..) => Self::V6,
32+
}
33+
}
34+
}
35+
36+
#[derive(Serialize, Debug, Clone, Copy)]
37+
pub enum Network {
38+
TCP,
39+
UDP,
40+
ICMPv4,
41+
ICMPv6,
42+
}
43+
44+
#[derive(Debug, Clone, Copy)]
45+
pub enum StackPrefer {
46+
V4,
47+
V6,
48+
V4V6,
49+
V6V4,
50+
}
51+
52+
impl StackPrefer {
53+
pub fn support_v6(&self) -> bool {
54+
match self {
55+
StackPrefer::V4 => false,
56+
_ => true,
57+
}
58+
}
59+
}

crates/wind-core/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
mod interface;
2+
mod outbound;
3+
4+
pub use interface::*;
5+
pub use outbound::*;

crates/wind-core/src/main.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.

crates/wind-core/src/outbound.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use tokio::io::{AsyncRead, AsyncWrite};
2+
3+
pub trait AbstractTcpStream: AsyncRead + AsyncWrite {}
4+
5+
impl<T> AbstractTcpStream for T where T: AsyncRead + AsyncWrite {}
6+
7+
pub trait AbstractOutbound {
8+
/// TCP traffic which needs handled by outbound
9+
fn handle_tcp(
10+
via: Option<impl AbstractOutbound + Sized + Send>,
11+
) -> impl Future<Output = impl AbstractTcpStream> + Send;
12+
}

crates/wind-tuic/Cargo.toml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@ description.workspace = true
77
license = "MIT OR Apache-2.0"
88

99
[features]
10-
default = ["server", "client"]
10+
default = ["server", "client", "aws-lc-rs"]
1111
decode = []
1212
encode = []
1313
server = ["decode"]
1414
client = ["encode"]
15+
aws-lc-rs = ["rustls/aws-lc-rs"]
16+
ring = ["rustls/ring"]
1517

1618
[dependencies]
19+
wind-core = { path = "../wind-core"}
20+
21+
1722
# Async
1823
tokio = { version = "*", default-features = false }
1924
tokio-util = { version = "*", features = ["codec"] }
25+
quinn = "*"
2026

2127
tokio-stream = "*"
2228
futures-util = { version = "*", default-features = false, features = ["sink"] }
@@ -28,6 +34,13 @@ hex = { package = "const-hex", version = "1" }
2834
# Patterns
2935
num_enum = "0.7"
3036
snafu = "0.8"
37+
enum_dispatch = "*"
38+
secrecy = "0.10"
39+
40+
# TLS
41+
tokio-rustls = { version = "*", default-features = false, features = ["logging"] }
42+
rustls = { version = "*", default-features = false }
43+
rustls-platform-verifier = "*"
3144

3245
[dev-dependencies]
3346
tokio = { version = "*", default-features = false, features = ["macros", "rt"] }

crates/wind-tuic/src/ext.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
use tokio::io::{AsyncRead, AsyncWrite};
2+
3+
use crate::outbound::TuicTcpStream;
4+
5+
impl AsyncRead for TuicTcpStream {
6+
fn poll_read(
7+
self: std::pin::Pin<&mut Self>,
8+
cx: &mut std::task::Context<'_>,
9+
buf: &mut tokio::io::ReadBuf<'_>,
10+
) -> std::task::Poll<std::io::Result<()>> {
11+
todo!()
12+
}
13+
}
14+
impl AsyncWrite for TuicTcpStream {
15+
fn poll_write(
16+
self: std::pin::Pin<&mut Self>,
17+
cx: &mut std::task::Context<'_>,
18+
buf: &[u8],
19+
) -> std::task::Poll<Result<usize, std::io::Error>> {
20+
todo!()
21+
}
22+
23+
fn poll_flush(
24+
self: std::pin::Pin<&mut Self>,
25+
cx: &mut std::task::Context<'_>,
26+
) -> std::task::Poll<Result<(), std::io::Error>> {
27+
todo!()
28+
}
29+
30+
fn poll_shutdown(
31+
self: std::pin::Pin<&mut Self>,
32+
cx: &mut std::task::Context<'_>,
33+
) -> std::task::Poll<Result<(), std::io::Error>> {
34+
todo!()
35+
}
36+
}

crates/wind-tuic/src/inbound.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)