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

add DisableFQDN option to Socks Config #53

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
19 changes: 10 additions & 9 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,19 @@ func (s *Server) handleRequest(req *Request, conn conn) error {

// Resolve the address if we have a FQDN
dest := req.DestAddr
if dest.FQDN != "" {
ctx_, addr, err := s.config.Resolver.Resolve(ctx, dest.FQDN)
if err != nil {
if err := sendReply(conn, hostUnreachable, nil); err != nil {
return fmt.Errorf("Failed to send reply: %v", err)
if s.config.DisableFQDN == false {
if dest.FQDN != "" {
ctx_, addr, err := s.config.Resolver.Resolve(ctx, dest.FQDN)
if err != nil {
if err := sendReply(conn, hostUnreachable, nil); err != nil {
return fmt.Errorf("Failed to send reply: %v", err)
}
return fmt.Errorf("Failed to resolve destination '%v': %v", dest.FQDN, err)
}
return fmt.Errorf("Failed to resolve destination '%v': %v", dest.FQDN, err)
ctx = ctx_
dest.IP = addr
}
ctx = ctx_
dest.IP = addr
}

// Apply any address rewrites
req.realDestAddr = req.DestAddr
if s.config.Rewriter != nil {
Expand Down
3 changes: 3 additions & 0 deletions socks5.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ type Config struct {

// Optional function for dialing out
Dial func(ctx context.Context, network, addr string) (net.Conn, error)

// Optional Disable FQDN Resolver
DisableFQDN bool
}

// Server is reponsible for accepting connections and handling
Expand Down