Add some changes
This commit is contained in:
+12
-21
@@ -56,8 +56,8 @@ func main() {
|
|||||||
Usage: "Get IP address information.",
|
Usage: "Get IP address information.",
|
||||||
Commands: []*cli.Command{
|
Commands: []*cli.Command{
|
||||||
{
|
{
|
||||||
Name: "local",
|
Name: "address",
|
||||||
Aliases: []string{"l"},
|
Aliases: []string{"a"},
|
||||||
Usage: "get local IP address information",
|
Usage: "get local IP address information",
|
||||||
Action: func(cCtx *cli.Context) error {
|
Action: func(cCtx *cli.Context) error {
|
||||||
ifaces, err := net.Interfaces()
|
ifaces, err := net.Interfaces()
|
||||||
@@ -66,24 +66,17 @@ func main() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(color.MagentaString("REMOTE ADDRESSES:"))
|
resp, httpErr := http.Get("https://api.ipify.org")
|
||||||
resp, httpErr := http.Get("https://ifconfig.me/ip")
|
if httpErr == nil {
|
||||||
|
defer resp.Body.Close()
|
||||||
if httpErr != nil {
|
body, ioErr := io.ReadAll(resp.Body)
|
||||||
fmt.Println(httpErr)
|
if ioErr == nil {
|
||||||
|
fmt.Println(color.MagentaString("PUBLIC ADDRESS:") + " " + color.WhiteString(string(body)))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
body, ioErr := io.ReadAll(resp.Body)
|
|
||||||
|
|
||||||
if ioErr != nil {
|
|
||||||
fmt.Println(ioErr)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println(" " + color.GreenString("WAN: ") + string(body))
|
|
||||||
|
|
||||||
fmt.Println(color.MagentaString("LOCAL INTERFACES:"))
|
fmt.Println(color.MagentaString("LOCAL INTERFACES:"))
|
||||||
for _, i := range ifaces {
|
for _, i := range ifaces {
|
||||||
|
|
||||||
if i.Name[:2] == "lo" {
|
if i.Name[:2] == "lo" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -91,8 +84,7 @@ func main() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
var v4Addr string
|
var v4Addr, v6Addr string
|
||||||
var v6Addr string
|
|
||||||
|
|
||||||
addrs, err := i.Addrs()
|
addrs, err := i.Addrs()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -117,13 +109,12 @@ func main() {
|
|||||||
}
|
}
|
||||||
fmt.Printf(color.GreenString(" "+i.Name+": ")+" %s (%s)\n", v4Addr, v6Addr)
|
fmt.Printf(color.GreenString(" "+i.Name+": ")+" %s (%s)\n", v4Addr, v6Addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "address",
|
Name: "lookup",
|
||||||
Aliases: []string{"a"},
|
Aliases: []string{"l"},
|
||||||
Usage: "lookup an IP address",
|
Usage: "lookup an IP address",
|
||||||
Action: func(cCtx *cli.Context) error {
|
Action: func(cCtx *cli.Context) error {
|
||||||
if cCtx.Args().First() == "" {
|
if cCtx.Args().First() == "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user