Skip to content

Commit e030359

Browse files
committed
Fix golint nits by adding docstrings and simplifying execution flow.
1 parent 6d97c2a commit e030359

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

listener.go

+5
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@ type tcpAddr string
4848
func (a tcpAddr) Network() string { return "tcp" }
4949
func (a tcpAddr) String() string { return string(a) }
5050

51+
// Addr returns the listener's Address field as a net.Addr.
5152
func (tl *TargetListener) Addr() net.Addr { return tcpAddr(tl.Address) }
5253

54+
// Close stops listening for new connections. All new connections
55+
// routed to this listener will be closed. Already accepted
56+
// connections are not closed.
5357
func (tl *TargetListener) Close() error {
5458
tl.lock()
5559
if tl.closed {
@@ -85,6 +89,7 @@ func (tl *TargetListener) HandleConn(c net.Conn) {
8589
}
8690
}
8791

92+
// Accept implements the Accept method in the net.Listener interface.
8893
func (tl *TargetListener) Accept() (net.Conn, error) {
8994
tl.lock()
9095
for tl.nextConn == nil && !tl.closed {

listener_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ func TestListenerAccept(t *testing.T) {
2828
if err != nil {
2929
ch <- err
3030
return
31-
} else {
32-
ch <- conn
3331
}
32+
ch <- conn
3433
}
3534
}()
3635

tcpproxy.go

+1
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ func UnderlyingConn(c net.Conn) net.Conn {
295295
return c
296296
}
297297

298+
// HandleConn implements the Target interface.
298299
func (dp *DialProxy) HandleConn(src net.Conn) {
299300
ctx := context.Background()
300301
var cancel context.CancelFunc

0 commit comments

Comments
 (0)