| 1 |
package main |
| 2 |
|
| 3 |
import ( |
| 4 |
"flag" |
| 5 |
"github.com/elazarl/goproxy" |
| 6 |
"log" |
| 7 |
"net/http" |
| 8 |
) |
| 9 |
|
| 10 |
func main() { |
| 11 |
verbose := flag.Bool("v", false, "should every proxy request be logged to stdout") |
| 12 |
addr := flag.String("addr", ":8080", "proxy listen address") |
| 13 |
flag.Parse() |
| 14 |
|
| 15 |
proxy := goproxy.NewProxyHttpServer() |
| 16 |
proxy.CertStore = NewCertStorage() //设置storage |
| 17 |
|
| 18 |
proxy.Verbose = *verbose |
| 19 |
|
| 20 |
proxy.OnRequest().HandleConnect(goproxy.AlwaysMitm) |
| 21 |
proxy.OnRequest().DoFunc(func(req *http.Request, ctx *goproxy.ProxyCtx) (*http.Request, *http.Response) { |
| 22 |
log.Println(req.URL.String()) |
| 23 |
return req, nil |
| 24 |
}) |
| 25 |
log.Fatal(http.ListenAndServe(*addr, proxy)) |
| 26 |
} |