From f5042e19a1b1ba4602582865ff6e1211f2ddb1e7 Mon Sep 17 00:00:00 2001 From: "yakumo.izuru" Date: Mon, 9 Oct 2023 18:49:48 +0000 Subject: [PATCH] Initial payload Signed-off-by: Izuru Yakumo git-svn-id: file:///srv/svn/repo/mizuchi/trunk@1 383d55e2-5bb2-3e47-99b6-5684985ccae5 --- COPYING | 14 ++++++++++++++ README.md | 10 ++++++++++ go.mod | 3 +++ main.go | 45 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 COPYING create mode 100644 README.md create mode 100644 go.mod create mode 100644 main.go diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..196d9bc --- /dev/null +++ b/COPYING @@ -0,0 +1,14 @@ +Copyright (c) 2021 Willy Goiffon +Copyright (c) 2023-present Izuru Yakumo + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..a333f75 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +![](https://raddle.me/submission_images/61e31cb98ba6f807847098560a6b29b2fbdf822069186d2cfe5fa67f747b13f2.gif) + +# mizuchi +The above animated picture says it all. + +## Build +`go build -o mizuchi` + +## Usage +Only required argument is `-i` diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..784d6a1 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module git.chaotic.ninja/yakumo.izuru/mizuchi + +go 1.20 diff --git a/main.go b/main.go new file mode 100644 index 0000000..02423c4 --- /dev/null +++ b/main.go @@ -0,0 +1,45 @@ +package main + +import ( + "encoding/json" + "flag" + "fmt" + "net/http" +) +type Status struct { + IP string `json:"ip"` + Hostname string `json:"hostname"` + City string `json:"city"` + Region string `json:"region"` + Country string `json:"country"` + Location string `json:"loc"` + Organization string `json:"org"` + Postal string `json:"postal"` + Timezone string `json:"timezone"` +} +const ( + url = "https://ipinfo.io" +) +var ( + ip_addr string +) +func init() { + flag.StringVar(&ip_addr, "i", "1.1.1.1", "IP address to check") +} +func main() { + flag.Parse() + + if len(ip_addr) == 0 { + fmt.Println("No IP address given, trying default") + } + + var status Status + query_url := url + "/" + ip_addr + resp, err := http.Get(query_url) + if err != nil { + fmt.Println(err) + } + defer resp.Body.Close() + _ = json.NewDecoder(resp.Body).Decode(&status) + fmt.Printf("IP: %v\nHostname: %v\nCity: %v\nRegion: %v\nCountry %v\nLocation: %v\nOrganization: %v\nPostal: %v\nTimezone: %v\n", status.IP, status.Hostname, status.City, status.Region, status.Country, status.Location, status.Organization, status.Postal, status.Timezone) +}