cmd

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2023 License: BSD-3-Clause-Clear Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ASNCmd *cobra.Command = &cobra.Command{
	Use:   "asn",
	Short: "Look up an ASN",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			cmd.Help()
			os.Exit(0)
		}
		s := style.NewSpinner(cmd)
		for _, arg := range args {
			if util.IsASN(arg) {
				p, _ := s.Start()
				r, err := addr.QueryASN(arg)
				p.Stop()
				if err != nil {
					cmd.PrintErr(err.Error() + "\n")
					os.Exit(1)
				}
				cmd.Println(style.ASNBox(r))
			} else {
				cmd.PrintErrf("invalid argument '%s'\n", arg)
				os.Exit(1)
			}
		}
	},
}
View Source
var IPCmd *cobra.Command = &cobra.Command{
	Use:   "ip",
	Short: "Look up an IP address or prefix",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			cmd.Help()
			os.Exit(0)
		}
		s := style.NewSpinner(cmd)
		for _, arg := range args {
			if util.IsIP(arg) {
				p, _ := s.Start()
				r, err := addr.QueryIPPrefix(arg)
				if err != nil {
					p.Stop()
					cmd.PrintErr(err.Error() + "\n")
					os.Exit(1)
				}
				ptrs, _ := addr.DNSReverseLookup(r.IP)
				p.Stop()
				cmd.Println(style.IPBox(r, ptrs))
			} else {
				cmd.PrintErrf("invalid argument '%s'\n", arg)
				os.Exit(1)
			}
		}
	},
}

Functions

func Init

func Init(version string) *cobra.Command

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