Skip to content

Commit

Permalink
add upstream cli args
Browse files Browse the repository at this point in the history
  • Loading branch information
lqqyt2423 committed Jul 19, 2023
1 parent d8d83f4 commit 4845c5d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ Usage of go-mitmproxy:
map remote config filename
-ssl_insecure
not verify upstream server SSL/TLS certificates.
-upstream string
upstream proxy
-version
show go-mitmproxy version
-web_addr string
Expand Down
2 changes: 2 additions & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ Usage of go-mitmproxy:
map remote json配置文件地址
-ssl_insecure
不验证上游服务器的 SSL/TLS 证书
-upstream string
upstream proxy
-version
显示 go-mitmproxy 版本
-web_addr string
Expand Down
4 changes: 4 additions & 0 deletions cmd/go-mitmproxy/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func loadConfigFromCli() *Config {
flag.IntVar(&config.Debug, "debug", 0, "debug mode: 1 - print debug log, 2 - show debug from")
flag.StringVar(&config.Dump, "dump", "", "dump filename")
flag.IntVar(&config.DumpLevel, "dump_level", 0, "dump level: 0 - header, 1 - header + body")
flag.StringVar(&config.Upstream, "upstream", "", "upstream proxy")
flag.StringVar(&config.MapRemote, "map_remote", "", "map remote config filename")
flag.StringVar(&config.MapLocal, "map_local", "", "map local config filename")
flag.StringVar(&config.filename, "f", "", "read config from the filename")
Expand Down Expand Up @@ -63,6 +64,9 @@ func mergeConfigs(fileConfig, cliConfig *Config) *Config {
if cliConfig.DumpLevel != 0 {
config.DumpLevel = cliConfig.DumpLevel
}
if cliConfig.Upstream != "" {
config.Upstream = cliConfig.Upstream
}
if cliConfig.MapRemote != "" {
config.MapRemote = cliConfig.MapRemote
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/go-mitmproxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Config struct {
Debug int // debug mode: 1 - print debug log, 2 - show debug from
Dump string // dump filename
DumpLevel int // dump level: 0 - header, 1 - header + body
Upstream string // upstream proxy
MapRemote string // map remote config filename
MapLocal string // map local config filename

Expand Down Expand Up @@ -53,6 +54,7 @@ func main() {
StreamLargeBodies: 1024 * 1024 * 5,
SslInsecure: config.SslInsecure,
CaRootPath: config.CertPath,
Upstream: config.Upstream,
}

p, err := proxy.NewProxy(opts)
Expand Down

0 comments on commit 4845c5d

Please sign in to comment.