-
-
Notifications
You must be signed in to change notification settings - Fork 84
Passthrough implementation #185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new “passthrough” rule type that proxies TCP connections between clients and real targets, logging bidirectional traffic.
- Adds
Passthrough
to the rule enum and exposesRuleType
- Implements
HandlePassThrough
inprotocols/tcp/passthrough.go
with two goroutines for source→target and target→source streaming - Registers the new handler in
protocols/protocols.go
and adds a sample rule inconfig/rules.yaml
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
File | Description |
---|---|
rules/rules.go | Export RuleType , add Passthrough constant and init case |
protocols/tcp/passthrough.go | New handler to proxy TCP streams and log data |
protocols/protocols.go | Register "passthrough" handler |
config/rules.yaml | Add sample passthrough rule |
Comments suppressed due to low confidence (2)
protocols/tcp/passthrough.go:26
- [nitpick] The comment is unclear and contains informal shorthand ('w/o', 'w it'). Consider rephrasing to explain the function’s purpose clearly, e.g., “HandlePassThrough opens a TCP connection to the real target and proxies traffic bidirectionally without modifying payloads.”
// Dial to the source ip, acting as a proxy between the client and real source by piping the data back and forth w/o interfering w it.
protocols/tcp/passthrough.go:1
- The new passthrough handler doesn’t have any associated unit or integration tests. Adding tests would help ensure correct proxy behavior under various scenarios and catch regressions.
package tcp
protocols/tcp/passthrough.go
Outdated
type parsedPassThrough struct { | ||
Direction string `json:"direction,omitempty"` | ||
Payload []byte `json:"payload,omitempty"` | ||
PayloadHash string `json:"payload_hash,omitempty"` | ||
} | ||
|
||
type passThroughServer struct { | ||
events []parsedPassThrough | ||
target string | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parsedPassThrough
and passThroughServer
are added but never used. Consider removing these types or implementing their intended functionality to avoid dead code.
type parsedPassThrough struct { | |
Direction string `json:"direction,omitempty"` | |
Payload []byte `json:"payload,omitempty"` | |
PayloadHash string `json:"payload_hash,omitempty"` | |
} | |
type passThroughServer struct { | |
events []parsedPassThrough | |
target string | |
} | |
// Removed unused types: parsedPassThrough and passThroughServer |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, do we need to append the events into a Server, like we do for other protocols?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it could be interesting to capture the traffic as well. Maybe we make it optional through configuration?
Made traffic capture configurable via config.yaml. You can now enable or disable payload capturing by toggling the |
Resolves #172 :
Adds a passthrough handler, which acts like a proxy and sets up two go routines to listen to and log the information passed between the client and the destination.