Remove unnecessary closures

This commit is contained in:
Toby 2021-04-21 17:43:24 -07:00
parent 3b6a2bc56e
commit 78f6eece9f
2 changed files with 4 additions and 4 deletions

View file

@ -48,7 +48,7 @@ func (r *Relay) ListenAndServe() error {
if err != nil { if err != nil {
return err return err
} }
go func(c *net.TCPConn) { go func() {
defer c.Close() defer c.Close()
r.ConnFunc(c.RemoteAddr()) r.ConnFunc(c.RemoteAddr())
rc, err := r.HyClient.DialTCP(r.Remote) rc, err := r.HyClient.DialTCP(r.Remote)
@ -59,6 +59,6 @@ func (r *Relay) ListenAndServe() error {
defer rc.Close() defer rc.Close()
err = utils.PipePairWithTimeout(c, rc, r.Timeout) err = utils.PipePairWithTimeout(c, rc, r.Timeout)
r.ErrorFunc(c.RemoteAddr(), err) r.ErrorFunc(c.RemoteAddr(), err)
}(c) }()
} }
} }

View file

@ -124,7 +124,7 @@ func (s *Server) ListenAndServe() error {
if err != nil { if err != nil {
return err return err
} }
go func(c *net.TCPConn) { go func() {
defer c.Close() defer c.Close()
if s.TCPTimeout != 0 { if s.TCPTimeout != 0 {
if err := c.SetDeadline(time.Now().Add(s.TCPTimeout)); err != nil { if err := c.SetDeadline(time.Now().Add(s.TCPTimeout)); err != nil {
@ -139,7 +139,7 @@ func (s *Server) ListenAndServe() error {
return return
} }
_ = s.handle(c, r) _ = s.handle(c, r)
}(c) }()
} }
} }