mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-07-16 13:17:19 +02:00
cmd/cli: log request id when leaking
This commit is contained in:
committed by
Cuong Manh Le
parent
b320662d67
commit
e88372fc8c
@@ -411,6 +411,7 @@ func (p *prog) proxy(ctx context.Context, req *proxyRequest) *proxyResponse {
|
|||||||
serveStaleCache := p.cache != nil && p.cfg.Service.CacheServeStale
|
serveStaleCache := p.cache != nil && p.cfg.Service.CacheServeStale
|
||||||
upstreamConfigs := p.upstreamConfigsFromUpstreamNumbers(upstreams)
|
upstreamConfigs := p.upstreamConfigsFromUpstreamNumbers(upstreams)
|
||||||
|
|
||||||
|
leaked := false
|
||||||
// If ctrld is going to leak query to OS resolver, check remote upstream in background,
|
// If ctrld is going to leak query to OS resolver, check remote upstream in background,
|
||||||
// so ctrld could be back to normal operation as long as the network is back online.
|
// so ctrld could be back to normal operation as long as the network is back online.
|
||||||
if len(upstreamConfigs) > 0 && p.leakingQuery.Load() {
|
if len(upstreamConfigs) > 0 && p.leakingQuery.Load() {
|
||||||
@@ -418,6 +419,8 @@ func (p *prog) proxy(ctx context.Context, req *proxyRequest) *proxyResponse {
|
|||||||
go p.checkUpstream(upstreams[n], uc)
|
go p.checkUpstream(upstreams[n], uc)
|
||||||
}
|
}
|
||||||
upstreamConfigs = nil
|
upstreamConfigs = nil
|
||||||
|
leaked = true
|
||||||
|
ctrld.Log(ctx, mainLog.Load().Debug(), "%v is down, leaking query to OS resolver", upstreams)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(upstreamConfigs) == 0 {
|
if len(upstreamConfigs) == 0 {
|
||||||
@@ -435,7 +438,11 @@ func (p *prog) proxy(ctx context.Context, req *proxyRequest) *proxyResponse {
|
|||||||
// 4. Try remote upstream.
|
// 4. Try remote upstream.
|
||||||
isLanOrPtrQuery := false
|
isLanOrPtrQuery := false
|
||||||
if req.ufr.matched {
|
if req.ufr.matched {
|
||||||
ctrld.Log(ctx, mainLog.Load().Debug(), "%s, %s, %s -> %v", req.ufr.matchedPolicy, req.ufr.matchedNetwork, req.ufr.matchedRule, upstreams)
|
if leaked {
|
||||||
|
ctrld.Log(ctx, mainLog.Load().Debug(), "%s, %s, %s -> %v (leaked)", req.ufr.matchedPolicy, req.ufr.matchedNetwork, req.ufr.matchedRule, upstreams)
|
||||||
|
} else {
|
||||||
|
ctrld.Log(ctx, mainLog.Load().Debug(), "%s, %s, %s -> %v", req.ufr.matchedPolicy, req.ufr.matchedNetwork, req.ufr.matchedRule, upstreams)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
switch {
|
switch {
|
||||||
case isPrivatePtrLookup(req.msg):
|
case isPrivatePtrLookup(req.msg):
|
||||||
|
|||||||
Reference in New Issue
Block a user