Commit Graph

24 Commits

Author SHA1 Message Date
65df01fee5 refactor(forwarder): remove CreateForwardedTCPIPPayload method
- OpenForwardedChannel now privately calls CreateForwardedTCPIPPayload
- Removed an unused function
2026-01-27 16:28:20 +07:00
9785a97973 refactor: remove duplicate channel management helpers from HTTP handler 2026-01-27 16:28:20 +07:00
b8c6359820 refactor: remove custom parsing functions and use ssh.Marshal/ssh.Unmarshal for serialization 2026-01-27 16:28:20 +07:00
1ed9f3631f fix: correct buffer pool usage to avoid type assertion error 2026-01-27 16:28:20 +07:00
24b9872aa4 fix: corrected defer usage to pass buffer pointer 2026-01-27 16:28:20 +07:00
2bc20dd991 refactor(config): centralize env loading and enforce typed access
- Centralize environment variable loading in config.MustLoad
- Parse and validate all env vars once at initialization
- Make config fields private and read-only
- Remove public Getenv usage in favor of typed accessors
- Improve validation and initialization order
- Normalize enum naming to be idiomatic and avoid constant collisions
2026-01-21 19:43:19 +07:00
1e12373359 chore(restructure): reorganize project layout
Docker Build and Push / build-and-push-branches (push) Has been skipped
Docker Build and Push / build-and-push-tags (push) Successful in 13m1s
- Reorganize internal packages and overall project structure
- Update imports and wiring to match the new layout
- Separate HTTP parsing and streaming from the server package
- Separate middleware from the server package
- Separate session registry from the session package
- Move HTTP, HTTPS, and TCP servers to the transport package
- Session package no longer starts the TCP server directly
- Server package no longer starts HTTP/HTTPS servers on initialization
- Forwarder no longer handles accepting TCP requests
- Move session details to the types package
- HTTP/HTTPS initialization is now the responsibility of main
2026-01-21 14:06:46 +07:00
aa1a465178 refactor(forwarder): improve connection handling and cleanup
Docker Build and Push / build-and-push-tags (push) Has been skipped
Docker Build and Push / build-and-push-branches (push) Has been cancelled
- Extract copyAndClose method for bidirectional data transfe
- Add closeWriter helper for graceful connection shutdown
- Add handleIncomingConnection helper
- Add openForwardedChannel helper
2026-01-20 19:01:15 +07:00
27f49879af refactor(server): enhance HTTP handler modularity and fix resource leak
Docker Build and Push / build-and-push-tags (push) Has been skipped
Docker Build and Push / build-and-push-branches (push) Successful in 11m43s
- Rename customWriter struct to httpWriter for clarity
- Add closeWriter field to properly close write side of connections
- Update all cw variable references to hw
- Merge handlerTLS into handler function to reduce code duplication
- Extract handler into smaller, focused methods
- Split Read/Write/forwardRequest into composable functions

Fixes resource leak where connections weren't properly closed on the
write side, matching the forwarder's CloseWrite() pattern.
2026-01-19 22:41:04 +07:00
8fb19af5a6 fix: resolve copy goroutine deadlock on early connection close
- Add proper CloseWrite handling to signal EOF to other goroutine
- Ensure both copy goroutines terminate when either side closes
- Prevent goroutine leaks for SSH forwarded-tcpip channels:
    - Use select with default when sending result to resultChan
    - Close unused SSH channels and discard requests if main goroutine has already timed out
2026-01-19 00:20:28 +07:00
44d224f491 refactor: explicit initialization and dependency injection
Docker Build and Push / build-and-push-branches (push) Has been skipped
Docker Build and Push / build-and-push-tags (push) Successful in 10m10s
- Replace init() with config.Load() function when loading env variables
- Inject portRegistry into session, server, and lifecycle structs
- Inject sessionRegistry directly into interaction and lifecycle
- Remove SetSessionRegistry function and global port variables
- Pass ssh.Conn directly to forwarder constructor instead of lifecycle interface
- Pass user and closeFunc callback to interaction constructor instead of lifecycle interface
- Eliminate circular dependencies between lifecycle, forwarder, and interaction
- Remove setter methods (SetLifecycle) from forwarder and interaction interfaces
2026-01-18 21:20:05 +07:00
dbdf8094fa refactor: replace Get/Set patterns with idiomatic Go interfaces
Docker Build and Push / build-and-push-branches (push) Has been skipped
Docker Build and Push / build-and-push-tags (push) Successful in 13m4s
- rename constructors to New
- remove Get/Set-style accessors
- replace string-based enums with iota-backed types
2026-01-14 16:54:10 +07:00
b115369913 fix: wait for both goroutines before cleanup in HandleConnection
renovate / renovate (push) Successful in 1m42s
Docker Build and Push / build-and-push-branches (push) Successful in 4m46s
Docker Build and Push / build-and-push-tags (push) Successful in 4m51s
Only waited for one of two copy goroutines, leaking the second. Now waits
for both to complete before closing connections.

Fixes file descriptor leak causing 'too many open files' under load.

Fixes: #56
2025-12-31 22:22:51 +07:00
acd02aadd3 refactor: restructure project architecture
renovate / renovate (push) Successful in 45s
Docker Build and Push / build-and-push-branches (push) Successful in 5m54s
Docker Build and Push / build-and-push-tags (push) Successful in 6m21s
2025-12-31 15:49:37 +07:00
2644b4521c refactor: improve encapsulation
renovate / renovate (push) Successful in 20s
Docker Build and Push / build-and-push (push) Successful in 3m25s
2025-12-29 12:37:03 +07:00
76d1202b8e fix: correct logic when checking tcpip-forward request
Docker Build and Push / build-and-push (push) Successful in 5m34s
2025-12-26 23:17:13 +07:00
6dff735216 fix: prevent OOM by bounding io.Copy buffer usage
Docker Build and Push / build-and-push (push) Successful in 3m47s
2025-12-18 21:09:12 +07:00
6451304ed7 fix: potential resource leak
Docker Build and Push / build-and-push (push) Successful in 4m17s
2025-12-17 21:38:00 +07:00
2725975d82 fix: add nil check in Forwarder.Close to avoid panic (issue #36)
Docker Build and Push / build-and-push (push) Successful in 4m8s
2025-12-12 15:36:07 +07:00
ba5f702e36 feat: add droping conn command
Docker Build and Push / build-and-push (push) Successful in 4m38s
2025-12-07 15:26:37 +07:00
af951b8fa7 fix: discard unused buffers in the ssh channel before disconnecting 2025-12-05 22:26:38 +07:00
659f6c3ee7 refactor: move CreateForwardedTCPIPPayload to forwarder interface 2025-12-05 13:49:33 +07:00
7a31047bb9 refactor: restructure session initialization to avoid circular references 2025-12-04 22:48:15 +07:00
039e979142 refactor: restructure session initialization to avoid circular references 2025-12-04 19:32:00 +07:00