Skip to content

Repository files navigation

Local Rate Limit - 本地域名限流工具


English

Overview

Local Rate Limit is a lightweight desktop application for monitoring and controlling network traffic at the domain level. It helps developers and users manage API request rates, debug network issues, and prevent rate limiting problems during development.

Screenshots

Home Dashboard

Home Dashboard

Real-time traffic statistics, rate limit status overview, and traffic trend charts with upload/download speed visualization.

Traffic Funnel

Traffic Funnel

Domain traffic aggregation with search, system proxy toggle, real-time request inspection (Fiddler-style), double-click domain filtering, and configurable detail retention count.

Logs

Logs

Comprehensive logging system with type filtering, time range selection, full-text search, and CSV export.

Settings

Settings

Application preferences including language, theme, auto-start, close behavior, log retention, and refresh interval.

Features

  • Domain-level Rate Limiting: Configure request limits per domain with flexible time windows (per second, minute, hour, or day)
  • Real-time Traffic Monitoring: Visual dashboard showing upload/download speeds, request counts, and traffic trends
  • Request Inspection: Detailed request logs similar to Fiddler, showing domain, protocol, method, and data sizes
  • Smart Queue Management: Requests exceeding limits are queued instead of rejected, with configurable timeout handling
  • HTTPS Inspection: Optional MITM proxy with a locally-generated CA certificate for decrypting and rate-limiting HTTPS traffic
  • System Proxy Control: One-click toggle to enable/disable system proxy (port 5678); auto-restores original settings on exit
  • Traffic Analysis: Aggregate statistics by domain with sortable, searchable lists
  • Domain Filter Tags: Double-click a domain to add filter tags for quick traffic detail filtering
  • Configurable Detail Retention: Choose to keep the latest 10, 100, or 1000 traffic detail entries
  • Comprehensive Logging: Track rate limit events, user operations, and system events with CSV export
  • Multi-language Support: English and Chinese interface
  • Theme Support: Light, dark, or system-following themes
  • System Tray Integration: Minimize to tray with quick access controls
  • Privacy First: All data stored locally, no cloud services required

Technology Stack

Layer Technology Description
Frontend Vue 3 + TypeScript UI framework (Composition API)
Styling Native CSS + CSS Variables Theme switching via CSS variables
Build Tool Vite Frontend bundler
Router Vue Router 4 SPA routing with lazy loading
i18n Custom implementation Chinese/English, localStorage persistence
Charts Chart.js + vue-chartjs Traffic trend visualization
Backend Rust Core logic
Framework Tauri v2 Cross-platform desktop framework
Async Tokio Rust async runtime
Error Handling thiserror Custom RateLimitError type
Proxy hyper 1.x + hyper-util HTTP proxy server
TLS tokio-rustls + rustls HTTPS MITM decryption
Certificate rcgen CA and dynamic leaf cert signing

Architecture

[System App] → [System Proxy (127.0.0.1:5678)] → [Rate Limiter] → [Target Server]
                      ↑                                    ↑
                      └────────── [Traffic Monitor] ──────┘
  1. One-click enable system proxy pointing to local proxy server (port 5678)
  2. All outbound HTTP/HTTPS requests pass through the local proxy
  3. Proxy server parses requests, extracts domain information
  4. Requests enter the rate limiter for rate control
  5. Requests within limits are forwarded directly; excess requests are queued
  6. Queued requests are sent in order with delay

Platform Support

  • Windows 10/11 (64-bit)
  • macOS 12+
  • Linux (gsettings-based desktops, e.g. GNOME)

Installation

Download Pre-built Package

Download the latest installer from the Releases page.

From Source

Prerequisites:

  • Node.js v18+
  • Rust v1.77.2+
  • Tauri CLI (cargo install tauri-cli)

Steps:

# Clone the repository
git clone https://github.com/zdl/local-rate-limit.git
cd local-rate-limit

# Install frontend dependencies
npm install

# Start development mode
cargo tauri dev

# Build for production
cargo tauri build

The built installer will be available in src-tauri/target/release/bundle/.

