1- # mitmpgo
1+ # mitmproxy-go
22
33An easy-use and flexible Man-In-The-Middle (MITM) proxy library for Go that enables transparent interception and inspection of HTTP, HTTPS, HTTP/2, and WebSocket traffic.
44
@@ -22,7 +22,7 @@ An easy-use and flexible Man-In-The-Middle (MITM) proxy library for Go that enab
2222## Installation
2323
2424``` bash
25- go get github.com/josexy/mitmpgo
25+ go get github.com/josexy/mitmproxy-go
2626```
2727
2828## Quick Start
@@ -38,14 +38,14 @@ import (
3838 " log"
3939 " net/http"
4040
41- " github.com/josexy/mitmpgo "
41+ " github.com/josexy/mitmproxy-go "
4242)
4343
4444func main () {
4545 // Create MITM proxy handler
46- handler , err := mitmpgo .NewMitmProxyHandler (
47- mitmpgo .WithCACertPath (" certs/ca.crt" ),
48- mitmpgo .WithCAKeyPath (" certs/ca.key" ),
46+ handler , err := mitmproxy .NewMitmProxyHandler (
47+ mitmproxy .WithCACertPath (" certs/ca.crt" ),
48+ mitmproxy .WithCAKeyPath (" certs/ca.key" ),
4949 )
5050 if err != nil {
5151 log.Fatal (err)
@@ -60,7 +60,7 @@ func main() {
6060### With HTTP Interceptor
6161
6262``` go
63- httpInterceptor := func (ctx context.Context , req *http.Request , invoker mitmpgo .HTTPDelegatedInvoker ) (*http.Response , error ) {
63+ httpInterceptor := func (ctx context.Context , req *http.Request , invoker mitmproxy .HTTPDelegatedInvoker ) (*http.Response , error ) {
6464 // Log request details
6565 fmt.Printf (" → %s %s \n " , req.Method , req.URL )
6666 fmt.Printf (" Host: %s \n " , req.Host )
@@ -78,17 +78,17 @@ httpInterceptor := func(ctx context.Context, req *http.Request, invoker mitmpgo.
7878 return resp, nil
7979}
8080
81- handler , err := mitmpgo .NewMitmProxyHandler (
82- mitmpgo .WithCACertPath (" certs/ca.crt" ),
83- mitmpgo .WithCAKeyPath (" certs/ca.key" ),
84- mitmpgo .WithHTTPInterceptor (httpInterceptor),
81+ handler , err := mitmproxy .NewMitmProxyHandler (
82+ mitmproxy .WithCACertPath (" certs/ca.crt" ),
83+ mitmproxy .WithCAKeyPath (" certs/ca.key" ),
84+ mitmproxy .WithHTTPInterceptor (httpInterceptor),
8585)
8686```
8787
8888### With WebSocket Interceptor
8989
9090``` go
91- websocketInterceptor := func (ctx context.Context , req *http.Request , rsp *http.Response , fw mitmpgo .WebsocketFramesWatcher ) {
91+ websocketInterceptor := func (ctx context.Context , req *http.Request , rsp *http.Response , fw mitmproxy .WebsocketFramesWatcher ) {
9292 // Log WebSocket messages
9393 log.Printf (" WS url: %s " , req.URL .String ())
9494
@@ -104,20 +104,20 @@ websocketInterceptor := func(ctx context.Context, req *http.Request, rsp *http.R
104104 }
105105}
106106
107- handler , err := mitmpgo .NewMitmProxyHandler (
108- mitmpgo .WithCACertPath (" certs/ca.crt" ),
109- mitmpgo .WithCAKeyPath (" certs/ca.key" ),
110- mitmpgo .WithWebsocketInterceptor (websocketInterceptor),
107+ handler , err := mitmproxy .NewMitmProxyHandler (
108+ mitmproxy .WithCACertPath (" certs/ca.crt" ),
109+ mitmproxy .WithCAKeyPath (" certs/ca.key" ),
110+ mitmproxy .WithWebsocketInterceptor (websocketInterceptor),
111111)
112112```
113113
114114### SOCKS5 Proxy Mode
115115
116116``` go
117117func main () {
118- handler , err := mitmpgo .NewMitmProxyHandler (
119- mitmpgo .WithCACertPath (" certs/ca.crt" ),
120- mitmpgo .WithCAKeyPath (" certs/ca.key" ),
118+ handler , err := mitmproxy .NewMitmProxyHandler (
119+ mitmproxy .WithCACertPath (" certs/ca.crt" ),
120+ mitmproxy .WithCAKeyPath (" certs/ca.key" ),
121121 )
122122 if err != nil {
123123 log.Fatal (err)
@@ -152,44 +152,44 @@ func main() {
152152
153153``` go
154154// Specify CA certificate and key for TLS interception
155- mitmpgo .WithCACertPath (" path/to/ca.crt" )
156- mitmpgo .WithCAKeyPath (" path/to/ca.key" )
155+ mitmproxy .WithCACertPath (" path/to/ca.crt" )
156+ mitmproxy .WithCAKeyPath (" path/to/ca.key" )
157157
158158// Use an upstream proxy
159- mitmpgo .WithProxy (" http://127.0.0.1:8080" )
159+ mitmproxy .WithProxy (" http://127.0.0.1:8080" )
160160
161161// Disable upstream proxy
162- mitmpgo .WithDisableProxy ()
162+ mitmproxy .WithDisableProxy ()
163163
164164// Add custom root CA certificates
165- mitmpgo .WithRootCAs (" path/to/root-ca1.crt" , " path/to/root-ca2.crt" )
165+ mitmproxy .WithRootCAs (" path/to/root-ca1.crt" , " path/to/root-ca2.crt" )
166166
167167// Configure certificate cache pool
168- mitmpgo .WithCertCachePool (2048 , 30 , 15 )
168+ mitmproxy .WithCertCachePool (2048 , 30 , 15 )
169169
170170// Custom dialer with timeout
171- mitmpgo .WithDialer (&net.Dialer {
171+ mitmproxy .WithDialer (&net.Dialer {
172172 Timeout : 30 * time.Second ,
173173})
174174
175175// Maximum channel size of WebSocket frames
176- mitmpgo .WithMaxWebsocketFramesPerForward (4096 )
176+ mitmproxy .WithMaxWebsocketFramesPerForward (4096 )
177177```
178178
179179### Interceptor Options
180180
181181``` go
182182// Set HTTP interceptor
183- mitmpgo .WithHTTPInterceptor (httpInterceptor)
183+ mitmproxy .WithHTTPInterceptor (httpInterceptor)
184184
185185// Set WebSocket interceptor
186- mitmpgo .WithWebsocketInterceptor (websocketInterceptor)
186+ mitmproxy .WithWebsocketInterceptor (websocketInterceptor)
187187
188188// Chain multiple HTTP interceptors (executed in order)
189- mitmpgo .WithChainHTTPInterceptor (interceptor1, interceptor2, interceptor3)
189+ mitmproxy .WithChainHTTPInterceptor (interceptor1, interceptor2, interceptor3)
190190
191191// Set error handler
192- mitmpgo .WithErrorHandler (func (ec mitmpgo .ErrorContext ) {
192+ mitmproxy .WithErrorHandler (func (ec mitmproxy .ErrorContext ) {
193193 log.Printf (" Error: %v " , ec.Error )
194194})
195195```
@@ -198,35 +198,35 @@ mitmpgo.WithErrorHandler(func(ec mitmpgo.ErrorContext) {
198198
199199``` go
200200// Skip SSL verification when connecting to servers (not recommended for production)
201- mitmpgo .WithSkipVerifySSLFromServer ()
201+ mitmproxy .WithSkipVerifySSLFromServer ()
202202
203203// mTLS client-authentication
204- mitmpgo .WithClientCert (" example.com" , mitmpgo .ClientCert {CertPath: " certs/client.crt" , KeyPath : " certs/client.key" })
204+ mitmproxy .WithClientCert (" example.com" , mitmproxy .ClientCert {CertPath: " certs/client.crt" , KeyPath : " certs/client.key" })
205205```
206206
207207### Protocol Options
208208
209209``` go
210210// Disable HTTP/2 support (use HTTP/1.1 only)
211- mitmpgo .WithDisableHTTP2 ()
211+ mitmproxy .WithDisableHTTP2 ()
212212```
213213
214214### Domain Filtering
215215
216216``` go
217217// Only intercept specific hosts (supports wildcards)
218- mitmpgo .WithIncludeHosts (" api.example.com" , " *.example.org" , " example.net" )
218+ mitmproxy .WithIncludeHosts (" api.example.com" , " *.example.org" , " example.net" )
219219
220220// Exclude specific hosts from interception (supports wildcards)
221- mitmpgo .WithExcludeHosts (" *.cdn.com" , " static.example.com" )
221+ mitmproxy .WithExcludeHosts (" *.cdn.com" , " static.example.com" )
222222```
223223
224224## Metadata Access
225225
226226Interceptors can access metadata from the context:
227227
228228``` go
229- httpInterceptor := func (ctx context.Context , req *http.Request , invoker mitmpgo .HTTPDelegatedInvoker ) (*http.Response , error ) {
229+ httpInterceptor := func (ctx context.Context , req *http.Request , invoker mitmproxy .HTTPDelegatedInvoker ) (*http.Response , error ) {
230230 // Extract metadata from context
231231 mdCtx , _ := metadata.FromContext (ctx)
232232 md := mdCtx.MD ()
0 commit comments