MCPcopy Create free account
hub / github.com/SenseUnit/dumbproxy / parse_args

Function parse_args

main.go:341–540  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

339}
340
341func parse_args() *CLIArgs {
342 args := &CLIArgs{
343 minTLSVersion: TLSVersionArg(tls.VersionTLS12),
344 maxTLSVersion: TLSVersionArg(tls.VersionTLS13),
345 denyDstAddr: PrefixList{
346 netip.MustParsePrefix("127.0.0.0/8"),
347 netip.MustParsePrefix("0.0.0.0/32"),
348 netip.MustParsePrefix("10.0.0.0/8"),
349 netip.MustParsePrefix("172.16.0.0/12"),
350 netip.MustParsePrefix("192.168.0.0/16"),
351 netip.MustParsePrefix("169.254.0.0/16"),
352 netip.MustParsePrefix("::1/128"),
353 netip.MustParsePrefix("::/128"),
354 netip.MustParsePrefix("fe80::/10"),
355 },
356 autocertCache: autocertCache{
357 kind: cacheKindDir,
358 value: filepath.Join(home, ".dumbproxy", "autocert"),
359 },
360 bind: bindSpec{
361 address: ":8080",
362 af: "tcp",
363 },
364 mode: proxyModeArg{proxyModeHTTP},
365 dnsPreferAddress: dnsPreferenceArg(resolver.PreferenceIPv4),
366 }
367 args.autocertCacheEncKey.Set(os.Getenv(envCacheEncKey))
368 flag.Func("bind-address", "HTTP proxy listen address. Set empty value to use systemd socket activation. (default \":8080\")", func(p string) error {
369 args.bind.address = p
370 args.bind.af = "tcp"
371 return nil
372 })
373 flag.Func("bind-unix-socket", "Unix domain socket to listen to, overrides bind-address if set.", func(p string) error {
374 args.bind.address = p
375 args.bind.af = "unix"
376 return nil
377 })
378 flag.BoolVar(&args.bindReusePort, "bind-reuseport", false, "allow multiple server instances on the same port")
379 flag.Func("bind-pprof", "enables pprof debug endpoints", func(p string) error {
380 args.bindPprof.address = p
381 args.bindPprof.af = "tcp"
382 return nil
383 })
384 flag.Func("bind-pprof-unix-socket", "enables pprof debug endpoints listening on Unix domain socket", func(p string) error {
385 args.bindPprof.address = p
386 args.bindPprof.af = "unix"
387 return nil
388 })
389 flag.BoolVar(&args.unixSockUnlink, "unix-sock-unlink", true, "delete file object located at Unix domain socket bind path before binding")
390 flag.Var(&args.unixSockMode, "unix-sock-mode", "set file mode for bound unix socket")
391 flag.Var(&args.mode, "mode", "proxy operation mode (http/socks5/stdio/port-forward)")
392 flag.StringVar(&args.auth, "auth", "none://", "auth parameters")
393 flag.StringVar(&args.directResponse, "direct-response", "", "response parameters for direct HTTP requests")
394 flag.StringVar(&args.accessReject, "access-reject", "", "reject response parameters for requests denied by access filters")
395 flag.IntVar(&args.verbosity, "verbosity", 20, "logging verbosity "+
396 "(10 - debug, 20 - info, 30 - warning, 40 - error, 50 - critical)")
397 flag.StringVar(&args.cert, "cert", "", "enable TLS and use certificate")
398 flag.StringVar(&args.key, "key", "", "key for TLS certificate")

Callers 1

runFunction · 0.85

Calls 4

TLSVersionArgTypeAlias · 0.85
dnsPreferenceArgTypeAlias · 0.85
ErrorfMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected