210 Commits

Author SHA1 Message Date
e89ef02205 特性(代理):通过端口和身份验证更新来增强服务器配置和安全性。
- 更新 docker-compose.yml 文件,使用端口 3336
- 修改 Dockerfile 以暴露端口 3336
- 重构 main.go 以支持新的路由和管理端点
- 在 auth.go 中实现健壮的身份验证中间件
- 通过加强错误检查来改进指标处理。
- 添加用于安全类型转换的实用函数
- 引入请求ID生成功能,以便更好地进行追踪。
2025-02-15 08:07:28 +08:00
wood chen
03ffec4760
Update readme.md 2025-02-15 02:00:49 +08:00
f76649d0e7 refactor(proxy): streamline target URL selection logic by removing deprecated path handling 2025-01-12 18:24:19 +08:00
8f27b8b70f Merge branch 'main' of https://github.com/woodchen-ink/proxy-go 2025-01-12 18:14:29 +08:00
f8a5999d36 fix(utils): update default size threshold and enhance logging for extension mapping 2025-01-12 18:14:27 +08:00
wood chen
49042362ed
Merge pull request #2 from woodchen-ink/dependabot/go_modules/golang.org/x/time-0.9.0
chore(deps): bump golang.org/x/time from 0.8.0 to 0.9.0
2025-01-12 01:54:55 +08:00
dependabot[bot]
d331ad036b
chore(deps): bump golang.org/x/time from 0.8.0 to 0.9.0
Bumps [golang.org/x/time](https://github.com/golang/time) from 0.8.0 to 0.9.0.
- [Commits](https://github.com/golang/time/compare/v0.8.0...v0.9.0)

---
updated-dependencies:
- dependency-name: golang.org/x/time
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-06 12:33:06 +00:00
wood chen
179898d01c
Update readme.md 2025-01-04 19:29:50 +08:00
wood chen
59af7fe312
Update readme.md 2025-01-01 02:56:38 +08:00
wood chen
8b99907dba
Update readme.md 2024-12-31 15:34:35 +08:00
wood chen
5c4701b99b
Update readme.md 2024-12-31 12:11:09 +08:00
9aedaf75c5 refactor(metrics): simplify auto-refresh logic in metrics template 2024-12-05 11:27:47 +08:00
ea4e7cc70b 状态码统计布局问题 2024-12-05 11:21:30 +08:00
1f2f78dc64 refactor(metrics): remove historical data handling and streamline collector logic
- Eliminated the historical data storage and related functions from the metrics collector to simplify the codebase.
- Removed the historical data display section from the metrics template, enhancing clarity and focus on current metrics.
- Updated the CheckDataConsistency method to implement a simpler validation check for total errors against total requests.

These changes improve the maintainability of the metrics system by removing outdated features and ensuring a more straightforward data validation process.
2024-12-05 11:16:58 +08:00
1440eec7ed refactor(metrics): remove deprecated metrics history endpoint and clean up related code
- Removed the MetricsHistoryHandler and associated historical data export functionality to streamline the metrics handling process.
- Updated the metrics template to improve label translations and ensure default values are used for optional data fields.
- Enhanced the JavaScript code for metrics display by adding checks for undefined data arrays, improving robustness.
- Cleaned up unused variables and functions to maintain code clarity and reduce complexity.

These changes simplify the metrics system by eliminating outdated features and improving the overall reliability of data presentation.
2024-12-05 11:09:44 +08:00
b82096227c feat(metrics): improve metrics handling with safe type conversions and default values
- Introduced safe type conversion functions to handle nil values gracefully, ensuring metrics integrity.
- Updated the MetricsHandler to return default values for metrics when stats retrieval fails, enhancing reliability.
- Streamlined the metrics initialization process by ensuring all necessary fields are populated, even in error scenarios.
- Improved memory usage reporting and response time metrics for better performance insights.

These changes enhance the robustness of the metrics system, ensuring accurate data handling and improved monitoring capabilities.
2024-12-05 10:59:55 +08:00
058244cc70 feat(metrics): enhance configuration and performance monitoring
- Added new performance monitoring settings in the configuration, including maximum requests per minute and data transfer limits.
- Introduced validation parameters for metrics, ensuring data integrity and consistency checks during collection.
- Refactored the metrics collector to streamline initialization and improve error handling.
- Removed deprecated database-related code and optimized metrics saving processes.
- Enhanced historical data management with regular clean-up routines to maintain performance.

These changes improve the configurability and reliability of the metrics system, ensuring accurate data handling and enhanced monitoring capabilities.
2024-12-05 10:56:27 +08:00
f360e13ca3 feat(metrics): optimize stats collection and enhance error handling
- Refactored the GetStats method to improve memory management by utilizing an object pool for stats initialization.
- Enhanced error rate calculation and added average response time metrics for better performance insights.
- Streamlined path and referer statistics collection, ensuring only relevant data is processed and displayed.
- Improved sorting and selection logic for top paths and referers, enhancing the clarity of metrics reporting.
- Updated comments for better code readability and understanding of the metrics collection process.

These changes enhance the efficiency and accuracy of the metrics collector, providing more reliable performance data and insights.
2024-12-05 10:37:47 +08:00
14843301f7 feat(metrics): enhance initialization process in metrics collector
- Improved the initialization sequence by clearly defining steps for cache, monitoring, and object pool setup.
- Enabled Feishu webhook alerts for real-time notifications based on configuration.
- Ensured last save time is set during initialization to maintain accurate data persistence.
- Streamlined historical data loading process to enhance metrics accuracy.

These changes improve the organization and functionality of the metrics collector, ensuring better performance and alerting capabilities.
2024-12-05 10:33:55 +08:00
c71da4c1fe feat(metrics): initialize cache and object pool in metrics collector
- Added cache initialization to enhance performance and data retrieval efficiency.
- Introduced an object pool for managing statistics, optimizing memory usage during metrics processing.
- Improved code organization by clarifying initialization steps for cache and monitoring components.

These changes enhance the metrics collector's efficiency and resource management, ensuring better performance in data handling.
2024-12-05 10:30:10 +08:00
ef3bc0c5a6 feat(metrics): enhance metrics initialization and consistency checks
- Added initialization of last save time during collector setup to ensure timely data persistence.
- Implemented immediate saving of metrics after loading historical data to maintain accurate statistics.
- Improved error handling in SaveMetrics by validating input types before updating persistent stats.
- Modified CheckDataConsistency logic to allow for a tolerance of 5% in total request comparisons, enhancing reliability in metrics validation.

These changes improve the accuracy and reliability of the metrics collection process, ensuring better monitoring and data integrity.
2024-12-05 10:26:09 +08:00
1c22e4c020 栈溢出 2024-12-05 10:21:50 +08:00
e275326d91 feat(metrics): enhance configuration and metrics validation
- Added new configuration structures for loading, saving, and validation settings in MetricsConfig.
- Introduced constants for load retry counts, intervals, and validation parameters to improve configurability.
- Enhanced metrics collector with data validation and consistency checks during metrics loading.
- Implemented backup and restore functionality for metrics data, ensuring data integrity and recoverability.
- Improved logging for metrics operations, providing better insights into the metrics collection process.

These changes enhance the flexibility and reliability of the metrics system, ensuring accurate data handling and improved monitoring capabilities.
2024-12-05 10:15:20 +08:00
8c266a1ec2 feat(metrics): enhance metrics collection and monitoring capabilities
- Added new performance monitoring thresholds for maximum requests and data transfer rates.
- Introduced dynamic save interval adjustments based on data change rates to optimize database writes.
- Implemented a retry mechanism for loading recent statistics, improving reliability in data retrieval.
- Consolidated metrics saving into a single method, SaveAllMetrics, to streamline database transactions and improve performance.
- Enhanced error handling and logging throughout the metrics collection process for better monitoring.

These changes improve the efficiency and reliability of the metrics system, ensuring more accurate and timely data collection.
2024-12-05 09:51:43 +08:00
ad4211fd6f refactor(metrics): streamline recent stats loading and remove deprecated function
- Replaced the deprecated loadRecentStatusStats function with a new LoadRecentStats method in the MetricsDB, consolidating recent statistics loading for status codes, paths, and referers.
- Improved error handling and logging for loading recent stats, enhancing monitoring capabilities.
- This refactor simplifies the codebase and improves the efficiency of metrics collection, ensuring more accurate and timely data retrieval.
2024-12-05 09:35:11 +08:00
79abb4089f 历史数据问题 2024-12-05 09:29:55 +08:00
8df86387ac refactor(metrics): enhance dashboard styles and optimize SQL queries
- Updated CSS styles for the metrics dashboard, improving layout with flex properties and enhanced item presentation.
- Modified the status code display to use a more organized structure, allowing for better alignment and spacing.
- Changed the data type for avgLatency in SaveMetrics to int64 for consistency.
- Implemented a context with timeout for database queries in GetRecentMetrics, improving performance and reliability.
- Optimized SQL queries to limit result sets and enhance data retrieval efficiency.

These changes improve the user experience and data presentation in the metrics dashboard, providing clearer insights into performance metrics.
2024-12-05 09:22:33 +08:00
7cca4bab95 fix css bug 2024-12-05 08:58:42 +08:00
1140062afb 修改metrics状态码样式 2024-12-05 08:52:25 +08:00
d69d34bb5d fix(metrics): update metrics dashboard styles and improve status code display 2024-12-05 08:48:00 +08:00
3270bb5f36 fix(metrics): update metrics dashboard styles and optimize SQL queries
- Changed text color in the metrics dashboard from white to black for better visibility.
- Modified the layout of status codes to display in a row with improved alignment and spacing.
- Enhanced CSS styles for the metrics dashboard, including adjustments to flex properties and background settings.
- Updated SQL query in GetRecentMetrics to sort status codes, ensuring a more organized display of metrics.

These changes improve the user experience and data presentation in the metrics dashboard, providing clearer insights into performance metrics.
2024-12-05 08:37:51 +08:00
ba691431f4 状态码统计数组越界 2024-12-05 08:27:19 +08:00
864ebcc610 test 2024-12-05 08:23:38 +08:00
97a195c9dd feat(metrics): add recent status stats loading and optimize database transaction settings
- Implemented a new function to load recent status statistics from the database, enhancing the collector's ability to track real-time metrics.
- Added error logging for failed status stats loading to improve monitoring and debugging capabilities.
- Moved database transaction optimization settings outside of the transaction scope in SaveMetrics, improving performance during metric saving operations.
- Updated SQL queries in GetRecentMetrics to streamline time filtering logic, ensuring accurate retrieval of recent metrics.

These changes enhance the metrics collection process and improve the overall performance and reliability of the metrics dashboard.
2024-12-05 08:15:18 +08:00
96a792abf2 fix(metrics): update metrics dashboard styles and SQL query
- Enhanced CSS styles for the metrics dashboard, improving layout and visual presentation with new flex properties and background adjustments.
- Modified the SQL query in GetRecentMetrics to include an additional interval parameter, ensuring more accurate data retrieval for recent metrics.
- These changes improve the user experience and data accuracy in the metrics dashboard, providing a more robust framework for performance monitoring.
2024-12-05 08:03:03 +08:00
e286fa9eaf feat(metrics): enhance metrics retention and improve data handling
- Introduced new constants for data retention periods, specifying retention for metrics, status codes, paths, and referers to improve data management.
- Updated the MetricsHistoryHandler to accept floating-point hours for more precise time queries, enhancing the flexibility of historical data retrieval.
- Enhanced the metrics dashboard layout with additional CSS styles for better visual presentation and user experience.
- Improved error handling in the response writing process to ensure robust logging of connection issues.
- Implemented a new function to check for connection closure errors, improving the reliability of the proxy handler.

These changes significantly enhance the metrics collection, retention, and user interface, providing a more robust framework for performance monitoring and data analysis.
2024-12-05 07:57:02 +08:00
26c945a3f9 feat(metrics): enhance metrics dashboard and data handling
- Improved the metrics dashboard layout with new styles for better visual presentation, including enhanced chart and control elements.
- Added functionality for auto-refreshing metrics and exporting data to CSV, improving user interaction and data accessibility.
- Implemented persistent statistics tracking in the collector, allowing for historical data retrieval and better performance monitoring.
- Enhanced database operations with optimizations for saving metrics and cleaning up old data, ensuring efficient data management.
- Introduced performance metrics tracking, providing insights into average response times and throughput.

These changes significantly enhance the usability and functionality of the metrics dashboard, providing a more robust framework for performance monitoring and data analysis.
2024-12-05 07:08:08 +08:00
2d658c35e6 fix(metrics): refine SQL query for recent metrics retrieval
- Updated the SQL query in GetRecentMetrics to adjust the time filtering logic, ensuring that only metrics within the specified hours are retrieved.
- This change enhances the accuracy of the metrics data by correctly bounding the time range, improving the reliability of performance monitoring.
2024-12-05 06:51:16 +08:00
c416c76790 feat(metrics): implement full metrics saving and enhance database schema
- Added functionality to save full metrics periodically and on application shutdown, improving data persistence.
- Introduced new database tables for performance metrics, status code history, popular paths, and referer history, enhancing data tracking capabilities.
- Updated the GetRecentMetrics function to utilize window functions for more accurate metrics retrieval and ensure non-negative values.
- Improved data handling by ensuring empty records are returned instead of null when no metrics are available.

These changes significantly enhance the metrics collection and storage process, providing a more robust framework for performance monitoring.
2024-12-05 06:47:39 +08:00
c35d95f2cc fix(metrics): enhance metrics dashboard layout and optimize database queries
- Increased the bottom margin of charts in the metrics dashboard for improved visual spacing.
- Added titles to the charts for better context and understanding of displayed data.
- Introduced composite indexes in the database to optimize aggregation queries and improve performance.
- Modified the SQL query in GetRecentMetrics to calculate incremental changes in metrics, enhancing data accuracy and usability.

These changes improve the user experience by providing clearer visualizations and more efficient data retrieval in the metrics dashboard.
2024-12-05 01:46:25 +08:00
68a0ea234b fix(metrics): refine chart handling and data validation in metrics dashboard
- Updated chart management logic to ensure proper destruction of existing charts before creating new ones, preventing memory leaks.
- Enhanced data validation by adding a check for the data format returned from the API, ensuring it is an array before processing.
- Consolidated chart options into a common configuration for improved consistency across different charts.
- Improved the updateChart function to handle canvas element existence checks and streamline chart creation.

These changes enhance the performance and reliability of the metrics dashboard, providing clearer visualizations and better data handling.
2024-12-05 01:28:17 +08:00
b5a3cfeee4 fix(metrics): improve chart management in metrics dashboard
- Added logic to destroy existing charts before creating new ones, preventing memory leaks and ensuring proper chart updates.
- Updated the currentCharts object to maintain references to the newly created charts, enhancing the management of chart instances.
- These changes improve the performance and reliability of the metrics dashboard by ensuring that charts are correctly handled during updates.
2024-12-05 01:22:58 +08:00
660e60576d fix(metrics): enhance metrics chart rendering and data handling
- Updated the metrics chart rendering logic to reverse the data order for a more intuitive time progression from left to right.
- Introduced chart options to ensure the x-axis is not reversed, improving the clarity of time-based data visualization.
- Modified the updateChart function to accept additional options, allowing for more flexible chart configurations.
- Added a safeguard in GetRecentMetrics to return a default empty record instead of null when no metrics are available, enhancing data reliability.

These changes improve the user experience by providing clearer visualizations and ensuring consistent data handling in the metrics dashboard.
2024-12-05 01:13:11 +08:00
8858c41419 Merge branch 'main' of https://github.com/woodchen-ink/proxy-go 2024-12-05 01:06:57 +08:00
59358cbe8a fix(metrics): update SQL query to use localtime for accurate metrics retrieval
- Modified the SQL query in GetRecentMetrics to utilize the 'localtime' modifier for timestamp handling, ensuring that metrics are retrieved based on the local time zone.
- This change enhances the accuracy of the metrics data by aligning the time calculations with local time, improving the reliability of performance monitoring.
2024-12-05 01:06:55 +08:00
wood chen
12b85b24e7
Merge pull request #1 from woodchen-ink/dependabot/go_modules/modernc.org/sqlite-1.34.2
chore(deps): bump modernc.org/sqlite from 1.28.0 to 1.34.2
2024-12-04 12:10:49 +08:00
60b115438a fix(metrics): update AvgLatency type and improve SQL query for metrics retrieval
- Changed AvgLatency field type from int64 to float64 in HistoricalMetrics for better precision in latency measurements.
- Updated SQL query in GetRecentMetrics to ensure proper averaging of AvgLatency by casting to float, enhancing accuracy in metrics reporting.
- These changes improve the reliability of metrics data and ensure more accurate performance monitoring.
2024-12-04 11:57:08 +08:00
dependabot[bot]
adfacfdeeb
chore(deps): bump modernc.org/sqlite from 1.28.0 to 1.34.2
Bumps [modernc.org/sqlite](https://gitlab.com/cznic/sqlite) from 1.28.0 to 1.34.2.
- [Commits](https://gitlab.com/cznic/sqlite/compare/v1.28.0...v1.34.2)

---
updated-dependencies:
- dependency-name: modernc.org/sqlite
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-03 12:35:22 +00:00
a009dd04a8 refactor(metrics): remove historical data section from metrics dashboard template
- Eliminated the historical data section from the metrics dashboard, including time range buttons and associated chart containers.
- Streamlined the metrics template for improved clarity and focus on current metrics display.
- This change enhances the user experience by simplifying the dashboard layout.
2024-12-03 18:27:04 +08:00
837820639f feat(metrics): implement database initialization and cleanup for metrics tracking
- Added initTables function to create necessary tables for metrics history, status statistics, and path statistics in the database.
- Implemented indexing on timestamp columns to enhance query performance.
- Introduced a cleanupRoutine function to periodically delete old metrics data based on retention policies, improving database management.
- Integrated logging for cleanup operations to monitor success and errors during the cleanup process.
2024-12-03 18:25:23 +08:00