You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.1 KiB
Go

4 years ago
package main
import (
4 years ago
"flag"
4 years ago
"os"
4 years ago
"github.com/lqqyt2423/go-mitmproxy/addon"
"github.com/lqqyt2423/go-mitmproxy/addon/web"
4 years ago
"github.com/lqqyt2423/go-mitmproxy/proxy"
4 years ago
log "github.com/sirupsen/logrus"
)
4 years ago
4 years ago
type Config struct {
4 years ago
addr string
dump string // dump filename
dumpLevel int // dump level
4 years ago
}
func loadConfig() *Config {
config := new(Config)
flag.StringVar(&config.addr, "addr", ":9080", "proxy listen addr")
flag.StringVar(&config.dump, "dump", "", "dump filename")
4 years ago
flag.IntVar(&config.dumpLevel, "dump_level", 0, "dump level: 0 - header, 1 - header + body")
4 years ago
flag.Parse()
return config
}
4 years ago
func main() {
4 years ago
log.SetLevel(log.InfoLevel)
log.SetReportCaller(false)
log.SetOutput(os.Stdout)
log.SetFormatter(&log.TextFormatter{
FullTimestamp: true,
})
4 years ago
4 years ago
config := loadConfig()
opts := &proxy.Options{
4 years ago
Addr: config.addr,
StreamLargeBodies: 1024 * 1024 * 5,
}
p, err := proxy.NewProxy(opts)
if err != nil {
log.Fatal(err)
}
4 years ago
if config.dump != "" {
4 years ago
dumper := addon.NewDumper(config.dump, config.dumpLevel)
4 years ago
p.AddAddon(dumper)
}
p.AddAddon(web.NewWebAddon())
4 years ago
log.Fatal(p.Start())
4 years ago
}