Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# 构建
cargo build --release

# 运行(默认监听 0.0.0.0:1323)
# 运行(默认监听 127.0.0.1:1323)
./target/release/font_obfuscator

# 自定义端口
Expand All @@ -38,6 +38,7 @@ PORT=8080 ./target/release/font_obfuscator
| 变量 | 默认值 | 说明 |
|------|--------|------|
| `PORT` | `1323` | 服务监听端口 |
| `LISTEN_ADDR` | `127.0.0.1` | 服务监听地址 |
| `BASE_FONT_PATH` | `base-font/KaiGenGothicCN-Regular.ttf` | 基础字体文件路径 |

### API
Expand Down Expand Up @@ -159,7 +160,7 @@ Built with Rust, using Google's [fontations](https://github.com/googlefonts/font
# Build
cargo build --release

# Run (listens on 0.0.0.0:1323 by default)
# Run (listens on 127.0.0.1:1323 by default)
./target/release/font_obfuscator

# Custom port
Expand All @@ -171,6 +172,7 @@ PORT=8080 ./target/release/font_obfuscator
| Variable | Default | Description |
|----------|---------|-------------|
| `PORT` | `1323` | Server listening port |
| `LISTEN_ADDR` | `127.0.0.1` | Server listen address |
| `BASE_FONT_PATH` | `base-font/KaiGenGothicCN-Regular.ttf` | Base font file path |

### API
Expand Down
2 changes: 2 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ impl Default for FontConfig {
#[derive(Clone)]
pub struct AppConfig {
pub port: u16,
pub listen_addr: String,
pub font: FontConfig,
pub base_font_path: String,
}
Expand All @@ -35,6 +36,7 @@ impl AppConfig {
.ok()
.and_then(|p| p.parse().ok())
.unwrap_or(1323),
listen_addr: env::var("LISTEN_ADDR").unwrap_or_else(|_| "127.0.0.1".into()),
font: FontConfig::default(),
base_font_path: env::var("BASE_FONT_PATH")
.unwrap_or_else(|_| "base-font/KaiGenGothicCN-Regular.ttf".into()),
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async fn main() {
})
});

let addr = format!("0.0.0.0:{}", config.port);
let addr = format!("{}:{}", config.listen_addr, config.port);
tracing::info!("服务启动于 {}", addr);

let state = Arc::new(AppState { config, font_data });
Expand Down