2020-07-17 01:05:25 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/zu1k/nali/internal/app"
|
2020-07-17 04:12:04 +00:00
|
|
|
"github.com/zu1k/nali/internal/ipdb"
|
2020-07-17 01:05:25 +00:00
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var parseCmd = &cobra.Command{
|
|
|
|
Use: "parse",
|
|
|
|
Short: "Query IP information",
|
2020-07-18 02:53:44 +00:00
|
|
|
Long: `Query IP information.
|
|
|
|
|
|
|
|
#1 Query a simple IP address
|
|
|
|
|
|
|
|
$ nali 1.2.3.4
|
|
|
|
|
|
|
|
or use pipe
|
|
|
|
|
|
|
|
$ echo IP 6.6.6.6 | nali
|
|
|
|
|
|
|
|
#2 Query multiple IP addresses
|
|
|
|
|
|
|
|
$ nali 1.2.3.4 4.3.2.1 123.23.3.0
|
|
|
|
|
|
|
|
#3 Interactive query
|
|
|
|
|
|
|
|
$ nali
|
|
|
|
123.23.23.23
|
|
|
|
123.23.23.23 [越南 越南邮电集团公司]
|
|
|
|
quit
|
|
|
|
|
|
|
|
#4 Use with dig
|
|
|
|
|
|
|
|
$ dig nali.lgf.im +short | nali
|
|
|
|
|
|
|
|
#5 Use with nslookup
|
|
|
|
|
|
|
|
$ nslookup nali.lgf.im 8.8.8.8 | nali
|
|
|
|
|
|
|
|
#6 Use with any other program
|
|
|
|
|
|
|
|
bash abc.sh | nali
|
|
|
|
|
|
|
|
#7 IPV6 support
|
|
|
|
|
|
|
|
$ nslookup google.com | nali
|
|
|
|
`,
|
|
|
|
Args: cobra.MinimumNArgs(1),
|
2020-07-17 01:05:25 +00:00
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
2020-07-17 04:12:04 +00:00
|
|
|
app.InitIPDB(ipdb.GetIPDBType())
|
2020-07-17 01:05:25 +00:00
|
|
|
app.ParseIPs(args)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
rootCmd.AddCommand(parseCmd)
|
|
|
|
}
|