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

Function run

main.go:542–1061  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

540}
541
542func run() int {
543 args := parse_args()
544 ver := version()
545
546 // handle special invocation modes
547 if args.showVersion {
548 fmt.Println(ver)
549 return 0
550 }
551
552 if args.list_ciphers {
553 list_ciphers()
554 return 0
555 }
556
557 if args.list_curves {
558 list_curves()
559 return 0
560 }
561
562 if args.passwd != "" {
563 if err := passwd(args.passwd, args.passwdCost, args.positionalArgs...); err != nil {
564 log.Fatalf("can't set password: %v", err)
565 }
566 return 0
567 }
568
569 if args.hmacSign {
570 if err := hmacSign(args.positionalArgs...); err != nil {
571 log.Fatalf("can't sign: %v", err)
572 }
573 return 0
574 }
575
576 if args.hmacGenKey {
577 if err := hmacGenKey(); err != nil {
578 log.Fatalf("can't generate key: %v", err)
579 }
580 return 0
581 }
582
583 switch args.mode.value {
584 case proxyModeStdIO, proxyModePortForward:
585 // expect exactly two positional arguments
586 if len(args.positionalArgs) != 2 {
587 arg_fail("Exactly two positional arguments are expected in this mode: host and port")
588 }
589 default:
590 // we don't expect positional arguments in the main operation mode
591 if len(args.positionalArgs) > 0 {
592 arg_fail("Unexpected positional arguments! Check your command line.")
593 }
594 }
595
596 // setup logging
597 logWriter := clog.NewLogWriter(os.Stderr, 128)
598 defer func() {
599 ctx, cl := context.WithTimeout(context.Background(), 1*time.Second)

Callers 1

mainFunction · 0.70

Calls 15

CloseMethod · 0.95
CriticalMethod · 0.95
InfoMethod · 0.95
WarningMethod · 0.95
ErrorMethod · 0.95
NewAuthFunction · 0.92
NewResponseFunction · 0.92
NewRejectAuthFunction · 0.92
NewJSFilterFunction · 0.92
NewDstAddrFilterFunction · 0.92
FastFromURLsFunction · 0.92

Tested by

no test coverage detected