MCPcopy Create free account
hub / github.com/crowdsecurity/crowdsec / Status

Method Status

cmd/crowdsec-cli/clilapi/status.go:58–81  ·  view source on GitHub ↗
(ctx context.Context, out io.Writer, hub *cwhub.Hub)

Source from the content-addressed store, hash-verified

56}
57
58func (cli *cliLapi) Status(ctx context.Context, out io.Writer, hub *cwhub.Hub) error {
59 cfg := cli.cfg()
60
61 cred := cfg.API.Client.Credentials
62
63 fmt.Fprintf(out, "Loaded credentials from %s\n", cfg.API.Client.CredentialsFilePath)
64
65 if cred.Login != "" {
66 fmt.Fprintf(out, "Trying to authenticate with username %q on %s\n", cred.Login, cred.URL)
67 }
68
69 if cred.CertPath != "" {
70 fmt.Fprintf(out, "Trying to authenticate with certificate %q on %s\n", cred.CertPath, cred.URL)
71 }
72
73 _, err := queryLAPIStatus(ctx, hub, cred.URL, cred.Login, cred.Password)
74 if err != nil {
75 return fmt.Errorf("failed to authenticate to Local API (LAPI): %w", err)
76 }
77
78 fmt.Fprintln(out, "You can successfully interact with Local API (LAPI)")
79
80 return nil
81}
82
83// prepareAPIURL checks/fixes a LAPI connection url (http, https or socket) and returns an URL struct
84func prepareAPIURL(clientCfg *csconfig.LocalApiClientCfg, apiURL string) (*url.URL, error) {

Callers 1

newStatusCmdMethod · 0.95

Calls 2

queryLAPIStatusFunction · 0.85
cfgMethod · 0.80

Tested by

no test coverage detected