Skip to content

Commit

Permalink
[Feat]: ports flag is available
Browse files Browse the repository at this point in the history
  • Loading branch information
FMotalleb committed Apr 6, 2023
1 parent bfa2f43 commit 3300543
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "absolutus_rex"
version = "0.1.0"
version = "0.2.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Absolutus Rex

**absolutus_rex** is a CLI tool to forward ports. The name means "Absolute King" in Latin. It is currently on version 0.1.0.
**absolutus_rex** is a CLI tool to forward ports. The name means "Absolute King" in Latin. It is currently on version 0.2.0.

## Usage

Expand Down Expand Up @@ -29,14 +29,14 @@ sequenceDiagram

### Options

- `-p, --port <PORT>`: Local port - requires a local port that is available for use [default: 8990]
- `-p, --ports <PORTS>`: Local port - requires a local port that are available for use
- `-l, --local-only`: This flag only opens a port on the local network (127.0.0.1), and is intended for debugging purposes
- `-a, --r-address <REMOTE_ADDRESS>`: This flag sets the remote address
- `--r-port <REMOTE_PORT>`: This flag sets the remote port
- `-h, --help`: Print help (see more with '--help')
- `-V, --version`: Print version

Note: The `--r-address` and `--r-port` options are required.
Note: The `--r-address`, `--r-port` and `--ports` options are required.

## Installation

Expand Down
23 changes: 12 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use std::fmt;
long_about = "Absolutus Rex is a command-line tool for port forwarding.\n\nThis tool can be used to forward ports, and may be particularly useful when used with `supervisord`."
)]
struct Args {
/// Local port - requires a local port that is available for use.
#[arg(short, long, default_value_t = 8990)]
port: u16,
/// Local ports - requires local ports that are available for use.
#[arg(short, long)]
ports: Vec<u16>,

/// This flag only opens a port on the local network (127.0.0.1), and is intended for debugging purposes.
#[arg(short, long, default_value_t = false)]
Expand All @@ -29,16 +29,17 @@ fn main() {
let args = Args::parse();
let remote = fmt::format(format_args!("{}:{}", args.remote_address, args.remote_port));
println!("Application ran with config:");
println!("\tPort: `{}`", args.port);
println!("\tIs Local Only: {}!", args.local_only);
println!("\tRemote Address: `{}`", remote);
match TcpProxy::new(args.port, remote.parse().unwrap(), args.local_only) {
Ok(_proxy) => {
println!("Proxy State: OK!");
}
e => {
println!("Proxy State: ERROR!");
println!("Reason: {}", e.err().unwrap());
for port in args.ports {
match TcpProxy::new(port, remote.parse().unwrap(), args.local_only) {
Ok(_proxy) => {
println!("\tPort: {},Proxy State: OK!", port);
}
e => {
println!("Port: {},Proxy State: ERROR!", port);
println!("Reason: {}", e.err().unwrap());
}
}
}

Expand Down

0 comments on commit 3300543

Please sign in to comment.