cmd

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ArpScanCmd = &cobra.Command{
	Use:     "arpscan",
	Short:   "netdog: a better dig",
	Aliases: []string{"as", "arp"},

	Long: `arp scan on an interface 
	`,
	Run: func(cmd *cobra.Command, args []string) {
		log.SetFormatter(&log.JSONFormatter{DisableTimestamp: true})
		log.SetOutput(os.Stdout)

		vprint.Println(args)
		all, _ := cmd.PersistentFlags().GetBool("all")

		timeout, _ := cmd.Flags().GetFloat64("timeout")
		delay, _ := cmd.Flags().GetFloat64("delay")
		vprint.Println("Timeout: ", timeout)
		vprint.Println("Delay: ", delay)
		if all {
			arpResults, err := netdog.ScanAllInterfaces(timeout, delay)
			if err != nil {
				log.Fatal(err)
			}
			log.Println(arpResults)
			return
		}
		if len(args) == 0 {
			log.Fatal("Must provide an interface name")
		}
		interfaceName := args[0]

		arpResults, err := netdog.ScanInterface(interfaceName, timeout, delay)
		if err != nil {
			log.Fatal(err)
		}
		vprint.Print(arpResults)
		return

	},
}
View Source
var DigCmd = &cobra.Command{
	Use:   "dig",
	Short: "netdog: like dig, but fluffier",
	Long: `Does what it says on the tin. Bare-bone, no-nonsense DNS lookups 
	`,
	Run: func(cmd *cobra.Command, args []string) {
		log.SetFormatter(&log.JSONFormatter{})
		log.SetOutput(os.Stdout)

		vprint.Printf("root called")
		vprint.Println(args)
		host := args[0]
		timeout, _ := cmd.Flags().GetFloat64("timeout")
		vprint.Println(timeout)

		start := time.Now()
		addrs, err := netdog.TimeoutLookupHost(host, timeout)

		if err != nil {
			log.Fatal(err)
		}
		log.WithFields(log.Fields{
			"addrs":   addrs,
			"host":    host,
			"elapsed": time.Since(start).Seconds()},
		).Info()
	},
}
View Source
var RootCmd = &cobra.Command{
	Use:   "dug",
	Short: "Dug: a better dig",
	Long: `Does what it says on the tin. Bare-bone, no-nonsense DNS lookups 
	`,
	Run: func(cmd *cobra.Command, args []string) {
		log.SetFormatter(&log.JSONFormatter{})
		log.SetOutput(os.Stdout)

		vprint.Printf("root called")
		vprint.Print(args)
		host := args[0]
		ns, _ := cmd.PersistentFlags().GetString("namespace")
		timeout, _ := cmd.PersistentFlags().GetFloat64("timeout")
		vprint.Printf(ns)

		addrs, err := netdog.TimeoutLookupHost(host, timeout)

		if err != nil {
			log.Fatal(err)
		}
		log.WithFields(log.Fields{
			"addrs": addrs,
			"host":  host}).Info()
	},
}

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the RootCmd.

Types

This section is empty.

Jump to

Keyboard shortcuts

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