|
|
@ -3,9 +3,7 @@ package main
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
rawLog "log"
|
|
|
|
// slog "log"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/lqqyt2423/go-mitmproxy/addon"
|
|
|
|
"github.com/lqqyt2423/go-mitmproxy/addon"
|
|
|
@ -16,6 +14,7 @@ import (
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
type Config struct {
|
|
|
|
|
|
|
|
debug int
|
|
|
|
version bool
|
|
|
|
version bool
|
|
|
|
certPath string
|
|
|
|
certPath string
|
|
|
|
|
|
|
|
|
|
|
@ -32,6 +31,7 @@ type Config struct {
|
|
|
|
func loadConfig() *Config {
|
|
|
|
func loadConfig() *Config {
|
|
|
|
config := new(Config)
|
|
|
|
config := new(Config)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flag.IntVar(&config.debug, "debug", 0, "debug mode: 1 - print debug log, 2 - show debug from")
|
|
|
|
flag.BoolVar(&config.version, "version", false, "show version")
|
|
|
|
flag.BoolVar(&config.version, "version", false, "show version")
|
|
|
|
flag.StringVar(&config.addr, "addr", ":9080", "proxy listen addr")
|
|
|
|
flag.StringVar(&config.addr, "addr", ":9080", "proxy listen addr")
|
|
|
|
flag.StringVar(&config.webAddr, "web_addr", ":9081", "web interface listen addr")
|
|
|
|
flag.StringVar(&config.webAddr, "web_addr", ":9081", "web interface listen addr")
|
|
|
@ -48,18 +48,22 @@ func loadConfig() *Config {
|
|
|
|
func main() {
|
|
|
|
func main() {
|
|
|
|
config := loadConfig()
|
|
|
|
config := loadConfig()
|
|
|
|
|
|
|
|
|
|
|
|
// for debug
|
|
|
|
if config.debug > 0 {
|
|
|
|
// slog.SetFlags(slog.LstdFlags | slog.Lshortfile)
|
|
|
|
rawLog.SetFlags(rawLog.LstdFlags | rawLog.Lshortfile)
|
|
|
|
// log.SetReportCaller(true)
|
|
|
|
log.SetLevel(log.DebugLevel)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
log.SetLevel(log.InfoLevel)
|
|
|
|
log.SetLevel(log.InfoLevel)
|
|
|
|
log.SetReportCaller(false)
|
|
|
|
}
|
|
|
|
|
|
|
|
if config.debug == 2 {
|
|
|
|
|
|
|
|
log.SetReportCaller(true)
|
|
|
|
|
|
|
|
}
|
|
|
|
log.SetOutput(os.Stdout)
|
|
|
|
log.SetOutput(os.Stdout)
|
|
|
|
log.SetFormatter(&log.TextFormatter{
|
|
|
|
log.SetFormatter(&log.TextFormatter{
|
|
|
|
FullTimestamp: true,
|
|
|
|
FullTimestamp: true,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
opts := &proxy.Options{
|
|
|
|
opts := &proxy.Options{
|
|
|
|
|
|
|
|
Debug: config.debug,
|
|
|
|
Addr: config.addr,
|
|
|
|
Addr: config.addr,
|
|
|
|
StreamLargeBodies: 1024 * 1024 * 5,
|
|
|
|
StreamLargeBodies: 1024 * 1024 * 5,
|
|
|
|
SslInsecure: config.ssl_insecure,
|
|
|
|
SslInsecure: config.ssl_insecure,
|
|
|
|