@@ -20,6 +20,7 @@ import (
2020 "github.com/celzero/firestack/intra/log"
2121 "github.com/celzero/firestack/intra/protect"
2222 "github.com/celzero/firestack/intra/protect/ipmap"
23+ "github.com/celzero/firestack/intra/settings"
2324 "github.com/celzero/firestack/intra/xdns"
2425 "github.com/miekg/dns"
2526)
@@ -122,7 +123,9 @@ func (m *ipmapper) queryIP2(_ context.Context, network, host, uid string, tid ..
122123 return []netip.Addr {ip }, nil
123124 }
124125
125- log .V ("ipmapper: lookup: host %s:%s for %s on %v" , network , host , uid , tid )
126+ if settings .Debug {
127+ log .V ("ipmapper: lookup: host %s:%s for %s on %v" , network , host , uid , tid )
128+ }
126129
127130 var q4 , q6 []byte
128131 var err4 , err6 error
@@ -197,8 +200,10 @@ func (m *ipmapper) queryIP2(_ context.Context, network, host, uid string, tid ..
197200 ip6 = m .undoAlgAndOrNat64 (ip6 , tid6 , uid ) // nat64 cannot really be "undone" for ip6!
198201 ips := append (ip4 , ip6 ... )
199202
200- log .D ("ipmapper: host %s => ips (out: %v / in: %d+%d); uid: %s, tids: %s+%s; err4: %v, err6: %v" ,
201- host , ips , len (r4 ), len (r6 ), uid , tid4 , tid6 , lerr4 , lerr6 )
203+ if settings .Debug {
204+ log .D ("ipmapper: host %s => ips (out: %v / in: %d+%d); uid: %s, tids: %s+%s; err4: %v, err6: %v" ,
205+ host , ips , len (r4 ), len (r6 ), uid , tid4 , tid6 , lerr4 , lerr6 )
206+ }
202207 return ips , nil
203208}
204209
@@ -216,7 +221,9 @@ func (m *ipmapper) queryAny2(q []byte, uid string, tids ...string) ([]byte, erro
216221 qtype := int (xdns .QType (msg ))
217222 qtypestr := strconv .Itoa (qtype )
218223
219- log .V ("ipmapper: lookup: host %s, uid: %v" , qname , uid )
224+ if settings .Debug {
225+ log .V ("ipmapper: lookup: host %s, uid: %v" , qname , uid )
226+ }
220227
221228 var v * core.V [answer , string ]
222229 if len (tids ) > 0 {
@@ -269,7 +276,9 @@ func (m *ipmapper) locallookup(q []byte) func() (answer, error) {
269276func (m * ipmapper ) undoAlg (ans []byte , tid , uid string ) ([]byte , error ) {
270277 gw := m .g
271278 if gw == nil {
272- log .V ("ipmapper: undoAlg: no-op for %s[%s]; no gateway" , tid , uid )
279+ if settings .Debug {
280+ log .V ("ipmapper: undoAlg: no-op for %s[%s]; no gateway" , tid , uid )
281+ }
273282 return ans , nil
274283 }
275284
@@ -286,8 +295,10 @@ func (m *ipmapper) undoAlg(ans []byte, tid, uid string) ([]byte, error) {
286295 is6 := ! is4 && xdns .HasAAAAQuestion (msg )
287296
288297 if ! is4 && ! is6 || noips {
289- log .VV ("ipmapper: undoAlg: no a? (%t), aaaa? (%t), ans? (%t); no-op" ,
290- ! is4 , ! is6 , noips )
298+ if settings .Debug {
299+ log .VV ("ipmapper: undoAlg: no a? (%t), aaaa? (%t), ans? (%t); no-op" ,
300+ ! is4 , ! is6 , noips )
301+ }
291302 return ans , nil
292303 }
293304
@@ -348,7 +359,9 @@ func (m *ipmapper) undoAlgAndOrNat64(ip64 []netip.Addr, tid, uid string) []netip
348359 // based on the dialers.Use4/Use6 settings.
349360 gw := m .g
350361 if gw == nil {
351- log .V ("ipmapper: undoAlg: no-op for %v on %s[%s]; no gateway" , ip64 , tid , uid )
362+ if settings .Debug {
363+ log .V ("ipmapper: undoAlg: no-op for %v on %s[%s]; no gateway" , ip64 , tid , uid )
364+ }
352365 return ip64
353366 }
354367 realips := make ([]netip.Addr , 0 , len (ip64 ))
0 commit comments