Skip to content

Commit

Permalink
minor change
Browse files Browse the repository at this point in the history
  • Loading branch information
neevek committed Apr 5, 2024
1 parent 1db901f commit 46d0974
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
rstun
=====

A secured UDP tunnel written in Rust.
A secure UDP tunnel written in Rust.

rstun builds on [Quinn](https://github.com/quinn-rs/quinn), which is an implementation of the IETF [QUIC](https://quicwg.org/) transport protocol.

rstun consists of two binaries, `rstunc` for client and `rstund` for server. `rstund` accepts connections from `rstunc`.

`rstunc` connects to the server to build a secured tunnel to allow data to be exchanged between two ends, it initiates the connection in one of two modes:
`rstunc` connects to the server to build a secure tunnel to allow data to be exchanged between two ends, it initiates the connection in one of two modes:

* The `IN` mode for exposing a local port to the internet through the server.
* The `OUT` mode for securing data going out from local to the internet through the server.
Expand Down Expand Up @@ -42,7 +42,7 @@ rstunc
--cert path/to/cert.der \
--addr-mapping 0.0.0.0:9900^8800
```
- `mode` here is `OUT` for `TunnelOut`, for securing traffic from local to the server through the tunnel.
- `mode` here is `OUT`, for securing traffic from local to the server through the tunnel.
- `server-addr`, domain name or IP address of the server.
- `password`, same as that for the server.
- `cert`, see explanation above for `rstund`. Note this is also optional if connecting to the server with a domain name, or the server `rstund` runs with an auto-generated self-signed certificate (see the TEST example below).
Expand All @@ -53,7 +53,7 @@ rstunc

* Simple TEST example

The following commands run a server and a client that connects to the server in their simplest ways:
The following commands run a server, then a client that connects to the server in their simplest ways:


```
Expand Down
2 changes: 1 addition & 1 deletion src/bin/rstund.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ struct RstundArgs {

/// Exposed upstreams as the receiving end of the tunnel, e.g. -d [ip:]port,
/// The entire local network is exposed through the tunnel if empty
#[arg(short = 'd', long, required = false)]
#[arg(short = 'u', long, required = false)]
upstreams: Vec<String>,

/// Password of the tunnel server
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub struct ServerConfig {

pub(crate) enum ReadResult {
Succeeded,
EOF,
Eof,
}

impl ClientConfig {
Expand Down Expand Up @@ -223,7 +223,7 @@ impl ClientConfig {
impl ReadResult {
#![allow(dead_code)]
pub fn is_eof(&self) -> bool {
matches!(self, Self::EOF)
matches!(self, Self::Eof)
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/tunnel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl Tunnel {
tokio::spawn(async move {
loop {
let result = Self::tcp_to_quic(&mut tcp_read, &mut quic_send).await;
if let Ok(ReadResult::EOF) | Err(_) = result {
if let Ok(ReadResult::Eof) | Err(_) = result {
break;
}
}
Expand All @@ -39,7 +39,7 @@ impl Tunnel {
tokio::spawn(async move {
loop {
let result = Self::quic_to_tcp(&mut tcp_write, &mut quic_recv).await;
if let Ok(ReadResult::EOF) | Err(_) = result {
if let Ok(ReadResult::Eof) | Err(_) = result {
break;
}
}
Expand All @@ -57,7 +57,7 @@ impl Tunnel {
Ok(ReadResult::Succeeded)
} else {
quic_send.finish().await?;
Ok(ReadResult::EOF)
Ok(ReadResult::Eof)
}
}

Expand All @@ -71,7 +71,7 @@ impl Tunnel {
tcp_write.write_all(&buffer[..len_read]).await?;
Ok(ReadResult::Succeeded)
} else {
Ok(ReadResult::EOF)
Ok(ReadResult::Eof)
}
}
}

0 comments on commit 46d0974

Please sign in to comment.