myip

module
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT

README

MyIP Tetrad

goreleaser   Go Reference

MyIP Tetrad is a simple to use terminal tool to determine your Internet-facing IP address and location from four remote sources. Developed on Go, it's a portable self-contained binary with no dependencies.

It is an excellent tool for quickly determining if your machine or network is connected to the Internet or to see if a VPN is activated.

Downloads

Windows, macOS, Linux, FreeBSD, Raspberry Pi

Packages
macOS Homebrew
brew install bengarrett/myip/myip
Windows Scoop
scoop bucket add myip https://github.com/bengarrett/myip.git
scoop install myip

apk - Alpine package, deb - Debian package, rpm - Redhat package

# Alpine package
apk add myip.apk
# Debian package
dpkg -i myip.deb
# Redhat package
rpm -i myip.rpm

Usage

myip -help
# MyIP Usage:
#     myip [options]:
#
#     -h, --help       show this list of options
#     -f, --first      returns the first reported IP address and its location
#     -s, --simple     simple mode only displays the IP address
#     -t, --timeout    https request timeout in milliseconds (default: 5000 [5 seconds])
#     -v, --version    version and information for this program
myip
# (1/4) 93.184.216.34, Norwell, United States
# (2/4) 93.184.216.34, Norwell, United States
# (3/4) 93.184.216.34, Norwell, United States
# (4/4) 93.184.216.34, Norwell, United States
myip -first
# (1/1) 93.184.216.34, Norwell, United States
myip -simple
# 93.184.216.34
# 93.184.216.34
# 93.184.216.34
# 93.184.216.34
myip -simple -first
# 93.184.216.34
myip -timeout=900
# (1/4) 93.184.216.34, Norwell, United States
# ip4.seeip.org: timeout
# (3/4) 93.184.216.34, Norwell, United States
# api.ipify.org: timeout

Build

Go supports dozens of architectures and operating systems letting MyIP to be built for most platforms.

# clone this repo
git clone git@github.com:bengarrett/myip.git

# access the main.go
cd myip/cmd/myip

# target and build the app for the host system
go build

# target and build for Windows 7+ 32-bit
env GOOS=windows GOARCH=386 go build

# target and build for OpenBSD
env GOOS=openbsd GOARCH=amd64 go build

# target and build for Linux on MIPS CPUs
env GOOS=linux GOARCH=mips64 go build

MyIP uses the following online APIs.

The IP region data is from GeoLite2 created by MaxMind, available from maxmind.com.

I found Steve Azzopardi's excellent import "context" post useful for understanding context library in Go.

Directories

Path Synopsis
cmd
myip
Package main determine your Internet-facing IP address and location from multiple sources.
Package main determine your Internet-facing IP address and location from multiple sources.
pkg
geolite2
Package geolite2 returns the city or country location of an IP address.
Package geolite2 returns the city or country location of an IP address.
ipify
Package myipcom returns your Internet-facing IPv4 or IPv6 address, sourced from the ipify API.
Package myipcom returns your Internet-facing IPv4 or IPv6 address, sourced from the ipify API.
ipv4
Package ipv4 requests your Internet-facing IPv4 address, sourced from four different online APIs.
Package ipv4 requests your Internet-facing IPv4 address, sourced from four different online APIs.
ipv6
Package ipv4 requests your Internet-facing IPv6 address, sourced from four different online APIs.
Package ipv4 requests your Internet-facing IPv6 address, sourced from four different online APIs.
myipcom
Package myipcom returns your Internet-facing IPv4 or IPv6 address, sourced from the MYIP.com API.
Package myipcom returns your Internet-facing IPv4 or IPv6 address, sourced from the MYIP.com API.
myipio
Package myipio returns your Internet-facing IPv4 or IPv6 address, sourced from the Workshell MyIP API.
Package myipio returns your Internet-facing IPv4 or IPv6 address, sourced from the Workshell MyIP API.
ping
Package ping contains string functions for the ipv4 and ipv6 packages.
Package ping contains string functions for the ipv4 and ipv6 packages.
seeip
Package seeip returns your Internet-facing IPv4 or IPv6 address, sourced from the SeeIP API.
Package seeip returns your Internet-facing IPv4 or IPv6 address, sourced from the SeeIP API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL