Skip to content
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

corrected Serve() unreachable code in socks5.go #18

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions socks5.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type Config struct {
Dial func(ctx context.Context, network, addr string) (net.Conn, error)
}

// Server is reponsible for accepting connections and handling
// Server is responsible for accepting connections and handling
// the details of the SOCKS5 protocol
type Server struct {
config *Config
Expand Down Expand Up @@ -107,14 +107,21 @@ func (s *Server) ListenAndServe(network, addr string) error {

// Serve is used to serve connections from a listener
func (s *Server) Serve(l net.Listener) error {
errChan := make(chan error)
for {
conn, err := l.Accept()
if err != nil {
return err
}
go s.ServeConn(conn)
go func(net.Conn) {
if err := s.ServeConn(conn); err != nil {
errChan <- err
} else {
errChan <- nil
}
}(conn)
return <-errChan
}
return nil
}

// ServeConn is used to serve a single connection.
Expand Down