-
-
Notifications
You must be signed in to change notification settings - Fork 78
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
Implement the pass through #172
base: main
Are you sure you want to change the base?
Conversation
@glaslos could you please have a check? |
rules/rules.go
Outdated
@@ -37,6 +38,10 @@ type Rule struct { | |||
matcher *pcap.BPF | |||
} | |||
|
|||
func (r *Rule) GetRuleType() RuleType { |
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.
Make the attribute public instead of implementing a getter
config/rules.yaml
Outdated
@@ -29,6 +29,8 @@ rules: | |||
- match: tcp dst port 11211 | |||
type: conn_handler | |||
target: memcache | |||
- match: tcp dst port 5000 |
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.
have you tested this for other ports?
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.
there is a problem, i have to set glutton run a specific port and implement pass through on the same port so that it works. so, i just wonder if gluuton could run a different port with pass through, i tested this situation but it shows connection refused. Also, when i test pass through within glutton running on the same port, it will accept request, but do not response, i don't if it is because i do not run any program on that port.
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.
Are you connecting directly to port 5000? You have to go through the TPROXY
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.
@glaslos hi, i have tested it, and it succeed. i tested pass_through rule on port 8080, which is defined on my rule.yaml, and other ports can still work as well
glutton.go
Outdated
@@ -216,6 +216,7 @@ func (g *Glutton) tcpListen() { | |||
} | |||
|
|||
md, err := g.connTable.RegisterConn(conn, rule) | |||
|
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.
why?
@@ -29,6 +29,9 @@ rules: | |||
- match: tcp dst port 11211 | |||
type: conn_handler | |||
target: memcache | |||
- match: tcp dst port 8080 | |||
type: pass_through | |||
target: pass_through |
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.
We can use a host:port as a target here
protocols/protocols.go
Outdated
@@ -3,6 +3,7 @@ package protocols | |||
import ( | |||
"bytes" | |||
"context" | |||
"github.com/mushorg/glutton/rules" |
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.
please use go fmt
go func() { | ||
_, err := io.Copy(targetConn, conn) | ||
errChan <- err | ||
}() |
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.
When is this go routine closed?
fix #161 implement passthrough so when you try to access a specific port, it will not set a handler for this port, and it just pass traffic to the target server not glutton