Nagy Károly Gábriel
6 years ago
2 changed files with 107 additions and 32 deletions
@ -0,0 +1,45 @@
|
||||
package main |
||||
|
||||
import ( |
||||
"flag" |
||||
"fmt" |
||||
"git.jpi.io/karasz/gip/giplib" |
||||
"os" |
||||
) |
||||
|
||||
var ( |
||||
//Version contains the git hashtag injected by make
|
||||
Version = "N/A" |
||||
//BuildTime contains the build timestamp injected by make
|
||||
BuildTime = "N/A" |
||||
) |
||||
|
||||
func main() { |
||||
var all bool |
||||
ptr4 := flag.Bool("4", false, "return only IPv4") |
||||
ptr6 := flag.Bool("6", false, "return only IPv6") |
||||
version := flag.Bool("v", false, "return version") |
||||
|
||||
flag.Parse() |
||||
|
||||
if *version { |
||||
fmt.Println(Version, " built on ", BuildTime) |
||||
os.Exit(0) |
||||
} |
||||
|
||||
if *ptr4 == *ptr6 { |
||||
all = true |
||||
} |
||||
if all { |
||||
fmt.Println(giplib.GetIPv4()) |
||||
fmt.Println(giplib.GetIPv6()) |
||||
os.Exit(0) |
||||
} |
||||
if *ptr4 { |
||||
fmt.Println(giplib.GetIPv4()) |
||||
} |
||||
if *ptr6 { |
||||
fmt.Println(giplib.GetIPv6()) |
||||
|
||||
} |
||||
} |
Loading…
Reference in new issue