@@ -519,16 +519,18 @@ func makeIPPorts(ips []netip.Addr, origipp netip.AddrPort, cap int) []netip.Addr
519519// returned realips may be incoming algip itself or translated from algip,
520520// depending on whether alg is enabled (ref: undidAlg).
521521func (h * baseHandler ) undoAlg (algip netip.Addr , uid string ) (undidAlg bool , realips , domains , probableDomains , blocklists string ) {
522+ const forcePTR = true // force PTR (realip => algans) translation?
523+ anyTransport := dnsx .NoDNS
522524 r := h .resolver
523- didForce := false
524- forcePTR := true // force PTR (realip => algans) translation?
525525 gw := r .Gateway ()
526+
526527 ipok := ! algip .IsUnspecified () && algip .IsValid ()
528+ didForce := false
527529 hasreal := false
528530 if ipok && gw != nil {
529- domains , didForce = gw .PTR (algip , ! forcePTR ) // does NAT (algip => algans) translation
531+ domains , didForce = gw .PTR (algip , uid , anyTransport , ! forcePTR ) // does NAT (algip => algans) translation
530532 if ! didForce && len (domains ) <= 0 {
531- probableDomains , _ = gw .PTR (algip , forcePTR )
533+ probableDomains , _ = gw .PTR (algip , uid , anyTransport , forcePTR )
532534 }
533535 var ips []netip.Addr
534536 // ips will contain the incoming "algip" arg, in cases where alg is NOT enabled.
@@ -537,6 +539,7 @@ func (h *baseHandler) undoAlg(algip netip.Addr, uid string) (undidAlg bool, real
537539 hasreal = len (realips ) > 0
538540 blocklists = gw .RDNSBL (algip )
539541 }
542+ // pick up corresponding domains from dialer's ipmap cache if none from gw.PTR
540543 if ipok && len (domains ) <= 0 && len (probableDomains ) <= 0 {
541544 if hosts := dialers .Ptr (algip ); len (hosts ) > 0 {
542545 probableDomains = strings .Join (hosts , "," )
0 commit comments