Skip to content

Commit f811759

Browse files
committed
設定ファイルをJSON5にできるようにした
1 parent fb2c878 commit f811759

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

local_proxy/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ async-trait = "0.1"
1818
tokio-rustls = "0.24"
1919
rustls-native-certs = "0.6"
2020
serde = { version = "1", features = ["derive"] }
21-
serde_json = "1"
21+
json5 = "0.4"
2222
dns-parser = "0.8"
2323
futures-util = "0.3"
2424
bytes = "1"

local_proxy/src/main.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ mod utils;
88

99
use crate::{config::Config, outbound::ProxyOutBound};
1010

11-
use std::io::Write;
11+
use std::io::{Read, Write};
1212
use tokio::{
1313
io::{AsyncRead, AsyncWrite},
1414
sync::RwLock,
@@ -27,8 +27,12 @@ async fn main() {
2727
let stdin = std::io::stdin();
2828
let mut stdout = std::io::stdout();
2929

30-
let mut config: Config =
31-
serde_json::from_reader(std::fs::File::open("./config.json").unwrap()).unwrap();
30+
let mut config = String::new();
31+
std::fs::File::open("./config.json")
32+
.unwrap()
33+
.read_to_string(&mut config)
34+
.unwrap();
35+
let mut config: Config = json5::from_str(&config).unwrap();
3236

3337
let mut proxy_stack: Vec<Box<dyn ProxyOutBound>> = vec![Box::new(outbound::Raw::new())];
3438
if let Some(proxies) = &mut config.proxies {

0 commit comments

Comments
 (0)