add event type & logging interceptor for unknown hosts (#157)

* add event type & logging interceptor for unknown hosts

* update logging

* add break

* rename host_observation interceptor to audit_logger

* restore MITMDecider and make AuditLogger telemetry skip MITM on CONNECT
This commit is contained in:
Sahil Bansal
2026-02-12 13:48:01 +05:30
committed by GitHub
parent 7fe9fc8763
commit 5b0517f92a
7 changed files with 177 additions and 7 deletions
+18 -4
View File
@@ -212,11 +212,25 @@ func (ps *proxyServer) configureMITM() {
ps.mu.RLock()
shouldMITM := false
for _, interceptor := range ps.interceptors {
if interceptor.ShouldIntercept(reqCtx) {
shouldMITM = true
log.Debugf("[%s] Interceptor %s will handle %s", reqCtx.RequestID, interceptor.Name(), host)
break
if !interceptor.ShouldIntercept(reqCtx) {
continue
}
mitm := true
if decider, ok := interceptor.(MITMDecider); ok {
mitm = decider.ShouldMITM(reqCtx)
}
if !mitm {
// Allow non-MITM interceptors (e.g., telemetry) to observe CONNECT traffic.
if _, err := interceptor.HandleRequest(reqCtx); err != nil {
log.Errorf("[%s] Interceptor %s error on CONNECT: %v", reqCtx.RequestID, interceptor.Name(), err)
}
continue
}
shouldMITM = true
log.Debugf("[%s] Interceptor %s will handle %s", reqCtx.RequestID, interceptor.Name(), host)
}
ps.mu.RUnlock()