Usage

  1. Launch the application - The app starts with the Home dashboard
  2. Enable system proxy - Toggle the system proxy switch on the Traffic Funnel page
  3. View traffic overview - Check the Home page for real-time statistics and trends
  4. Configure rate limits - Go to Traffic Funnel page, select a domain, and set limits
  5. Monitor requests - View detailed request logs in the Traffic Funnel page
  6. Filter by domain - Double-click a domain in the aggregation list to filter details
  7. Check logs - Review rate limit events and system logs in the Logs page
  8. Adjust settings - Configure language, theme, and system preferences in Settings

Development

# Frontend development only
npm run dev

# Full stack development
cargo tauri dev

# Build production version
npm run build
cargo tauri build

Project Structure

locla-rate-limit/
├── src/                    # Frontend (Vue 3)
│   ├── components/         # Reusable components
│   ├── pages/              # Route pages
│   ├── i18n/               # Internationalization
│   ├── lib/                # Utilities (IPC layer, etc.)
│   ├── types/              # TypeScript type definitions
│   └── style.css           # Global styles & CSS variables
├── src-tauri/              # Backend (Rust + Tauri)
│   ├── src/
│   │   ├── domain/         # Core business logic
│   │   │   ├── proxy/      # HTTP/HTTPS proxy server + MITM
│   │   │   ├── rate_limiter/  # Token bucket + request queue
│   │   │   ├── traffic_monitor/  # Traffic capture
│   │   │   ├── certificate.rs    # CA certificate management
│   │   │   ├── system_proxy.rs   # OS proxy configuration
│   │   │   ├── settings.rs       # App settings store
│   │   │   └── logger.rs         # Logging system
│   │   └── main.rs         # App entry & Tauri commands
│   ├── Cargo.toml          # Rust dependencies
│   └── tauri.conf.json     # Tauri configuration
├── images/                 # Screenshots for README
└── package.json            # Frontend dependencies

Contributing

Contributions are welcome! Please read CONTRIBUTING.md for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.


中文

概述

本地域名限流工具是一款轻量级桌面应用程序,用于在域名级别监控和控制网络流量。它帮助开发者和用户管理 API 请求速率、调试网络问题,并在开发过程中防止触发速率限制。

界面截图

首页仪表盘

首页仪表盘

实时流量统计、限流状态总览,以及带上传/下载速度可视化的流量趋势图表。

流量漏斗

流量漏斗

域名流量聚合(支持搜索、系统代理开关),实时请求明细(Fiddler 风格),双击域名筛选,可配置明细保留条数。

日志页面

日志页面

完整的日志系统,支持类型筛选、时间范围选择、全文搜索和 CSV 导出。

设置页面

设置页面

应用偏好设置,包括语言、主题、开机自启、关闭行为、日志保留时长和刷新间隔。

功能特性

  • 域名级限流:为每个域名配置灵活的请求限制(按秒、分钟、小时或天)
  • 实时监控:可视化仪表板显示上传/下载速度、请求数量和流量趋势
  • 请求检查:类似 Fiddler 的详细请求日志,显示域名、协议、方法和数据大小
  • 智能队列管理:超出限制的请求进入队列而非直接拒绝,支持可配置的超时处理
  • HTTPS 解密:可选的 MITM 代理,通过本地生成的 CA 证书解密并对 HTTPS 流量进行限流
  • 系统代理控制:一键开关系统代理(端口 5678),退出时自动恢复原始设置
  • 流量分析:按域名聚合统计,支持排序和搜索
  • 域名筛选标签:双击域名添加筛选标签,快速过滤流量明细
  • 可配置明细保留数:选择保留最新 10、100 或 1000 条流量明细
  • 完整日志系统:记录限流事件、用户操作和系统事件,支持 CSV 导出
  • 多语言支持:中英文界面切换
  • 主题支持:浅色、深色或跟随系统主题
  • 系统集成:最小化到系统托盘,提供快捷操作
  • 隐私优先:所有数据本地存储,无需云服务

技术栈

