Commit Graph

67 Commits

Author SHA1 Message Date
yusing
d3a8b3c0e6 fix(agent/stream): improve error handling in UDP server connection
- Enhanced error handling in the UDP server to properly manage EOF and closed connection scenarios.
- Ensured that bytes read from the client are forwarded before handling errors.
- Added checks to avoid logging noise for expected shutdown conditions.
2026-01-07 23:42:21 +08:00
yusing
63f96b8d76 refactor(agent/stream): update header size calculation and field types
- Adjusted headerSize calculation to reflect the correct size based on field definitions.
- Changed HostLength and PortLength types from uint8 to byte.
- Updated PROTOCOL.md to reflect the new header size and structure.
2026-01-07 22:33:24 +08:00
yusing
5048326c20 fix(agent/stream): handle EOF error in UDP server connection
- Updated error handling in the UDP server to ignore io.EOF errors when reading from client connections.
- Added a check to return early if no bytes are read from the client connection.
- Ensured proper closure of tcpListener in the main.go file during cancellation.
2026-01-07 21:10:47 +08:00
yusing
d7361c6f52 refactor(agent/config): simplify stream server address handling
- Removed the streamServerAddr field from AgentConfig to streamline configuration.
- Updated StartWithCerts, NewTCPClient, and NewUDPClient methods to use Addr directly for establishing connections.
- Eliminated the getStreamServerAddr method as it is no longer needed.
2026-01-07 21:09:07 +08:00
yusing
c8f617108e refactor(agent/stream): rename payload.go to header.go and update protocol header format
- Rename payload.go to header.go for clarity
- Add HostLength and PortLength fields to avoid NUL-terminated string scanning
- Add padding bytes to make struct size match headerSize
- Remove unused StreamRequestPayload struct and WriteTo method
- Add runtime size validation in init()
- Update PROTOCOL.md documentation
2026-01-07 21:08:04 +08:00
yusing
039ae26696 chore(stream): remove unused StreamRequestPayload test 2026-01-07 21:05:52 +08:00
yusing
a605d56a4c feat(agent/stream): remove STREAM_PORT and use tcp multiplexing on the same port 2026-01-07 18:30:31 +08:00
yusing
682b4330fc feat(agent/stream): log UDP server errors 2026-01-07 14:34:14 +08:00
yusing
56f7841eda test(agent/stream): refactor server flow tests to use testify and real certificate generation
- Use agent.NewAgent() for properly configured certificates matching real usage
- Migrate to testify/require for assertions
- Add tests for UDP server rejecting clients with invalid certificates
- Use t.Context() for lifecycle management
2026-01-07 14:19:58 +08:00
yusing
2e2b7246d5 fix(agent): set ServerName in NewTCPClient and NewUDPClient; move CertDNSName to agent/pkg/common 2026-01-07 02:01:59 +08:00
yusing
68c15536bc fix(agent): add omitempty to stream_port in AgentInfo 2026-01-07 01:06:40 +08:00
yusing
fe619f1dd9 feat(agent): agent stream tunneling with TLS and dTLS (UDP); combined agent APIs
- Add `StreamPort` configuration to agent configuration and environment variables
- Implement TCP and UDP stream client support in agent package
- Update agent verification to test stream connectivity (TCP/UDP)
- Add `/info` endpoint to agent HTTP handler for version, name, runtime, and stream port
- Remove /version, /name, /runtime APIs, replaced by /info
- Update agent compose template to expose stream port for TCP and UDP
- Update agent creation API to optionally specify stream port (defaults to port + 1)
- Modify `StreamRoute` to pass agent configuration to stream implementations
- Update `TCPTCPStream` and `UDPUDPStream` to use agent stream tunneling when agent is configured
- Add support for both direct connections and agent-tunneled connections in stream routes

