Skip to content

Commit

Permalink
Remove unnecessary closures
Browse files Browse the repository at this point in the history
  • Loading branch information
tobyxdd committed Apr 22, 2021
1 parent 3b6a2bc commit 78f6eec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/relay/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (r *Relay) ListenAndServe() error {
if err != nil {
return err
}
go func(c *net.TCPConn) {
go func() {
defer c.Close()
r.ConnFunc(c.RemoteAddr())
rc, err := r.HyClient.DialTCP(r.Remote)
Expand All @@ -59,6 +59,6 @@ func (r *Relay) ListenAndServe() error {
defer rc.Close()
err = utils.PipePairWithTimeout(c, rc, r.Timeout)
r.ErrorFunc(c.RemoteAddr(), err)
}(c)
}()
}
}
4 changes: 2 additions & 2 deletions pkg/socks5/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (s *Server) ListenAndServe() error {
if err != nil {
return err
}
go func(c *net.TCPConn) {
go func() {
defer c.Close()
if s.TCPTimeout != 0 {
if err := c.SetDeadline(time.Now().Add(s.TCPTimeout)); err != nil {
Expand All @@ -139,7 +139,7 @@ func (s *Server) ListenAndServe() error {
return
}
_ = s.handle(c, r)
}(c)
}()
}
}

Expand Down

0 comments on commit 78f6eec

Please sign in to comment.