Commit Graph

29 Commits

Author SHA1 Message Date
Gouryella
89f67ab145 feat(client): Add bandwidth limit function support
- Implement client bandwidth limitation parameter --bandwidth, supporting 1M, 1MB, 1G and other formats
- Added parseBandwidth function to parse bandwidth values and verify them
- Added bandwidth limit option in HTTP, HTTPS, TCP commands
- Pass bandwidth configuration to the server through protocol
- Add relevant test cases to verify the bandwidth analysis function

feat(server): implements server-side bandwidth limitation function

- Add bandwidth limitation logic in connection processing, using token bucket algorithm
- Implement an effective rate limiting strategy that minimizes the bandwidth of the client and server
- Added QoS limiter and restricted connection wrapper
- Integrated bandwidth throttling in HTTP and WebSocket proxies
- Added global bandwidth limit and burst multiplier settings in server configuration

docs: Updated documentation to describe bandwidth limiting functionality

- Add 2025-02-14 version update instructions in README and README_CN
- Add bandwidth limit function description and usage examples
- Provide client and server configuration examples and parameter descriptions
2026-02-15 02:39:50 +08:00
zhiqing
307cf8e6cc feat: Add Bearer Token authentication support and optimize code structure
- Add Bearer Token authentication, supporting tunnel access control via the --auth-bearer parameter
- Refactor large modules into smaller, more focused components to improve code maintainability
- Update dependency versions, including golang.org/x/crypto, golang.org/x/net, etc.
- Add SilenceUsage and SilenceErrors configuration for all CLI commands
- Modify connector configuration structure to support the new authentication method
- Update recent change log in README with new feature descriptions

BREAKING CHANGE: Authentication via Bearer Token is now supported, requiring the new --auth-bearer parameter
2026-01-29 14:40:53 +08:00
Gouryella
10aa65065a feat(proxy): Support independent configuration for service domain and tunnel domain
- Add serverDomain and tunnelDomain fields to the Handler struct to distinguish between service domain and tunnel domain
- Modify the NewHandler function signature to support passing two separate domain parameters
- Update the extractSubdomain method to return a subdomain result type with three states: home, found, notFound
- Add serveTunnelNotFound method to handle tunnel not found cases, returning a 404 page
- Add favicon support to display an icon on the page
- Adjust routing logic to display a dedicated 404 page when accessing a tunnel domain but the corresponding tunnel is not found
2026-01-16 17:18:43 +08:00
Gouryella
5459d952be feat(server): Optimize configuration priority processing logic 2026-01-15 17:32:08 +08:00
Gouryella
6139a9c0ed feat: add transport protocol option supporting TCP and WebSocket connections
Added --transport parameter to allow users to select transport protocol type:
- auto: automatically choose based on server address (default)
- tcp: direct TLS 1.3 connection
- wss: WebSocket over TLS (CDN-friendly)

Also updated client connector to support WebSocket transport, and added server-side discovery endpoint to query supported transport protocols.
2026-01-14 12:49:08 +08:00
Gouryella
029044a9ba feat(proxy): Implement HTML escaping in login pages to prevent XSS attacks 2026-01-13 11:03:20 +08:00
Gouryella
f75bd9f0d2 feat(cli): add proxy authentication support
Add the --auth parameter to enable proxy authentication for HTTP and HTTPS tunnels, supporting password verification and session management.

- Add --auth flag in CLI to set proxy authentication password
- Implement server-side authentication handling and login page
- Support Cookie-based session management and validation
- Add protocol message definitions related to authentication
2026-01-13 10:41:12 +08:00
Gouryella
d7b92a8b95 feat(server): Add server configuration validation and optimize connection handling
- Add Validate method to ServerConfig to validate port ranges, domain format, TCP port ranges, and other configuration items
- Add configuration validation logic in server.go to ensure valid configuration before server startup
- Improve channel naming in TCP connections for better code readability
- Enhance data copying mechanism with context cancellation support to avoid resource leaks
- Add private network definitions for secure validation of trusted proxy headers

fix(proxy): Strengthen client IP extraction security and fix error handling

- Trust X-Forwarded-For and X-Real-IP headers only when requests originate from private/loopback networks
- Define RFC 1918 and other private network ranges for proxy header validation
- Add JSON serialization error handling in TCP connections to prevent data loss
- Fix context handling logic in pipe callbacks
- Optimize error handling mechanism for data connection responses

refactor(config): Improve client configuration validation and error handling

- Add Validate method to ClientConfig to verify server address format and port validity
- Change configuration validation from simple checks to full validation function calls
- Provide more detailed error messages to help users correctly configure server address formats
2026-01-12 10:55:27 +08:00
Gouryella
85a0f44e44 feat: Add IP access control functionality
- Implement IP whitelist/blacklist access control mechanism
- Add --allow-ip and --deny-ip command-line arguments to configure IP access rules
- Support CIDR format for IP range configuration
- Enable IP access control in HTTP, HTTPS, and TCP tunnels
- Add IP access check logic to server-side proxy handling
- Update documentation to explain how to use IP access control
2026-01-11 14:22:41 +08:00
Gouryella
d03874b3d3 feat: Added Prometheus metrics support and optimized the homepage interface.
Added the prometheus/client_golang dependency to support metrics collection, and refactored the proxy processor's homepage.
It uses modern CSS styles and responsive design, and adds code copy functionality.
BREAKING CHANGE: Removed session selection-related methods and the large buffer feature of the buffer pool in TCP connection groups.
2026-01-05 11:56:18 +08:00
Gouryella
11ca454659 feat(server): Adds server configuration management commands and metric monitoring functionality.
- Add a new `server config` command to display server configuration.
- Supports displaying the full token via the --full flag.
- Add the metrics-token configuration option for monitoring access control.
- Integrate Prometheus metrics monitoring system
- Add the /metrics endpoint to provide monitoring data in Prometheus format.
- Add detailed metric collection for tunnels, connections, traffic, etc.
- Add a link to the metrics endpoint on the homepage
refactor: Refactor the token display logic to support full display options.
- Refactor the token mask logic in the configuration display
- Supports controlling the token display method via the configFull flag.
build: Update dependency versions
- Updated github.com/spf13/cobra from v1.10.1 to v1.10.2
- Updated golang.org/x/crypto from v0.45.0 to v0.46.0
- Updated golang.org/x/net from v0.47.0 to v0.48.0
- Update golang.org/x/sys from v0.38.0 to v0.39.0
- Added several new indirect dependency packages, including Prometheus-related components.
- Update the versions of several existing dependency packages.
2026-01-03 16:50:28 +08:00
Gouryella
88e4525bf6 perf(core): Optimizes performance configuration and resource management
- Removed the manual performance optimization configuration in main.go and replaced it with a new tuning module.
- Add patterned GC tuning in server.go and tunnel_runner.go
- Updated yamux configuration to a unified optimized configuration to improve throughput.
- Implement connection pool preheating function to eliminate cold start delay.
- Optimize session selection using a min-heap, reducing the time complexity from O(n) to O(log n).
- Add a bufio.Reader pool and a buffer pool to reduce memory allocation.
- Implement a fragmented lock manager to improve performance under high concurrency.
- Adjust heartbeat and timeout configurations to suit high-throughput scenarios
BREAKING CHANGE: Manual GC tuning configuration has been removed; automatic tuning mode is now used.
2025-12-23 11:16:12 +08:00
Gouryella
0cff316334 feat(client): Optimized connection pool scaling logic and enhanced session statistics functionality.
- Reduce inspection intervals and cooling times to improve response speed
- Added burst load handling mechanism to support batch expansion.
- Introduced the GetSessionStats method to retrieve detailed statistics for each session.
- Create data sessions concurrently to accelerate scaling.
- Added a ping loop keep-alive mechanism for each session.
feat(server): Enhance tunnel management and security restrictions
- Implement IP-based tunnel number and registration frequency limits
- Add a rate limiter to prevent malicious registration behavior.
- Improved shutdown process to ensure proper exit of cleanup coroutines.
- Introduce atomic operations to tunnel connections to improve concurrency performance
- Track client IP addresses for access control
perf(server): Improves HTTP request processing performance and resource reuse.
- Use sync.Pool to reuse bufio.Writer to reduce GC pressure.
- Enable TCP_NODELAY to improve response speed
- Adjust HTTP server timeout configuration to balance performance and security
refactor(proxy): Optimizes the stream open timeout control logic
- Use context to control timeouts and avoid goroutine leaks.
- Ensure that established connections are properly closed upon timeout.
docs(test): Upgrade one-click test scripts to Go test service
- Replace Python's built-in server with a high-performance Go implementation
- Update dependency checks: Use Go instead of Python 3
- Enhanced startup log output for easier debugging
chore(shared): Enhances the security and consistency of the ID generator.
- Remove the timestamp fallback scheme and uniformly adopt crypto/rand.
- Added TryGenerateID to provide a non-panic error handling method.
- Define the maximum frame size explicitly and add comments to explain it.
style(frame): Reduce memory allocation and optimize read performance
- Use an array on the stack instead of heap allocation to read the frame header.
- Reduced maximum frame size from 10MB to 1MB to decrease DoS risk.
2025-12-22 16:08:24 +08:00
Gouryella
bad099d0f3 fix(tcp): Fixed a connection reading issue during WebSocket upgrade processing.
When processing HTTP streams, support for buffered readers has been added for WebSocket upgrade requests.
This ensures that data not fully read before connection switching is not lost. The forwarding logic for the Host header has also been optimized.
Add the X-Forwarded-Host header to preserve the original host information.
2025-12-19 17:48:15 +08:00
Gouryella
e5aaf150e3 feat(proxy): Removes support for the HTTP CONNECT method.
In the ServeHTTP processing logic, CONNECT requests are no longer processed, and a 405 status code is returned when such a request is received.
The method was flagged as not allowed. The original handleConnect implementation code was also removed.
2025-12-19 10:26:38 +08:00
Gouryella
1c733de303 feat(server): Supports HTTP CONNECT proxy and connection pooling.
- Added handling for the HTTP CONNECT method, supporting HTTPS tunneling proxies.
- Introducing connQueueListener to hand over HTTP connections to standard http.Server handling.
- Optimized Connection struct fields and lifecycle management logic
- Remove redundant comments and streamline some response writing logic
- Upgrade the golang.org/x/net dependency version to support new features.
- Enhanced HTTP request parsing stability and improved error logging methods.
- Adjusted the TCP listener startup process to integrate HTTP/2 configuration support.
- Improve the connection closing mechanism to avoid resource leakage issues.
2025-12-16 02:24:20 +08:00
Gouryella
0c19c3300c feat(tunnel): switch to yamux stream proxying and connection pooling
- Introduce pooled tunnel sessions (TunnelID/DataConnect) on client/server
- Proxy HTTP/HTTPS via raw HTTP over yamux streams; pipe TCP streams directly
- Move UI/stats into internal/shared; refactor CLI tunnel helpers; drop msgpack/hpack legacy
2025-12-13 18:03:44 +08:00
Gouryella
8e6f9c553a feat(proxy): Optimizes homepage response processing
Convert the HTML content into byte slices and set the Content-Length header.
To improve response performance and accuracy.
2025-12-10 15:26:24 +08:00
Gouryella
d21bb4897f feat(cli): Supports stopping HTTPS tunnels and optimizes configuration display logic.
- Added support for HTTPS tunnel types to the `drip stop` command and updated the example documentation.
- Optimized token display logic to adapt to token formats of different lengths.
- Adjust the alignment of FrameHandler buffer read/write and timeout configuration formats.
- Move the error handling logic location to ensure data read integrity.
- Introducing context to control request lifecycle and supporting cancel transfer in proxy handlers
- The hop-by-hop header judgment format in the unified response header filtering rules
- Add a context-aware streaming request cancellation mechanism and extend the channel cleanup timeout.
- Add a context control field to the TCP connection structure to support connection lifecycle management.
- Format the httpResponseWriter field comments
2025-12-08 16:57:10 +08:00
Gouryella
3bc7978999 fix(proxy): Improves response handling for health check and statistics interfaces.
Replace json.NewEncoder.Encode with json.Marshal and w.Write.
Add a Content-Length header to ensure the integrity and correctness of the response data.
At the same time, error handling is enhanced to avoid potential coding failures.
2025-12-08 15:51:02 +08:00
Gouryella
aa5b0bfde3 feat(proxy): Adjusts the processing logic of the health check and statistics interfaces. 2025-12-08 15:22:25 +08:00
Gouryella
1a5ffce15c refactor(buffer): Optimizes TCP and HTTP streaming request processing using a buffer pool.
Replaces the fixed-size buffers in `FrameHandler` and `Handler` with dynamic buffers obtained from the buffer pool,

to reduce memory allocation and improve performance. Also updates the logo path in the README to match the new resource directory structure.
2025-12-08 12:53:56 +08:00
Gouryella
7283180e6a perf(client): Optimize client performance and introduce a data frame processing worker pool
- Add runtime performance optimization configurations to main.go, including setting GOMAXPROCS, adjusting GC frequency, and memory limits.

- Implement a worker pool-based data frame processing mechanism in connector.go to improve processing capabilities under high concurrency.

- Adjust frame writer configuration to improve batch write efficiency and enable adaptive refresh strategy.

- Add callback handling support for write errors to enhance connection stability.

refactor(server): Introduce an adaptive buffer pool to optimize memory usage

- Add adaptive_buffer_pool.go to implement large and small buffer reuse, reducing memory allocation overhead.

- Apply buffer pool management for large/medium temporary buffers in proxy handlers and TCP connections.

- Change the HTTP response writer to a cached bufio.Writer to improve I/O performance.

- Optimize HTTP request reading logic and response sending process.

build(docker): Update mount paths and remove unused named volumes

- Modify the data directory mount method in docker-compose.release.yml. ./data:/app/data

- Remove the unnecessary drip-data named volume definition

test(script): Add performance testing and profiling scripts

- Add profile-test.sh script for automating stress testing and performance data collection