层级 技术 说明
前端 Vue 3 + TypeScript UI 框架(Composition API)
样式 原生 CSS + CSS 变量 主题切换通过 CSS 变量实现
构建工具 Vite 前端构建
路由 Vue Router 4 SPA 路由,懒加载
国际化 自实现 i18n 中英双语,localStorage 持久化
图表 Chart.js + vue-chartjs 流量趋势图
后端 Rust 核心逻辑
框架 Tauri v2 跨平台桌面应用框架
异步 Tokio Rust 异步运行时
错误处理 thiserror 自定义 RateLimitError 类型
代理 hyper 1.x + hyper-util HTTP 代理服务器
TLS tokio-rustls + rustls HTTPS MITM 解密
证书 rcgen CA 与动态叶子证书签发

架构原理

[系统应用] → [系统代理 (127.0.0.1:5678)] → [限流器] → [目标服务器]
                      ↑                                  ↑
                      └──────── [流量监控] ──────────────┘
  1. 一键开启系统代理,指向本地代理服务器(端口 5678)
  2. 所有出站 HTTP/HTTPS 请求经过本地代理
  3. 代理服务器解析请求,提取域名信息
  4. 请求进入限流器进行速率控制
  5. 符合限制的请求直接转发,超出限制的请求进入队列等待
  6. 队列中的请求按顺序延迟发送

平台支持

  • Windows 10/11(64 位)
  • macOS 12+
  • Linux(基于 gsettings 的桌面环境,如 GNOME)

安装方法

下载预构建安装包

Releases 页面下载最新安装包。

从源码构建

环境要求:

  • Node.js v18+
  • Rust v1.77.2+
  • Tauri CLI(cargo install tauri-cli

步骤:

# 克隆仓库
git clone https://github.com/zdl/local-rate-limit.git
cd local-rate-limit

# 安装前端依赖
npm install

# 启动开发模式
cargo tauri dev

# 构建生产版本
cargo tauri build

构建的安装包位于 src-tauri/target/release/bundle/ 目录。

使用说明

  1. 启动应用 - 应用启动后进入首页仪表盘
  2. 开启系统代理 - 在流量漏斗页面点击系统代理开关
  3. 查看流量概览 - 在首页查看实时统计数据和趋势图
  4. 配置限流规则 - 进入流量漏斗页面,选择域名并设置限制
  5. 监控请求 - 在流量漏斗页面查看详细请求日志
  6. 按域名筛选 - 双击聚合列表中的域名,添加筛选标签过滤明细
  7. 检查日志 - 在日志页面查看限流事件和系统日志
  8. 调整设置 - 在设置页面配置语言、主题和系统偏好

开发指南

# 仅前端开发
npm run dev

# 全栈开发
cargo tauri dev

# 构建生产版本
npm run build
cargo tauri build

项目结构

locla-rate-limit/
├── src/                    # 前端代码 (Vue 3)
│   ├── components/         # 可复用组件
│   ├── pages/              # 路由页面
│   ├── i18n/               # 国际化
│   ├── lib/                # 工具函数(IPC 层等)
│   ├── types/              # TypeScript 类型定义
│   └── style.css           # 全局样式 & CSS 变量
├── src-tauri/              # 后端代码 (Rust + Tauri)
│   ├── src/
│   │   ├── domain/         # 核心业务逻辑
│   │   │   ├── proxy/      # HTTP/HTTPS 代理服务器 + MITM
│   │   │   ├── rate_limiter/  # 令牌桶 + 请求队列
│   │   │   ├── traffic_monitor/  # 流量捕获
│   │   │   ├── certificate.rs    # CA 证书管理
│   │   │   ├── system_proxy.rs   # 系统代理配置
│   │   │   ├── settings.rs       # 应用设置存储
│   │   │   └── logger.rs         # 日志系统
│   │   └── main.rs         # 应用入口 & Tauri 命令
│   ├── Cargo.toml          # Rust 依赖配置
│   └── tauri.conf.json     # Tauri 配置
├── images/                 # README 截图
└── package.json            # 前端依赖配置

贡献指南

欢迎贡献!请阅读 CONTRIBUTING.md 了解详情。

许可证

本项目基于 MIT 许可证授权 - 详见 LICENSE 文件。


Made with Rust + Vue 3 + Tauri v2

About

Windows本地域名/API限流工具,自定义域名请求频率限制、域名流量节流,提供x64一键安装包

Topics

Resources

Code of conduct

Contributing

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages