Skip to content

Commit

Permalink
fmt & doc
Browse files Browse the repository at this point in the history
  • Loading branch information
zephyrchien committed Jul 8, 2021
1 parent 352c841 commit 6d3b361
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 9 deletions.
29 changes: 23 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,28 @@ realm is a simple, high performance relay server written in rust.
- Low resources cost.

## Usage
This executable takes 2 arguments:
- -l [--local] local socket address. Default address 127.0.0.1 is used when the address is omitted.
- -r [--remote] remote socker address. Both domain and ip address are accepted. If a domain is passed, the resolver will try to resolve and update the ip address regularly, ipv4 is preferred.

An example to listen on port 30000 and forwarding traffic to example.com:12345 is as follows.
```bash
realm -c config.json
```
>example.json
```json
{
"dns_mode": "Ipv4Only",
"endpoints": [
{
"local": "0.0.0.0:5000",
"remote": "1.1.1.1:443",
"udp": false
}
{
"local": "0.0.0.0:10000",
"remote": "www.google.com:443",
"udp": true
}
]
}
```
>dns_mode
```
./realm -l 127.0.0.1:30000 -r example.com:12345
Ipv4Only|Ipv6Only|Ipv4AndIpv6|Ipv4thenIpv6|Ipv6thenIpv4
```
13 changes: 13 additions & 0 deletions src/cmd/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
use clap::{Arg, App, SubCommand};

mod nav;
pub use nav::run_navigator;

pub enum CmdInput {
Config(String),
Navigate,
None,
}

Expand All @@ -17,9 +21,18 @@ pub fn scan() -> CmdInput {
.help("specify a config file in json format")
.takes_value(true),
)
.subcommand(
SubCommand::with_name("nav")
.about("An Interactive configuration editor")
.version("0.1.0")
.author("zephyr <i@zephyr.moe>"),
)
.get_matches();
if let Some(config) = matches.value_of("config") {
return CmdInput::Config(config.to_string());
}
if let Some(_) = matches.subcommand_matches("nav") {
return CmdInput::Navigate;
}
CmdInput::None
}
3 changes: 3 additions & 0 deletions src/cmd/nav.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub fn run_navigator() {
todo!()
}
1 change: 0 additions & 1 deletion src/config/endpoint_config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use serde::{Serialize, Deserialize};

use crate::relay::Endpoint;

#[derive(Debug, Serialize, Deserialize)]
Expand Down
1 change: 0 additions & 1 deletion src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use serde::{Serialize, Deserialize};

mod dns_mode;
mod endpoint_config;

pub use dns_mode::DnsMode;
pub use endpoint_config::EndpointConfig;

Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use relay::Endpoint;
fn main() {
match cmd::scan() {
CmdInput::Config(c) => start_from_config(c),
CmdInput::Navigate => cmd::run_navigator(),
CmdInput::None => {}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/relay/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ mod dns;
mod tcp;
mod udp;
mod types;

pub use types::{Endpoint, RemoteAddr};
pub use dns::init_resolver;

Expand Down

0 comments on commit 6d3b361

Please sign in to comment.