Skip to content

Commit

Permalink
improved logging for dns hijacking resisted doh
Browse files Browse the repository at this point in the history
  • Loading branch information
uoosef committed Sep 3, 2023
1 parent 28d6894 commit 6306a28
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,19 @@ func (s *Server) Handle(ctx context.Context, w io.Writer, req *socks5.Request, n
// if user has a faulty dns, and it returns dpi ip,
// we resolve destination based on extracted tls sni or http hostname
if hostname != nil && strings.Contains(IPPort, "10.10.3") {
logger.Infof("%s is dpi ip extracting destination host from packets...", IPPort)
req.RawDestAddr.FQDN = string(hostname)
IPPort, err = s.resolveDestination(ctx, req)
if err != nil {
// if destination resolved to dpi and we cant resolve to actual destination
// it's pointless to connect to dpi
logger.Infof("system was unable to extract destination host from packets!")
return err
}
}

logger.Infof("Dialing %s...", IPPort)

conn, err := s.Dialer.TCPDial("tcp", "", IPPort)
if err != nil {
return err
Expand Down Expand Up @@ -231,7 +235,6 @@ func (s *Server) resolveDestination(ctx context.Context, req *socks5.Request) (s
}

addr := net.JoinHostPort(dest.IP.String(), strconv.Itoa(dest.Port))
logger.Infof("dialing %s", addr)
return addr, nil
}

Expand Down

0 comments on commit 6306a28

Please sign in to comment.