-
Notifications
You must be signed in to change notification settings - Fork 42
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
tcpproxy: add pause and resume to the stream #119
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.
LGTM thanks
tcpproxy.go
Outdated
@@ -33,6 +38,7 @@ func NewTCPProxy(c *gc.C, remoteAddr string) *TCPProxy { | |||
p := &TCPProxy{ | |||
listener: listener, | |||
} | |||
p.stopStart = sync.NewCond(&p.mu) |
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.
Or, if you declare stopStart as a value not a pointer, then:
p.stopStart.L = &p.mu
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.
done
tcpproxy.go
Outdated
@@ -91,6 +97,24 @@ func (p *TCPProxy) CloseConns() { | |||
} | |||
} | |||
|
|||
// PauseConns stops traffic flowing through all the connections that are |
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.
Actually, it pauses all traffic, so perhaps:
// PauseConns stops all traffic flowing through the proxy.
?
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.
done
tcpproxy.go
Outdated
io.Copy(dst, src) | ||
buf := make([]byte, 32*1024) | ||
for { | ||
nr, er := src.Read(buf) |
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.
Since you're not bothered about the actual errors, I'd name the error variables just as conventional "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.
done
@@ -140,3 +177,15 @@ func assertEOF(c *gc.C, r io.Reader) { | |||
c.Assert(err, gc.Equals, io.EOF) | |||
c.Assert(n, gc.Equals, 0) | |||
} | |||
|
|||
func assertReadTimeout(c *gc.C, conn net.Conn) { | |||
err := conn.SetReadDeadline(time.Now().Add(500 * time.Millisecond)) |
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.
nice
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.
thanks
This allows servers that are not responding in a timely manner to be simulated.
e810f2f
to
b567b5e
Compare
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju-testing |
This allows servers that are not responding in a timely manner to be
simulated.