diff --git a/readme.md b/readme.md index edc3df70..600e5f7f 100644 --- a/readme.md +++ b/readme.md @@ -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 ``` diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs index b60e32b2..4079fda9 100644 --- a/src/cmd/mod.rs +++ b/src/cmd/mod.rs @@ -1,7 +1,11 @@ use clap::{Arg, App, SubCommand}; +mod nav; +pub use nav::run_navigator; + pub enum CmdInput { Config(String), + Navigate, None, } @@ -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 "), + ) .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 } diff --git a/src/cmd/nav.rs b/src/cmd/nav.rs new file mode 100644 index 00000000..297cac73 --- /dev/null +++ b/src/cmd/nav.rs @@ -0,0 +1,3 @@ +pub fn run_navigator() { + todo!() +} diff --git a/src/config/endpoint_config.rs b/src/config/endpoint_config.rs index c91a8dca..13f3df30 100644 --- a/src/config/endpoint_config.rs +++ b/src/config/endpoint_config.rs @@ -1,5 +1,4 @@ use serde::{Serialize, Deserialize}; - use crate::relay::Endpoint; #[derive(Debug, Serialize, Deserialize)] diff --git a/src/config/mod.rs b/src/config/mod.rs index 4a15f2e9..8e58f86e 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -4,7 +4,6 @@ use serde::{Serialize, Deserialize}; mod dns_mode; mod endpoint_config; - pub use dns_mode::DnsMode; pub use endpoint_config::EndpointConfig; diff --git a/src/main.rs b/src/main.rs index 6ccd9e04..9eaf28db 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 => {} } } diff --git a/src/relay/mod.rs b/src/relay/mod.rs index 940bc673..87bb0ed7 100644 --- a/src/relay/mod.rs +++ b/src/relay/mod.rs @@ -8,7 +8,6 @@ mod dns; mod tcp; mod udp; mod types; - pub use types::{Endpoint, RemoteAddr}; pub use dns::init_resolver;