Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
doroved committed Dec 3, 2024
2 parents f11e056 + 9606ad7 commit a0fc7f6
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
/src/old
/src/test.rs
README_PRIVATE.md
config.test.jsonc
config.test.json5
.DS_Store
95 changes: 89 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "proxer-cli"
version = "0.3.0"
version = "0.3.1"
edition = "2021"
authors = ["doroved"]
description = "Proxy TCP traffic on macOS with domain filtering."
Expand All @@ -23,7 +23,7 @@ tokio = { version = "1.42.0", features = ["full"] }
tokio-native-tls = "0.3.1"

wildmatch = "2.4.0"
clap = { version = "4.5.21", features = ["derive"] }
clap = { version = "4.5.22", features = ["derive"] }
sha2 = "0.10.8"
base64 = "0.22.1"
bytes = "1.9.0"
Expand All @@ -33,6 +33,7 @@ http-body-util = "0.1.2"

tracing = "0.1.41"
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
json5 = "0.4.1"


[profile.release]
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,23 @@ Usage: proxer-cli [OPTIONS]
Options:
--port <u16> Set port for proxer. By default 5555.
--config <string> Path to the configuration file. Example: '/path/to/config.(jsonc|json)'. Default is ~/.proxer-cli/config.jsonc.
--config <string> Path to the configuration file. Example: '/path/to/config.(jsonc|json)'. Default is ~/.proxer-cli/config.json5.
--token <string> Secret token to access the HTTP/S proxerver. Must match the token specified in the proxerver configuration.
-h, --help Print help
-V, --version Print version
```

The default configuration file is located in `~/.proxer-cli/config.jsonc`. To edit it, you can quickly open it using the terminal command:
The default configuration file is located in `~/.proxer-cli/config.json5`. To edit it, you can quickly open it using the terminal command:

```bash
open -a TextEdit ~/.proxer-cli/config.jsonc
open -a TextEdit ~/.proxer-cli/config.json5
```

If you want to use your own configuration file, you can specify it at startup using the `--config` flag.
For example, if you are in a directory with the config, you can run proxer as follows:

```bash
proxer-cli --config ./config.jsonc
proxer-cli --config ./config.json5
```

Configuration file structure:
Expand Down Expand Up @@ -139,13 +139,13 @@ cargo build --release
3. Run the Proxer binary with configuration.

```bash
./target/release/proxer-cli --config 'config.dev.jsonc'
./target/release/proxer-cli --config 'config.dev.json5'
```

4. Or run it in background process using `nohup`.

```bash
nohup ./target/release/proxer-cli --config 'config.dev.jsonc' >/dev/null 2>&1 &
nohup ./target/release/proxer-cli --config 'config.dev.json5' >/dev/null 2>&1 &
```

5. To stop Proxer, run this command.
Expand Down
File renamed without changes.
34 changes: 34 additions & 0 deletions config.test.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"name": "Proxer Free [DE] proxerver",
"enabled": true,
"scheme": "HTTPS",
"host": "prxy.freemyip.com",
"port": 4443,
"auth_credentials": {
"username": "proxerver",
"password": "onelove"
},
"filter": [
{
"name": "YouTube",
"domains": ["*.youtube.com", "*.googlevideo.com", "*.ggpht.com", "*.ytimg.com", "youtu.be"]
},
{
"name": "Discord",
"domains": [
"discord.com",
"*.discord.com",
"*.discordapp.com",
"discord-attachments-*.storage.googleapis.com",
"*.discordapp.net",
"gateway.discord.gg"
]
},
{
"name": "Test",
"domains": ["api.ipify.org"]
}
]
}
]
10 changes: 5 additions & 5 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ if xattr ~/.proxer-cli/bin/proxer-cli | grep -q "com.apple.quarantine"; then
echo "Removed quarantine attribute from ~/.proxer-cli/bin/proxer-cli"
fi

# Check if config.jsonc exists, if not, create it
if [ ! -f ~/.proxer-cli/config.jsonc ]; then
cat <<EOL > ~/.proxer-cli/config.jsonc
# Check if config.json5 exists, if not, create it
if [ ! -f ~/.proxer-cli/config.json5 ]; then
cat <<EOL > ~/.proxer-cli/config.json5
[
{
"name": "Proxer Free [DE] proxerver",
Expand Down Expand Up @@ -91,9 +91,9 @@ if [ ! -f ~/.proxer-cli/config.jsonc ]; then
}
]
EOL
echo "Created config.jsonc in ~/.proxer-cli"
echo "Created config.json5 in ~/.proxer-cli"
else
echo "config.jsonc already exists in ~/.proxer-cli"
echo "config.json5 already exists in ~/.proxer-cli"
fi

# Add to PATH
Expand Down
2 changes: 1 addition & 1 deletion src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct Opt {
#[clap(
long,
value_name = "string",
help = "Path to the configuration file. Example: '/path/to/config.(jsonc|json)'. Default is ~/.proxer-cli/config.jsonc."
help = "Path to the configuration file. Example: '/path/to/config.(jsonc|json)'. Default is ~/.proxer-cli/config.json5."
)]
pub config: Option<String>,

Expand Down
6 changes: 3 additions & 3 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ pub async fn run() -> Result<(), Box<dyn std::error::Error>> {

// Read the config file or use the default one
let config_path = options.config.unwrap_or_else(|| {
tracing::info!("Using default config file ~/.proxer-cli/config.jsonc");
tracing::info!("Using default config file ~/.proxer-cli/config.json5");
let home_dir = std::env::var("HOME").expect("$HOME environment variable not set");
format!("{home_dir}/.proxer-cli/config.jsonc")
format!("{home_dir}/.proxer-cli/config.json5")
});

let config = fs::read_to_string(&config_path)
.unwrap_or_else(|_| panic!("Failed to read config file: {config_path}"));
let parsed_config: Vec<ProxyConfig> = serde_json::from_str(&config)
let parsed_config: Vec<ProxyConfig> = json5::from_str(&config)
.unwrap_or_else(|_| panic!("Failed to parse config file: {config_path}"));
let proxy_config_arc = Arc::new(parsed_config);

Expand Down

0 comments on commit a0fc7f6

Please sign in to comment.