(args []string)
| 67 | } |
| 68 | |
| 69 | func debugMode(args []string) error { |
| 70 | fs := flag.NewFlagSet("debug", flag.ExitOnError) |
| 71 | fs.BoolVar(&debugArgs.ifconfig, "ifconfig", false, "If true, print network interface state") |
| 72 | fs.BoolVar(&debugArgs.monitor, "monitor", false, "If true, run network monitor forever. Precludes all other options.") |
| 73 | fs.BoolVar(&debugArgs.portmap, "portmap", false, "If true, run portmap debugging. Precludes all other options.") |
| 74 | fs.StringVar(&debugArgs.getURL, "get-url", "", "If non-empty, fetch provided URL.") |
| 75 | fs.StringVar(&debugArgs.derpCheck, "derp", "", "if non-empty, test a DERP ping via named region code") |
| 76 | if err := fs.Parse(args); err != nil { |
| 77 | return err |
| 78 | } |
| 79 | if len(fs.Args()) > 0 { |
| 80 | return errors.New("unknown non-flag debug subcommand arguments") |
| 81 | } |
| 82 | ctx := context.Background() |
| 83 | if debugArgs.derpCheck != "" { |
| 84 | return checkDerp(ctx, debugArgs.derpCheck) |
| 85 | } |
| 86 | if debugArgs.ifconfig { |
| 87 | return runMonitor(ctx, false) |
| 88 | } |
| 89 | if debugArgs.monitor { |
| 90 | return runMonitor(ctx, true) |
| 91 | } |
| 92 | if debugArgs.portmap { |
| 93 | return debugPortmap(ctx) |
| 94 | } |
| 95 | if debugArgs.getURL != "" { |
| 96 | return getURL(ctx, debugArgs.getURL) |
| 97 | } |
| 98 | return errors.New("only --monitor is available at the moment") |
| 99 | } |
| 100 | |
| 101 | func runMonitor(ctx context.Context, loop bool) error { |
| 102 | b := eventbus.New() |
nothing calls this directly
no test coverage detected
searching dependent graphs…