Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to disable capturing network activity log #113

Merged
merged 4 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func main() {
}
}
proxyService := proxy.NewTransparentProxyService(p, ca, proxy.PolicyMode(*policyMode), &pl)
proxyService.LogActivity()
proxyService.Proxy.OnRequest().DoFunc(
func(req *http.Request, ctx *goproxy.ProxyCtx) (*http.Request, *http.Response) {
return proxyService.ApplyNetworkPolicy(req, ctx)
Expand Down
7 changes: 6 additions & 1 deletion pkg/proxy/proxy/transparent.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,18 @@ func NewTransparentProxyService(p *goproxy.ProxyHttpServer, ca *tls.Certificate,
return TransparentProxyService{
Proxy: p,
Ca: ca,
NetworkLog: netlog.CaptureActivityLog(p, m),
NetworkLog: &netlog.NetworkActivityLog{},
Mode: mode,
Policy: pl,
mx: m,
}
}

// LogActivity starts recording network activity in memory.
func (t *TransparentProxyService) LogActivity() {
t.NetworkLog = netlog.CaptureActivityLog(t.Proxy, t.mx)
}

// ProxyHTTP serves an endpoint that transparently redirects HTTP connections to the proxy server.
// This endpoint also explicitly (i.e. non-transparently) proxies HTTP and TLS connections.
func (t TransparentProxyService) ProxyHTTP(addr string) {
Expand Down