File tree 3 files changed +7
-2
lines changed
3 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -48,8 +48,12 @@ type tcpAddr string
48
48
func (a tcpAddr ) Network () string { return "tcp" }
49
49
func (a tcpAddr ) String () string { return string (a ) }
50
50
51
+ // Addr returns the listener's Address field as a net.Addr.
51
52
func (tl * TargetListener ) Addr () net.Addr { return tcpAddr (tl .Address ) }
52
53
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.
53
57
func (tl * TargetListener ) Close () error {
54
58
tl .lock ()
55
59
if tl .closed {
@@ -85,6 +89,7 @@ func (tl *TargetListener) HandleConn(c net.Conn) {
85
89
}
86
90
}
87
91
92
+ // Accept implements the Accept method in the net.Listener interface.
88
93
func (tl * TargetListener ) Accept () (net.Conn , error ) {
89
94
tl .lock ()
90
95
for tl .nextConn == nil && ! tl .closed {
Original file line number Diff line number Diff line change @@ -28,9 +28,8 @@ func TestListenerAccept(t *testing.T) {
28
28
if err != nil {
29
29
ch <- err
30
30
return
31
- } else {
32
- ch <- conn
33
31
}
32
+ ch <- conn
34
33
}
35
34
}()
36
35
Original file line number Diff line number Diff line change @@ -295,6 +295,7 @@ func UnderlyingConn(c net.Conn) net.Conn {
295
295
return c
296
296
}
297
297
298
+ // HandleConn implements the Target interface.
298
299
func (dp * DialProxy ) HandleConn (src net.Conn ) {
299
300
ctx := context .Background ()
300
301
var cancel context.CancelFunc
You can’t perform that action at this time.
0 commit comments