Documentation ¶
Index ¶
- Variables
- func ConfigDeleteCommand(*cli.Context) error
- func ConfigViewCommand(*cli.Context) error
- func InitialisePICLI()
- func RunDatabaseClientSummaryCommand(c *cli.Context) error
- func RunDatabaseTopQueriesCommand(c *cli.Context) error
- func RunDisablePiHoleCommand(c *cli.Context) error
- func RunEnablePiHoleCommand(*cli.Context) error
- func RunLatestQueriesCommand(c *cli.Context) error
- func RunSummaryCommand(*cli.Context) error
- func RunTopTenBlockedCommand(*cli.Context) error
- func RunTopTenForwardedCommand(*cli.Context) error
- func SetupCommand(c *cli.Context) error
Constants ¶
This section is empty.
Variables ¶
var App = cli.App{ Name: "Pi-CLI", Usage: "Third party program to retrieve and display Pi-Hole data right from your terminal", Description: "Pi-Hole data right from your terminal. Live updating view, query history extraction and more!", Copyright: fmt.Sprintf("Copyright (c) %d Reece Mercer", time.Now().Year()), Authors: []*cli.Author{ { Name: "Reece Mercer", Email: "reecemercer981@gmail.com", }, }, Commands: []*cli.Command{ { Name: "setup", Aliases: []string{"s"}, Usage: "Configure Pi-CLI", Action: SetupCommand, }, { Name: "config", Aliases: []string{"c"}, Usage: "Interact with stored configuration settings", Subcommands: []*cli.Command{ { Name: "delete", Aliases: []string{"d"}, Usage: "Delete stored config data (config file and API key)", Action: ConfigDeleteCommand, }, { Name: "view", Aliases: []string{"v"}, Usage: "View config stored config data (config file and API key)", Action: ConfigViewCommand, }, }, }, { Name: "run", Aliases: []string{"r"}, Usage: "Run a one off command without booting the live view", Subcommands: []*cli.Command{ { Name: "summary", Aliases: []string{"s"}, Usage: "Extract a basic summary of data from the Pi-Hole", Action: RunSummaryCommand, }, { Name: "top-forwarded", Aliases: []string{"tf"}, Usage: "Extract the current top 10 forwarded DNS queries", Action: RunTopTenForwardedCommand, }, { Name: "top-blocked", Aliases: []string{"tb"}, Usage: "Extract the current top 10 blocked DNS queries", Action: RunTopTenBlockedCommand, }, { Name: "latest-queries", Aliases: []string{"lq"}, Usage: "Extract the latest queries", Flags: []cli.Flag{ &cli.Int64Flag{ Name: "limit", Aliases: []string{"l"}, Usage: "The limit on the number of queries to extract", DefaultText: "10", }, }, Action: RunLatestQueriesCommand, }, { Name: "enable", Aliases: []string{"e"}, Usage: "Enable the Pi-Hole", Action: RunEnablePiHoleCommand, }, { Name: "disable", Aliases: []string{"d"}, Usage: "Disable the Pi-Hole", Flags: []cli.Flag{ &cli.Int64Flag{ Name: "timeout", Aliases: []string{"t"}, Usage: "A timeout in seconds. Pi-Hole will re-enable after this time has elapsed.", DefaultText: "permanent", }, }, Action: RunDisablePiHoleCommand, }, }, }, { Name: "database", Aliases: []string{"d"}, Usage: "Analytics options to run on a Pi-Hole's FTL database", Subcommands: []*cli.Command{ { Name: "client-summary", Aliases: []string{"cs"}, Usage: "Summary of all Pi-Hole clients", Flags: []cli.Flag{ &cli.StringFlag{ Name: "path", Aliases: []string{"p"}, Usage: "Path to a Pi-Hole FTL database file", DefaultText: database.DefaultDatabaseFileLocation, }, }, Action: RunDatabaseClientSummaryCommand, }, { Name: "top-queries", Aliases: []string{"tq"}, Usage: "Returns the top (all time) queries", Flags: []cli.Flag{ &cli.StringFlag{ Name: "path", Aliases: []string{"p"}, Usage: "Path to the Pi-Hole FTL database file", DefaultText: database.DefaultDatabaseFileLocation, }, &cli.Int64Flag{ Name: "limit", Aliases: []string{"l"}, Usage: "The limit on the number of queries to extract", DefaultText: "10", }, &cli.StringFlag{ Name: "filter", Aliases: []string{"f"}, Usage: "Filter by domain or word. (e.g. 'google.com', 'spotify', 'facebook' etc...)", DefaultText: "No filter", }, }, Action: RunDatabaseTopQueriesCommand, }, }, }, }, Action: func(context *cli.Context) error { InitialisePICLI() ui.StartUI() return nil }, }
This is the main CLI app, it contains all the various commands and subcommands that Pi-CLI is capable of responding to, and manages all of their corresponding flags
Functions ¶
func ConfigDeleteCommand ¶
func ConfigDeleteCommand(*cli.Context) error
Searches for and deletes:
- the API key from the system keyring (if exists)
- the config file from the user's home directory (if exists)
func ConfigViewCommand ¶
func ConfigViewCommand(*cli.Context) error
Displays any saved configuration data to the user. If a config file is present, that can be loaded and displayed, otherwise, the user can be prompted to create one.
func InitialisePICLI ¶
func InitialisePICLI()
Validate that the config file and API key are in place. Load the required settings into memory
func RunDatabaseClientSummaryCommand ¶
func RunDatabaseClientSummaryCommand(c *cli.Context) error
Extracts a summary of data regarding the Pi-Hole's clients
func RunDatabaseTopQueriesCommand ¶
func RunDatabaseTopQueriesCommand(c *cli.Context) error
Extracts all time top query data from the database file.
func RunDisablePiHoleCommand ¶
func RunDisablePiHoleCommand(c *cli.Context) error
Disable the Pi-Hole. This command also takes an optional timeout parameter in seconds. If given and within constraints, the Pi-Hole will automatically re-enable after this time period has elapsed
func RunEnablePiHoleCommand ¶
func RunEnablePiHoleCommand(*cli.Context) error
Enable the Pi-Hole if it is not already enabled,
func RunLatestQueriesCommand ¶
func RunLatestQueriesCommand(c *cli.Context) error
func RunSummaryCommand ¶
func RunSummaryCommand(*cli.Context) error
Extracts a quick summary of the previous 24/hr of data from the Pi-Hole.
func RunTopTenBlockedCommand ¶
func RunTopTenBlockedCommand(*cli.Context) error
Extract the current top 10 blocked domains that the FTL has filtered out and not forwarded to the upstream DNS resolver
func RunTopTenForwardedCommand ¶
func RunTopTenForwardedCommand(*cli.Context) error
Extract the current top 10 permitted domains that have been forwarded to the upstream DNS resolver
func SetupCommand ¶
func SetupCommand(c *cli.Context) error
Reads in data from the user and uses it to construct a config file that Pi-CLI can use in the future.
The setup commands takes:
- The IP address of the target Pi-Hole instance
- The port exposing the Pi-Hole's web interface
- A data refresh rate in seconds
- User's Pi-Hole API key (used for authentication)
It will then ask them if they wish to store the API key in their system keyring or the config file itself.
Types ¶
This section is empty.