- Supports collecting pprof data such as CPU, stack traces, and coroutines and generating analysis reports
2025-12-08 12:24:42 +08:00
Gouryella
bbef7efb5e feat(client): Implements a response cancellation mechanism to improve resource management
Added support for HTTP response context cancellation, including logic for registering, triggering, and cleaning up cancellation functions.

Introduced a responseCancels mapping and corresponding synchronization lock in FrameHandler to track and control the request lifecycle.

When the data frame type is closed, actively called cancelResponse to release related resources.

Simultaneously, during the response body reading process, identified context cancellation or timeout errors and prematurely terminated the processing flow to avoid invalid operations.
2025-12-06 23:58:31 +08:00
Gouryella
aead68bb62 feat: Add HTTP streaming, compression support, and Docker deployment
enhancements

  - Add adaptive HTTP response handling with automatic streaming for large
  responses (>1MB)
  - Implement zero-copy streaming using buffer pools for better performance
  - Add compression module for reduced bandwidth usage
  - Add GitHub Container Registry workflow for automated Docker builds
  - Add production-optimized Dockerfile and docker-compose configuration
  - Simplify background mode with -d flag and improved daemon management
  - Update documentation with new command syntax and deployment guides
  - Clean up unused code and improve error handling
  - Fix lipgloss style usage (remove unnecessary .Copy() calls)
2025-12-05 22:09:07 +08:00
Gouryella
35e6c86e1f feat(client): Added the --short option to the version command to support plain text output.
Added the `--short` flag to the `version` command for printing version information without styles.

In this mode, only the version, Git commit hash, and build time in plain text format will be output, facilitating script parsing.

Optimized Windows process detection logic to improve runtime accuracy.

Removed redundant comments and simplified signal checking methods, making the code clearer and easier to maintain.

refactor(protocol): Replaced string matching of data frame types with enumeration types.

Unified the representation of data frame types in the protocol, using the `DataType` enumeration to improve performance and readability.

Introduced a pooled buffer mechanism to improve memory efficiency in high-load scenarios.

refactor(ui): Adjusted style definitions, removing hard-coded color values.

Removed fixed color settings from some lipgloss styles, providing flexibility for future theme customization.

``` docs(install): Improved the version extraction function in the installation script.

Added the `get_version_from_binary` function to enhance version identification capabilities, prioritizing plain mode output, ensuring accurate version number acquisition for the drip client or server across different terminal environments.

perf(tcp): Improved TCP processing performance and connection management capabilities.

Adjusted HTTP client transmission parameter configuration, increasing the maximum number of idle connections to accommodate higher concurrent requests.

Improved error handling logic, adding special checks for common cases such as closing network connections to avoid log pollution.

chore(writer): Expanded the FrameWriter queue length to improve batch write stability.

Increased the FrameWriter queue size from 1024 to 2048, and released pooled resources after flushing, better handling sudden traffic spikes and reducing memory usage fluctuations.
2025-12-03 18:11:37 +08:00
Gouryella
dd54e79ad7 perf (client): Refactored the command-line interface and enhanced user experience
- Optimized terminal output style and configuration management using libraries such as `lipgloss` and `go-json`

- Introduced the `ui` package to unify the display logic of colors, tables, and prompts

- Updated the README document structure and installation script links to improve readability and internationalization support

- Improved the interaction flow and log display effects of the daemon startup and attach commands

- Fixed some command parameter parsing issues, improving program robustness and user onboarding experience
2025-12-03 10:18:52 +08:00
Gouryella
e0e33c3323 feat(install-scripts): Updated installation scripts to fetch the latest version from GitHub and fixed download links.
Updated client and server installation scripts to automatically fetch the latest release via the GitHub API and corrected binary download addresses. Removed the old "latest" version logic to ensure explicit version tags are always used for downloads.

fix(readme): Fixed installation commands and license information in the README.

Corrected the installation script link pointing to an incorrect URL in the README to the correct path raw.githubusercontent.com, and updated the open-source license information used by the project from MIT to BSD 3-Clause.

ci(release): Added an automated GitHub Actions release workflow.

Added a new CI workflow configuration file to trigger the build process when a tag is pushed. This workflow compiles binaries for multiple platforms, generates checksums, and creates a GitHub Release with attachments. Supports different architectures including Linux, macOS, and Windows.
2025-12-02 16:40:53 +08:00
Gouryella
07eea862d5 feat(init): Initializes the project's basic structure and configuration files. 2025-12-02 16:12:18 +08:00