This enables agents to handle TCP and UDP route tunneling, expanding the proxy capabilities beyond HTTP-only connections.
2026-01-07 00:44:12 +08:00
yusing
fd74bfedf0 fix(agent): improve url handling to not break urls with encoded characters 2026-01-01 18:25:27 +08:00
yusing
f721395ff0 refactor(healthcheck): agent health check 2025-12-05 00:45:24 +08:00
yusing
3cbd70f73a fix(health_check): correct agent routes health check logic 2025-11-07 10:21:15 +08:00
yusing
6f75bb7593 refactor(api): replace apitypes module and fix swagger generation 2025-10-26 01:05:18 +08:00
yusing
9c3346dd9d fix(agent): correct usage of task in StartAgentServer and updated test expectations 2025-10-22 00:02:13 +08:00
yusing
5a91db8d10 perf: use fasthttp for health checks; upgrade go to 1.25.3 2025-10-17 22:50:13 +08:00
yusing
cc8858332d fix(agent): remove leftover pointer in tls.Config 2025-10-12 22:23:14 +08:00
yusing
c66de99fcb perf: further optimize http and body buffer handling 2025-10-12 20:57:51 +08:00
yusing
3aed41e078 refactor: move version.go to goutils 2025-10-09 01:14:43 +08:00
yusing
f411e17d80 feat(json): improve JSON performance with bytedance/sonic 2025-09-29 17:43:34 +08:00
yusing
024100aa8c fix(agent): failed to parse agent proxy config: unexpected end of JSON input 2025-09-28 20:30:02 +08:00
yusing
2a05c6a630 refactor: move websocket package and some http utils to seperate repo 2025-09-27 14:16:42 +08:00
yusing
6776f20332 refactor: move task, error and testing utils to separte repo; apply gofumpt 2025-09-27 13:41:50 +08:00
yusing
22bcf1201b refactor: move some io, http and string utils to separate repo 2025-09-27 12:46:41 +08:00
yusing
b2713a4b83 refactor(health): optimize health checking 2025-09-27 11:32:18 +08:00
yusing
8ec9752656 refactor(env): move env parsing to separate repo (cont. f7149453d6) 2025-09-26 21:41:57 +08:00
yusing
f9affba9fc refactor(modules): replace github.com/yusing/go-proxy with github.com/yusing/godoxy 2025-09-22 16:44:59 +08:00
yusing
af8e2d56b2 fix(agent): respect response header timeout and compression settings 2025-09-21 11:58:31 +08:00
yusing
74a215b894 feat(agentproxy): simplify configuration handling and related header management 2025-09-21 11:52:42 +08:00
yusing
ccdc0046fd refactor(agent): update version handling in AgentConfig to use pkg.Version type 2025-09-21 11:51:17 +08:00
yusing
83a69322fa refactor(server): enhance server start options and support for proxy protocol 2025-09-18 17:34:02 +08:00
yusing
3aba5a1911 refactor(agent): simplify ReverseProxy method by directly modifying request URL 2025-09-17 14:07:06 +08:00
yusing
ca805edfe0 fix(agent): incorrect uri in reverse proxy 2025-09-17 14:03:35 +08:00
yusing
59917f52d7 feat(agent): add runtime configuration to agent env and script 2025-09-14 00:16:47 +08:00
yusing
1e1999b0af feat(agent): add ReverseProxy method and enhance Forward method
- Introduced ReverseProxy method to handle requests to the agent with context, method, and body.
- Updated Forward method to return *http.Response instead of byte data.
- Enhanced SystemInfo function to support querying by agent name in addition to agent address.
2025-09-14 00:09:07 +08:00
yusing
2717dc963a feat(agent): add container runtime support and enhance agent configuration
- Introduced ContainerRuntime field in AgentConfig and AgentEnvConfig.
- Added IterAgents and NumAgents functions for agent pool management.
- Updated agent creation and verification endpoints to handle container runtime.
- Enhanced Docker Compose template to support different container runtimes.
- Added runtime endpoint to retrieve agent runtime information.
2025-09-13 23:44:03 +08:00
yusing
0d2229cca0 refactor(xsync): replace functional map with xsync.Map, remove functional/map 2025-09-13 23:19:20 +08:00
yusing
baf5b5eff1 fix(handler): fixed health check import and corrected code for new metrics api handler 2025-08-17 20:24:42 +08:00
yusing
cfb37d5bd0 refactor(agent): update AgentConfig struct to use exported fields and improve JSON serialization 2025-08-17 19:08:23 +08:00
yusing
f53d384533 refactor(agent): rename requests.go to http_requests.go 2025-08-17 19:07:50 +08:00
yusing
35a3e3fef6 refactor(api): restructured API for type safety, maintainability and docs generation
- These changes makes the API incombatible with previous versions
- Added new types for error handling, success responses, and health checks.
- Updated health check logic to utilize the new types for better clarity and structure.
- Refactored existing handlers to improve response consistency and error handling.
- Updated Makefile to include a new target for generating API types from Swagger.
- Updated "new agent" API to respond an encrypted cert pair
2025-08-16 13:04:05 +08:00
yusing
ecc9d306d1 refactor(agent): move agent pool to agent package, rename route.Agent() to route.GetAgent() (cont. 7d17a01) 2025-06-14 22:04:10 +08:00
Yuzerion
4a8bd48ad5 fix: optimize memory usage, fix agent and code refactor (#118)
* refactor: simplify io code and make utils module independent

* fix(docker): agent and socket-proxy docker event flushing with modified reverse proxy handler

* refactor: remove unused code

* refactor: remove the use of logging module in most code

* refactor: streamline domain mismatch check in certState function

* tweak: use ecdsa p-256 for autocert

* fix(tests): update health check tests for invalid host and add case for port in host

* feat(acme): custom acme directory

* refactor: code refactor and improved context and error handling

* tweak: optimize memory usage under load

* fix(oidc): restore old user matching behavior

* docs: add ChatGPT assistant to README

---------

Co-authored-by: yusing <yusing@6uo.me>
2025-05-25 09:45:57 +08:00
yusing
ff08c40403 fix(agent): docker handler 2025-05-23 21:12:46 +08:00
yusing
1f50ee7f2f tweak: replace coder/websocket with gorilla/websocket 2025-05-19 23:15:11 +08:00
yusing
78be9b1c71 fix(agent): update script url 2025-05-17 08:39:03 +08:00
yusing
36ceba3ae7 security: switch from RSA-2048 to ECDSA-P256 for agent certs and update certificate config and handling 2025-05-17 08:29:01 +08:00
yusing
84e7a6591e fix(agent): health check logic 2025-05-11 00:05:01 +08:00