175 Commits

Author SHA1 Message Date
006fa9a172 refactor(metrics): 移除延迟分布统计的冗余日志输出
- 删除 RecordRequest 和 GetStats 方法中的详细日志记录
- 保留核心的延迟分布统计逻辑,提高代码简洁性
- 减少不必要的日志输出,优化性能和可读性
2025-03-09 12:16:44 +08:00
2a41458bb8 feat(metrics): 添加引用来源统计持久化支持
- 在 MetricsStorage 结构体中新增 refererStatsFile 字段
- 在 SaveMetrics 方法中添加引用来源统计保存逻辑
- 在 LoadMetrics 方法中实现引用来源统计的加载和恢复
- 前端页面调整路径显示,增加长路径的截断处理
- 优化引用来源统计的数据处理和类型转换
2025-03-09 12:02:32 +08:00
d2e5020d22 feat(metrics): 优化延迟分布数据处理逻辑
- 增加对延迟分布数据的类型兼容性处理
- 新增直接使用 map[string]int64 类型的处理分支
- 优化日志输出,提供更详细的类型转换信息
- 在处理结束后打印最终的延迟分布数据
- 改进错误处理和类型转换的健壮性
2025-03-09 11:49:37 +08:00
f2e1b8cbf5 feat(metrics): 统一延迟分布桶命名并优化日志记录
- 将延迟分布桶键名从 "<10ms" 和 ">1s" 改为 "lt10ms" 和 "gt1s"
- 在指标处理和收集过程中添加详细日志,帮助诊断数据处理流程
- 前端页面适配新的桶键名,并提供友好的显示转换
- 增强延迟分布数据处理的健壮性和可读性
2025-03-09 11:43:26 +08:00
2cb88a4f5e fix(metrics): 优化延迟统计和分布数据处理
- 修复延迟统计分布数据获取逻辑,增加更健壮的类型转换
- 确保延迟分布桶始终存在,即使没有数据
- 在处理器中为空分布数据添加默认初始化
- 优化指标收集器中的延迟桶初始化和数据获取方法
2025-03-09 11:33:47 +08:00
b6b77b03ed feat(metrics): 增强指标展示和统计功能
- 在指标结构中新增延迟统计、错误统计和引用来源统计字段
- 更新前端仪表盘,添加延迟、带宽、错误和引用来源统计卡片
- 优化指标收集器,支持引用来源和错误类型统计
- 在工具函数中新增字符串转整数解析方法
- 简化引用来源URL处理,提取域名信息
2025-03-09 11:24:46 +08:00
f0c806292b feat(metrics): 完善指标存储服务集成
- 在主程序中添加指标存储服务初始化和停止逻辑
- 更新指标收集器的保存方法,支持外部指标存储服务
- 优化静态文件服务路径,使用新的 web/dist 目录
- 调整静态文件处理逻辑,支持更灵活的路由
2025-03-09 11:00:39 +08:00
e67a3880f5 删除统计保存功能 2025-03-09 10:48:43 +08:00
a0cea8f5b8 feat(metrics): 增强指标收集和恢复日志记录
- 在指标初始化和加载过程中添加详细日志
- 改进指标恢复逻辑,支持从不同数据结构恢复统计信息
- 添加更多日志输出,帮助诊断指标加载问题
- 优化数据验证逻辑,允许小范围的统计数据误差
- 增加对未找到数据的日志提示
2025-03-09 10:41:24 +08:00
095b087fd8 refactor(metrics): 优化指标收集和内存管理
- 修改路径统计数据结构为指针类型,提高性能
- 使用原子操作方法替换旧的原子操作
- 添加内存释放和垃圾回收机制
- 限制路径统计数量,只保留前20个路径
- 优化指标保存和文件清理逻辑,减少内存使用
2025-03-09 10:35:00 +08:00
4276709b3f feat(config): 添加指标保存间隔和最大文件数的默认值处理
- 在配置解析中新增 MetricsSaveInterval 和 MetricsMaxFiles 字段
- 在前端页面为指标配置添加默认值(15分钟间隔,10个文件)
- 更新配置解析逻辑以支持新的指标相关配置
2025-03-09 05:47:41 +08:00
015aa6bc15 feat(metrics): 增加指标保存和管理功能
- 在配置中新增指标保存间隔和最大文件数量设置
- 实现定期自动保存指标数据到文件
- 添加指标文件自动清理机制
- 优化指标收集和存储逻辑
- 在Web界面添加指标设置选项卡
2025-03-09 05:41:22 +08:00
3810153f8e refactor(auth): Update OAuth URLs and button text for CZL Connect integration 2025-03-03 23:08:27 +08:00
4af1592021 删除固定路径代理配置, 因为普通代理好像已经支持了 2025-03-03 06:47:52 +08:00
f614692f33 refactor(auth): Remove user allowlist filtering
- Delete `isAllowedUser` function for user authorization
- Remove environment variable `OAUTH_ALLOWED_USERS` from docker-compose
- Eliminate user whitelist check in OAuth callback handler
2025-02-20 02:50:43 +08:00
929d13157d refactor(proxy): Optimize hop-by-hop header handling and routing logic
- Simplify hop-by-hop headers initialization using map literal
- Create a local copy of hop headers to improve header filtering
- Enhance routing logic with context-based timeout for alternative target checks
- Improve error handling and logging in file size and routing detection
- Reduce unnecessary goroutine complexity in target URL selection
2025-02-18 13:34:50 +08:00
f7a52a1be5 feat(config): Add max file size threshold and improve path configuration
- Extend PathConfig with MaxSize parameter to define upper file size limit
- Update routing logic to handle both minimum and maximum file size thresholds
- Enhance frontend configuration UI to support max size input
- Improve file routing decision-making with comprehensive size range checks
2025-02-17 18:12:16 +08:00
69050adf57 refactor(routing): Improve file size detection and alternative target routing
- Enhance file size retrieval with fallback mechanisms for alternative and default sources
- Improve logging for file size detection and routing decisions
- Remove unused cache hit check function
- Optimize routing logic for extension-mapped targets
2025-02-17 17:56:29 +08:00
429664b598 feat(routing): Add target URL accessibility check for extension mapping
- Implement `isTargetAccessible` function to validate alternative target URLs
- Add fallback mechanism when alternative target is not reachable
- Enhance routing logic to prevent potential broken redirects
- Log detailed information about routing decisions and accessibility checks
2025-02-17 17:28:25 +08:00
76b549aa90 refactor(metrics): Enhance path metrics sorting with secondary lexicographic ordering
- Update path metrics sorting to consider request count and path name
- Implement secondary sorting by path name when request counts are equal
- Improve deterministic ordering of metrics for consistent display
2025-02-17 08:36:05 +08:00
ed63121a00 refactor(metrics): Introduce JSON-friendly metrics serialization
- Create PathMetricsJSON struct for clean JSON serialization
- Add ToJSON method to convert PathMetrics to JSON-compatible representation
- Update metrics handlers and collectors to use new JSON-friendly type
- Simplify type conversion in SafePathMetrics utility function
- Improve metrics data transfer and serialization consistency
2025-02-17 08:01:29 +08:00
55d3a9cebc refactor(metrics): Update metrics collection with atomic operations and improved type safety
- Replace manual increment methods with atomic store operations in PathMetrics
- Enhance GetStats method to handle different metric types and convert to value slice
- Update RequestLog JSON tags for consistent naming
- Add SafePathMetrics conversion for mixed pointer and value slices
- Improve type safety and consistency in metrics tracking
2025-02-17 07:56:52 +08:00
d0d752712e refactor(metrics): Comprehensive metrics system redesign with improved performance tracking
- Refactor Collector struct to use more efficient atomic counters and data structures
- Implement robust bandwidth tracking with sliding window mechanism
- Enhance path metrics with atomic operations and improved type safety
- Add data consistency checker for metrics integrity
- Optimize request logging with a more memory-efficient queue
- Simplify metrics collection and reporting logic
- Improve frontend metrics display with more detailed status code visualization
2025-02-17 07:46:58 +08:00
ff24191146 feat(dashboard): Enhance configuration management with advanced validation and UX improvements
- Add comprehensive input validation for path mappings, extension maps, and fixed paths
- Implement confirmation dialogs for deletion of paths, extensions, and fixed paths
- Improve error handling with detailed toast messages
- Add dynamic dialog state management for better user experience
- Enhance extension map editing with edit and delete functionality
- Implement more robust configuration import validation
2025-02-17 07:12:13 +08:00
4b1c774509 refactor(metrics): Optimize atomic counter initialization and status code tracking
- Refactor counter initialization to use pointer creation for better type safety
- Simplify atomic counter handling in RecordRequest method
- Add status code statistics collection with atomic load operations
- Improve consistency in counter initialization across different metrics tracking
2025-02-17 06:59:49 +08:00
e9aad806f8 refactor(metrics): Improve atomic counter handling and type safety in metrics collection
- Optimize latency bucket counter initialization using pointer creation
- Add type checking when loading latency distribution metrics
- Simplify counter initialization and access in metrics collector
- Enhance type safety for atomic counter operations
2025-02-17 06:36:38 +08:00
92910a608f feat(metrics): Add interval-based metrics tracking and reporting
- Implement time-interval statistics for requests, errors, and bytes
- Add per-second metrics calculation for requests and bandwidth
- Enhance GetStats method to return interval-specific performance data
- Track and reset interval status codes dynamically
- Improve metrics granularity with more detailed performance insights
2025-02-17 06:13:24 +08:00
a4437b9a39 feat(auth): Implement OAuth-based authentication with Q58 platform
- Replace password-based login with OAuth authentication
- Add OAuth login and callback handlers
- Support user whitelist via environment variables
- Update login page to use OAuth flow
- Remove legacy metrics-related authentication configuration
- Enhance token management with username tracking
2025-02-17 05:43:23 +08:00
5c3fb00d57 feat(dashboard): Add clickable links to paths in metrics tables
- Make top paths and recent requests table entries clickable
- Open links in new tabs with appropriate security attributes
- Add hover and color styles to improve link visibility and interaction
2025-02-16 20:46:41 +08:00
41f5b82661 feat(metrics): Enhance uptime formatting with more precise time display
- Update FormatUptime to include seconds in time representation
- Modify metrics handler to use new uptime formatting method
- Improve readability of uptime display with more granular time details
2025-02-16 20:24:31 +08:00
4e3a17ecd4 refactor(logging): Standardize logging format across components
- Update logging in cache, auth, proxy, metrics, and fixed path middleware
- Add consistent log message structure with method, path, status, and source
- Improve error logging with more descriptive and uniform messages
- Enhance log readability by using concise and informative log formats
2025-02-16 14:34:49 +08:00
1f277997d3 feat(cache): Enhance cache file management and cleanup
- Add startup cleanup of stale and temporary files
- Modify ClearCache to remove all cache files except config
- Implement cleanStaleFiles method to remove orphaned and temporary cache files
- Improve file management by tracking and cleaning unused cache entries
2025-02-16 14:22:51 +08:00
b63f38c95d feat(cache): Add persistent configuration storage for cache manager
- Implement saveConfig and loadConfig methods to persist cache settings
- Add JSON-based configuration file in cache directory
- Support loading and saving cache configuration (max age, cleanup interval, cache size)
- Handle configuration file creation and error scenarios
- Automatically save configuration after updates and load on initialization
2025-02-16 14:17:27 +08:00
5f67325055 refactor(cache): Improve cache expiration using LastAccess timestamp
- Update cache expiration check to use LastAccess instead of CreatedAt
- Reset expiration time on each cache item access
- Enhance cache management with more accurate access tracking
2025-02-16 14:12:29 +08:00
a4c4688412 feat(cache): Add dynamic cache configuration management
- Implement GetConfig and UpdateConfig methods in CacheManager
- Add cache configuration endpoints in CacheAdminHandler
- Create frontend UI for dynamically updating cache settings
- Support configurable max age, cleanup interval, and cache size
- Add input validation for cache configuration updates
2025-02-16 13:57:12 +08:00
d00ab0a6e1 feat(metrics): Improve latency tracking and error visualization
- Add atomic operations to track minimum and maximum request latency
- Update GetStats method to handle uninitialized latency values
- Modify dashboard error chart with improved color scheme and legend
- Adjust chart margins and axis width for better readability
2025-02-15 18:24:55 +08:00
35ea14a91f feat(cache): Add Content-Encoding support in cache management
- Update CacheItem struct to include ContentEncoding field
- Modify Put and Commit methods to store Content-Encoding header
- Enhance cache retrieval to set Content-Encoding header for cached responses
- Implement Content-Encoding preservation across proxy and mirror handlers
2025-02-15 18:16:04 +08:00
1c44fe1bf4 feat(metrics): Add status code tracking and improve path metrics handling
- Implement status code statistics tracking in Collector
- Update PathMetrics type to use pointer-based access
- Enhance atomic operations for request and error count tracking
- Modify type assertions to use pointer-based type conversion
2025-02-15 18:08:49 +08:00
2267a27b37 feat(cache): Implement streaming cache with TeeReader for efficient response handling
- Replace full response body reading with streaming cache mechanism
- Add CreateTemp and Commit methods to CacheManager for incremental caching
- Use io.TeeReader to simultaneously write response to client and cache file
- Remove buffer pool and full body reading in proxy and mirror handlers
- Improve memory efficiency and reduce latency for large responses
- Update error handling and logging for cache-related operations
2025-02-15 17:48:13 +08:00
ffc64bb73a feat(cache): Add fixed path cache support to admin dashboard and API
- Integrate fixed path cache into cache admin handler and API endpoints
- Update cache admin dashboard to display fixed path cache statistics
- Modify cache management functions to support fixed path cache operations
- Add new cache type to frontend cache management UI
2025-02-15 17:32:27 +08:00
9c3c48f4b6 feat(cache,middleware): Enhance caching mechanism for fixed path proxy
- Modify CacheKey to use a simplified string representation of Vary headers
- Update GenerateCacheKey to handle Vary headers more efficiently
- Implement caching in FixedPathProxyMiddleware with cache hit/miss tracking
- Improve response handling by reading entire response body before writing
- Add error handling for connection-related issues during response writing
2025-02-15 17:14:29 +08:00
88726d9d8f feat(cache): Add CacheKey methods for string representation, equality, and hashing
- Implement `String()` method to generate a unique string representation of CacheKey
- Add `Equal()` method to compare CacheKey instances
- Create `Hash()` method using FNV-64a hashing algorithm for efficient key comparison
2025-02-15 17:09:00 +08:00
c4cd99a827 feat(cache): Implement comprehensive caching system for proxy requests
- Add CacheManager to handle caching for proxy and mirror handlers
- Introduce cache-related API endpoints for stats, enabling, and clearing
- Modify proxy and mirror handlers to support caching GET requests
- Remove rate limiting and simplify request handling
- Update go.mod dependencies and remove unused imports
- Add cache hit/miss headers to responses
- Enhance metrics collection for cached requests
2025-02-15 17:00:16 +08:00
3e5950e3f6 feat(metrics,web): Enhance dashboard with advanced metrics visualization
- Integrate Recharts library for interactive data visualization
- Add detailed latency distribution charts and error type analysis
- Implement bandwidth and performance metrics graphs
- Update metrics collection to support more granular statistical tracking
- Modify frontend API routes to remove /admin prefix
- Improve metrics display with responsive and informative charts
2025-02-15 16:23:20 +08:00
eabb1f1f9a refactor(models,web): Update JSON serialization and formatting utilities
- Modify RequestLog struct to use PascalCase JSON tags
- Enhance formatBytes function to handle undefined or NaN inputs
- Update formatDate to return full datetime and handle empty inputs
- Add null/NaN checks to formatLatency for more robust display
2025-02-15 12:01:28 +08:00
f758db3531 refactor(metrics): Simplify metrics collection and improve performance
- Restructure Collector to use more efficient atomic operations
- Remove complex caching and monitoring dependencies
- Simplify path and status code tracking with sync.Map
- Optimize request logging with a dedicated request queue
- Remove unnecessary utility functions and pools
- Streamline stats generation and reduce complexity
2025-02-15 11:51:01 +08:00
33d6a51416 refactor(web): Migrate to modern web frontend and simplify admin routes
- Remove legacy static files, templates, and JavaScript
- Update main.go to serve SPA-style web application
- Modify admin route handling to support client-side routing
- Simplify configuration and metrics API endpoints
- Remove server-side template rendering in favor of static file serving
- Update Dockerfile and GitHub Actions to build web frontend
2025-02-15 11:44:09 +08:00
0446eb1c53 feat(proxy): Optimize HTTP transport and timeout configurations
- Increase connection pool and idle connection limits
- Extend timeout durations for more robust network handling
- Configure HTTP/2 transport with enhanced performance settings
- Add HTTP/2-specific optimizations and security constraints
2025-02-15 08:59:20 +08:00
6c7bc2bfb8 refactor(proxy): Improve error handling and response writing in proxy handler
- Modify error response writing to use explicit WriteHeader and Write methods
- Remove redundant WriteHeader call in ServeHTTP method
- Add WriteHeader before writing response for both small and large responses
- Enhance code readability and error handling consistency
2025-02-15 08:34:14 +08:00
e89ef02205 特性(代理):通过端口和身份验证更新来增强服务器配置和安全性。
- 更新 docker-compose.yml 文件,使用端口 3336
- 修改 Dockerfile 以暴露端口 3336
- 重构 main.go 以支持新的路由和管理端点
- 在 auth.go 中实现健壮的身份验证中间件
- 通过加强错误检查来改进指标处理。
- 添加用于安全类型转换的实用函数
- 引入请求ID生成功能,以便更好地进行追踪。
2025-02-15 08:07:28 +08:00