probe

package
v0.0.0-...-862fb52 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Name  = "probe"
	Usage = "Probe target endpoint"
	Alias = "prb"
)
View Source
const (
	FlagTarget      = "target"
	FlagTargetUsage = "Target endpoint to probe"

	//for now just TCP ports (so no FlagProto for now)
	FlagPort      = "port"
	FlagPortUsage = "Endpoint port to probe"
)

Probe command flag names and usage descriptions

Variables

View Source
var CLI = &cli.Command{
	Name:    Name,
	Aliases: []string{Alias},
	Usage:   Usage,
	Flags: append([]cli.Flag{
		cflag(FlagTarget),
		cflag(FlagPort),
	}, command.HTTPProbeFlagsBasic()...),
	Action: func(ctx *cli.Context) error {
		gparams, ok := command.CLIContextGet(ctx.Context, command.GlobalParams).(*command.GenericParams)
		if !ok || gparams == nil {
			return command.ErrNoGlobalParams
		}

		xc := app.NewExecutionContext(
			Name,
			gparams.QuietCLIMode,
			gparams.OutputFormat)

		targetEndpoint := ctx.String(FlagTarget)
		if targetEndpoint == "" {
			if ctx.Args().Len() < 1 {
				xc.Out.Error("param.target", "missing target")
				cli.ShowCommandHelp(ctx, Name)
				return nil
			} else {
				targetEndpoint = ctx.Args().First()
			}
		}

		httpProbeOpts := command.GetHTTPProbeOptions(xc, ctx, true)
		targetPorts := ctx.UintSlice(FlagPort)
		OnCommand(
			xc,
			gparams,
			targetEndpoint,
			targetPorts,
			httpProbeOpts)

		return nil
	},
}
View Source
var CommandFlagSuggestions = &command.FlagSuggestions{
	Names: []prompt.Suggest{
		{Text: command.FullFlagName(FlagTarget), Description: FlagTargetUsage},
		{Text: command.FullFlagName(FlagPort), Description: FlagPortUsage},
		{Text: command.FullFlagName(command.FlagHTTPProbeCmd), Description: command.FlagHTTPProbeCmdUsage},
		{Text: command.FullFlagName(command.FlagHTTPProbeCmdFile), Description: command.FlagHTTPProbeCmdFileUsage},
		{Text: command.FullFlagName(command.FlagHTTPProbeStartWait), Description: command.FlagHTTPProbeStartWaitUsage},
		{Text: command.FullFlagName(command.FlagHTTPProbeRetryCount), Description: command.FlagHTTPProbeRetryCountUsage},
		{Text: command.FullFlagName(command.FlagHTTPProbeRetryWait), Description: command.FlagHTTPProbeRetryWaitUsage},
		{Text: command.FullFlagName(command.FlagHTTPProbePorts), Description: command.FlagHTTPProbePortsUsage},
		{Text: command.FullFlagName(command.FlagHTTPProbeFull), Description: command.FlagHTTPProbeFullUsage},
		{Text: command.FullFlagName(command.FlagHTTPProbeExitOnFailure), Description: command.FlagHTTPProbeExitOnFailureUsage},
		{Text: command.FullFlagName(command.FlagHTTPProbeCrawl), Description: command.FlagHTTPProbeCrawlUsage},
		{Text: command.FullFlagName(command.FlagHTTPCrawlMaxDepth), Description: command.FlagHTTPCrawlMaxDepthUsage},
		{Text: command.FullFlagName(command.FlagHTTPCrawlMaxPageCount), Description: command.FlagHTTPCrawlMaxPageCountUsage},
		{Text: command.FullFlagName(command.FlagHTTPCrawlConcurrency), Description: command.FlagHTTPCrawlConcurrencyUsage},
		{Text: command.FullFlagName(command.FlagHTTPMaxConcurrentCrawlers), Description: command.FlagHTTPMaxConcurrentCrawlersUsage},
		{Text: command.FullFlagName(command.FlagHTTPProbeAPISpec), Description: command.FlagHTTPProbeAPISpecUsage},
		{Text: command.FullFlagName(command.FlagHTTPProbeAPISpecFile), Description: command.FlagHTTPProbeAPISpecFileUsage},
	},
	Values: map[string]command.CompleteValue{
		command.FullFlagName(command.FlagHTTPProbeCmdFile):     command.CompleteFile,
		command.FullFlagName(command.FlagHTTPProbeFull):        command.CompleteBool,
		command.FullFlagName(command.FlagHTTPProbeCrawl):       command.CompleteTBool,
		command.FullFlagName(command.FlagHTTPProbeAPISpecFile): command.CompleteFile,
	},
}
View Source
var CommandSuggestion = prompt.Suggest{
	Text:        Name,
	Description: Usage,
}
View Source
var Flags = map[string]cli.Flag{
	FlagTarget: &cli.StringFlag{
		Name:    FlagTarget,
		Value:   "",
		Usage:   FlagTargetUsage,
		EnvVars: []string{"DSLIM_PRB_TARGET"},
	},
	FlagPort: &cli.UintSliceFlag{
		Name:    FlagPort,
		Value:   cli.NewUintSlice(),
		Usage:   FlagPortUsage,
		EnvVars: []string{"DSLIM_PRB_PORT"},
	},
}

Functions

func OnCommand

func OnCommand(
	xc *app.ExecutionContext,
	gparams *command.GenericParams,
	targetEndpoint string,
	targetPorts []uint,
	httpProbeOpts config.HTTPProbeOptions)

OnCommand implements the 'probe' command

func RegisterCommand

func RegisterCommand()

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL