Giter Club home page Giter Club logo

cli's Introduction

IPinfo IPinfo CLI

This is the official CLI for the IPinfo.io IP address API, allowing you to:

  • Look up IP details in bulk or one-by-one.
  • Look up ASN details.
  • Summarize the details of up to 1000 IPs at a time.
  • Open a map of IP locations for any set of IPs.
  • Filter IPv4 & IPv6 addresses from any input.
  • Print out IP lists for any CIDR or IP range.
  • And more!

Installation

The ipinfo CLI is available for download via multiple mechanisms.

macOS

brew install ipinfo-cli

OR to install the latest amd64 version without automatic updates:

curl -Ls https://github.com/ipinfo/cli/releases/download/ipinfo-3.3.1/macos.sh | sh

Ubuntu PPA

Note: this installs our full suite of binaries and keeps them up-to-date.

echo "deb [trusted=yes] https://ppa.ipinfo.net/ /" | sudo tee  "/etc/apt/sources.list.d/ipinfo.ppa.list"
sudo apt update
sudo apt install ipinfo

Debian / Ubuntu

Note: this is a one-time installation; updates are not automatic. Use the PPA for automatic updates.

curl -Ls https://github.com/ipinfo/cli/releases/download/ipinfo-3.3.1/deb.sh | sh

OR

curl -LO https://github.com/ipinfo/cli/releases/download/ipinfo-3.3.1/ipinfo_3.3.1_linux_{arch}.deb
sudo dpkg -i ipinfo_3.3.1_linux_{arch}.deb

where {arch} can be 386, amd64, arm, or arm64.

FreeBSD

cd /usr/ports/net/ipinfo-cli && make install clean

Arch linux

git clone https://aur.archlinux.org/ipinfo-cli.git
makepkg -si

Windows Powershell

Note: run powershell as administrator before executing this command.

iwr -useb https://github.com/ipinfo/cli/releases/download/ipinfo-3.3.1/windows.ps1 | iex

Scoop

scoop install ipinfo-cli

Docker

docker run --rm -it ipinfo/ipinfo:3.3.1

To save the CLI's config, add -v "/path_to_config:/root/.config/ipinfo". For example, the following command saves the config to the ipinfo directory in the current working directory.

docker run --rm -it -v "$PWD/ipinfo:/root/.config/ipinfo" ipinfo/ipinfo:3.3.1

Using go install

Make sure that $GOPATH/bin is in your $PATH, because that's where this gets installed:

go install github.com/ipinfo/cli/ipinfo@latest

Using curl/wget

The pre-built binaries for all platforms are available on GitHub via artifacts in releases. You need to simply download, unpack and move them to your shell's binary search path.

The following OS & arch combinations are supported (if you use one not listed on here, please open an issue):

darwin_amd64
darwin_arm64
dragonfly_amd64
freebsd_386
freebsd_amd64
freebsd_arm
freebsd_arm64
linux_386
linux_amd64
linux_arm
linux_arm64
netbsd_386
netbsd_amd64
netbsd_arm
netbsd_arm64
openbsd_386
openbsd_amd64
openbsd_arm
openbsd_arm64
solaris_amd64
windows_386
windows_amd64
windows_arm
windows_arm64

After choosing a platform PLAT from above, run:

# for Windows, use ".zip" instead of ".tar.gz"
curl -LO https://github.com/ipinfo/cli/releases/download/ipinfo-3.3.1/ipinfo_3.3.1_${PLAT}.tar.gz
# OR
wget https://github.com/ipinfo/cli/releases/download/ipinfo-3.3.1/ipinfo_3.3.1_${PLAT}.tar.gz

tar -xvf ipinfo_3.3.1_${PLAT}.tar.gz
sudo mv ipinfo_3.3.1_${PLAT} /usr/local/bin/ipinfo

Using git

Installing from source requires at least the Golang version specified in go.mod. You can install the Golang toolchain from the official site.

Once the correct Golang version is installed, simply clone the repository and install the binary:

git clone https://github.com/ipinfo/cli ipinfo-cli
cd ipinfo-cli
go install ./ipinfo/
$GOPATH/bin/ipinfo

You can add $GOPATH/bin to your $PATH to access ipinfo directly from anywhere.

Alternatively, you can do the following to output the binary somewhere specific:

git clone https://github.com/ipinfo/cli ipinfo-cli
cd ipinfo-cli
go build -o <path> ./ipinfo/

Replace <path> with the required location.

Additional CLIs

The ipinfo CLI has some subcommands like grepip, grepdomain, matchip, prips, cidr2range, cidr2ip, range2cidr, range2ip, splitcidr, randip and mmdb which are also shipped as standalone binaries.

These binaries are available via all the same installation methods as mentioned above for ipinfo, except you must change only the name to the name of the subcommand, and choose the appropriate version.

Currently these subcommands are separately shipped:

CLI Version
grepip 1.2.3
grepdomain 1.0.0
matchip 1.0.0
prips 1.0.0
cidr2range 1.2.0
cidr2ip 1.0.0
range2cidr 1.3.0
range2ip 1.0.0
randip 1.1.0
splitcidr 1.0.0
mmdb 1.4.2

Quick Start

This will help you quickly get started with the ipinfo CLI.

Default Help Message

By default, invoking the CLI shows a help message:

ipinfo

ipinfo

Login

If you have a token, log in with it first. You can continue without a token, but there will be limited data output and some features (like bulk lookups) will not be available. Get your token for free at https://ipinfo.io/signup.

ipinfo init

My IP

You can quickly look up details of your own IP with myip:

ipinfo myip

ipinfo myip

Any IP

You can see the details of any IP by specifying it:

ipinfo 8.8.8.8

ipinfo myip

Piping

You can pipe IPs in and get their results in bulk (this requires a token):

cat ips.txt | ipinfo | less

cat ips.txt | ipinfo

Here's the CSV version of that:

cat ips.txt | ipinfo -c | less

cat ips.txt | ipinfo -c

Field Filter

In case you only needed a single field from a bunch of IPs:

cat ips.txt | ipinfo -f hostname

cat ips.txt | ipinfo

Bulk

The above commands implicitly run the bulk subcommand on the input. You can manually specify bulk and input IPs on the command line:

ipinfo bulk 1.1.1.0/30 8.8.8.0/30 9.9.9.0/30 | less

ipinfo bulk

Summarize

IP details can be summarized similar to what's provided by https://ipinfo.io/tools/summarize-ips:

cat lk-ips.txt | ipinfo summarize

ipinfo summarize

There are many more features available, so for full details, consult the -h or --help message for each command. For example:

ipinfo 8.8.8.8 --help

Auto-Completion

Auto-completion is supported for at least the following shells:

bash
zsh
fish

NOTE: it may work for other shells as well because the implementation is in Golang and is not necessarily shell-specific.

Installation

Installing auto-completions is as simple as running one command (works for bash, zsh and fish shells):

ipinfo completion install

If you want to customize the installation process (e.g. in case the auto-installation doesn't work as expected), you can request the actual completion script for each shell:

# get bash completion script
ipinfo completion bash

# get zsh completion script
ipinfo completion zsh

# get fish completion script
ipinfo completion fish

Shell not listed?

If your shell is not listed here, you can open an issue.

Note that as long as the COMP_LINE environment variable is provided to the binary itself, it will output completion results. So if your shell provides a way to pass COMP_LINE on auto-completion attempts to a binary, then have your shell do that with the ipinfo binary itself (or any of our binaries).

Data

The amount of data you get back per lookup depends upon how much data you have enabled on your token via the https://ipinfo.io site.

If you have an account, see our plans and addons.

All examples in this document use a token with all data enabled.

Color Output

Disabling Color Output

All our CLIs respect either the --nocolor flag or the NO_COLOR environment variable to disable color output.

Color on Windows

To enable color support for the Windows command prompt, run the following to enable Console Virtual Terminal Sequences.

REG ADD HKCU\CONSOLE /f /v VirtualTerminalLevel /t REG_DWORD /d 1

You can disable this by running the following:

REG DELETE HKCU\CONSOLE /f /v VirtualTerminalLevel

Other IPinfo Tools

There are official IPinfo client libraries available for many languages including PHP, Python, Go, Java, Ruby, and many popular frameworks such as Django, Rails and Laravel. There are also many third party libraries and integrations available for our API.

See https://ipinfo.io/developers/libraries for more details.

About IPinfo

Founded in 2013, IPinfo prides itself on being the most reliable, accurate, and in-depth source of IP address data available anywhere. We process terabytes of data to produce our custom IP geolocation, company, carrier, VPN detection, hosted domains, and IP type data sets. Our API handles over 40 billion requests a month for 100,000 businesses and developers.

image

cli's People

Contributors

0xbharath avatar abdullahdevrel avatar abu-usama avatar ahmadmujahid2k avatar anyfactor avatar awaismslm avatar charllespinon1 avatar coderholic avatar eacp avatar harisabdullah avatar k3das avatar kashaf-sajid-yaseen avatar max-ipinfo avatar maxmouchet avatar nicoandmee avatar nulldutra avatar rm-umar avatar samuel-gill avatar shamirshahzad avatar sharils avatar st-polina avatar taimoor-12 avatar talhahwahla avatar talhawahla avatar umanshahzad avatar wasi-master avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cli's Issues

Allow disabling cache

Allow toggling the cache on or off, globally or per run.

This requires saving the setting in a file somewhere. We should use boltdb to store all settings, including the token, as a key/value pair.

Refresh some README gifs

Before we release v2 with more features, we should refresh some of the README gifs because more subcommands have been added since the first gifs were created, and some subcommands got more features e.g. #22

Allow specifying CIDRs+ranges+IPs simultaneously

Right now we're not allowing specifying CIDRs+ranges+IPs at the same time, e.g. this doesn't work:

$ ipinfo bulk 1.1.1.1 8.8.8.0/24

The main reason this was hard to do is because we allow specifying ranges as <ip_start> <ip_end>, which is hard to distinguish from 2 normal IPs.

To fix this, just change IP range format to be <ip_start>-<ip_end>, and so any <ip1> <ip2> form is just 2 IPs.

Releasing v1

The package's feature set looks and feels ready for a v1 release. But we need to do the following:

  • Make the repository public.
  • Upload 1.0.0 tag/binaries (currently only beta versions released).

Right after the repo is public, we can:

  • Upload to homebrew; we need the repo's public URL to download & install the CLI when homebrew runs.

There may be things you guys have planned @coderholic @kennethkhaw like a blog or something. I'm not in the loop on that so, if that's a blocker let me know.

[feature] Command to show quota. (possible using the /me endpoint)

Sometime ago, I used the /me EP to validate the token during auth. The /me EP actually returns usefull quota information, but at this point it is not used.

I propose a command that displays the quota information.

$ ipinfo quota

Requests
Day: 0,
Month: 9,
Limit: 50000,
Remaining: 49991


"features": {
    "core": {
      "daily": 2147483647,
      "monthly": 50000
    },
    "hostio": {
      "daily": 2147483647,
      "monthly": 1000,
      "result_limit": 5
    }
  }

Or something similar. The design is pending.

no support for x86_64? just tried it on my (Apple MBA 2018) machine but didn't work

Finally had some time to play around with this @UmanShahzad :)

Ok so i decided to follow the path of a casual user and tried it out with your readme. First thing I noted was..

darwin_amd64
dragonfly_amd64
freebsd_amd64
linux_amd64
netbsd_amd64
openbsd_amd64
plan9_amd64
solaris_amd64
windows_amd64

what?? no x86_64 architecture?? hmm.. ok maybe go will just compile to my local arc. lets try just cloning the repository and doing the install. Here is all that I saw:
Screen Shot 2021-03-22 at 10 25 05 pm
I have a feeling i am doing something wrong. 🤔

Add `--unique, -u` option to `randip`

Allow generating only unique random IPs with the --unique, -u flag.

This requires making a map[u32]struct{} to store all the IPs we've seen so far and which we can access fast to check for uniqueness on the following generations.

Of course the limitation here is it'll consume a lot of memory for a huge number of desired generations, but that use case should be rare and presumably the host machine that needs to be working on that many random IPs will already have plenty of memory.

A way to get specific fields for ips

Make it easier to get a single field for IPs.

Eg. if I want to get the hostname for some IPs I need to do this currently:

$ echo -e "8.8.8.8\n1.1.1.1" | ./ipinfo bulk | jq -r '.[] | .hostname'
one.one.one.one
dns.google

It'd be easier for the user to do something like:

$ echo -e "8.8.8.8\n1.1.1.1" | ./ipinfo hostname'
8.8.8.8,one.one.one.one
1.1.1.1,dns.google

We could support a few key fields, or make a generic jq style lookup key (so hostname, asn.asn, company.type etc)

Link based authentication / account creation

CLI currently lets you paste in an existing API token. It'd be awesome if it supported signing up for a new token and creating an account from the CLI. Would need some web changes, and not needed for v1, but we should think through what this flow might look like.

ANSI-colour on Windows

I probably assume that you assume all consoles on Windows handles
ANSI-sequences. Mine does, but I've turned that off for various reasons.
And I'm now left with this junk output:

f:\MingW32\src\inet\IP-geo\IPinfo-CLI>ipinfo.exe  8.8.8.8
Core
- ←[36mIP          ←[0m ←[32m8.8.8.8←[0m
- ←[36mAnycast     ←[0m ←[32mtrue←[0m
- ←[36mHostname    ←[0m ←[32mdns.google←[0m
- ←[36mCity        ←[0m ←[32mMountain View←[0m
- ←[36mRegion      ←[0m ←[32mCalifornia←[0m
- ←[36mCountry     ←[0m ←[32mUnited States (US)←[0m
- ←[36mLocation    ←[0m ←[32m37.4056,-122.0775←[0m
- ←[36mOrganization←[0m ←[32mAS15169 Google LLC←[0m
- ←[36mPostal      ←[0m ←[32m94043←[0m
- ←[36mTimezone    ←[0m ←[32mAmerica/Los_Angeles←[0m

Could someone in 2021 please detect that such codes are effective before using them?
AFAIK, a GetConsoleMode() and test for ENABLE_VIRTUAL_TERMINAL_PROCESSING should do it.
Ref: https://docs.microsoft.com/en-us/windows/console/getconsolemode

Otherwise this is pretty cool program.

ipinfo cli crashes when manually entering bulk data

What I did.

  • I typed: ipinfo bulk
  • I typed 8.8.8.8
  • I pressed CTRL+D

What did I expect

The results

What happened?

$ ipinfo bulk
** manual input mode **
Enter all IPs, one per line:
8.8.8.8
panic: interface conversion: interface {} is *interface {}, not *ipinfo.Core

goroutine 1 [running]:
github.com/ipinfo/go/v2/ipinfo.(*Client).GetIPStrInfoBatch(0xc0000256c0, 0xc000055ce0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x3, 0xc00001a1b0, ...)
        /home/mslm/dev/ipinfo/cli/vendor/github.com/ipinfo/go/v2/ipinfo/batch.go:288 +0x285
github.com/ipinfo/go/v2/ipinfo.(*Client).GetIPInfoBatch(0xc0000256c0, 0xc000180000, 0x1, 0x2710, 0x0, 0x0, 0x0, 0x0, 0x19, 0xc00007e180, ...)
        /home/mslm/dev/ipinfo/cli/vendor/github.com/ipinfo/go/v2/ipinfo/batch.go:260 +0x17a
main.cmdBulk(0x7ffe894f0483, 0x4)
        /home/mslm/dev/ipinfo/cli/ipinfo/cmd_bulk.go:93 +0x449
main.main()
        /home/mslm/dev/ipinfo/cli/ipinfo/main.go:57 +0x398

Another IP error using GrepIP, but this one isn't super critical

goroutine 1 [running]:
encoding/binary.bigEndian.Uint32(...)
	/usr/lib/go-1.17/src/encoding/binary/binary.go:112
github.com/ipinfo/cli/lib.IPFromStdIP({0x0, 0xc00001c180, 0x827dae})
	/go/pkg/mod/github.com/ipinfo/[email protected]/lib/ip.go:24 +0x45
github.com/ipinfo/cli/lib.CmdGrepIP.func1({0x7fff8e9fa9fa, 0x13}, {0x82db00, 0xc000010550})
	/go/pkg/mod/github.com/ipinfo/[email protected]/lib/cmd_grepip.go:265 +0x766
github.com/ipinfo/cli/lib.CmdGrepIP.func2({0x7fff8e9fa9fa, 0x13})
	/go/pkg/mod/github.com/ipinfo/[email protected]/lib/cmd_grepip.go:326 +0x5f
github.com/ipinfo/cli/lib.CmdGrepIP({0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1}, {0xc000071a20, 0x1, ...}, ...)
	/go/pkg/mod/github.com/ipinfo/[email protected]/lib/cmd_grepip.go:343 +0x8a2
main.cmdGrepIP()
	/go/pkg/mod/github.com/ipinfo/[email protected]/ipinfo/cmd_grepip.go:65 +0x105
main.main()
	/go/pkg/mod/github.com/ipinfo/[email protected]/ipinfo/main.go:55 +0x1ef

Fix README to show other binaries as well

As we add more binaries, we should make it easier to discover them from the README, but without sacrificing the spotlight provided to the ipinfo binary specifically. Right now there's little to no indication that anything besides ipinfo exists, unless you look at the releases yourself or look at the code.

man pages for detailed documentation

There's actually so many features in the CLI so far for different commands that it's not reasonable to lay everything out in the README or in the inlined -h/--help output.

We should create man pages for individual commands which go into full details of what's possible and which can be accessible in these two ways:

$ man 1 ipinfo-<subcommand>
$ ipinfo <subcommand> --help

This is similar to what git does, e.g.:

$ man 1 git-init
$ git init --help

Need to also figure out how this works in a PowerShell (windows) environment.

Add token into config file

store token inside the ~/.config/ipinfo/config.json file and allow to configure it using $ ipinfo config token=<tok>

Looking up bogons return blank values but maybe better to explicitly state that?

Tried looking up a private IP and here is the result that I got:
Screen Shot 2021-03-24 at 4 57 00 pm
I guess it is expected but I think it will be better to be more explicit that it is a bogon/private IP or else users might wonder why there are IP address results with blank values? We do get a fair amount of people reaching out to support that can't tell or don't know the difference between a valid public IP vs. a bogon/private IP.

For reference, this is what our API returns -> https://ipinfo.io/192.168.1.1/json

Set useragent

Couldn't find anywhere that we're currently setting the user agent.

We should set it to something like IPinfoCli/$version. We could include additional system too, so we can track usage across OS etc. The stripe npm package does uname -a on the first initialization and adds those details to the useragent (see https://github.com/stripe/stripe-node/blob/c85a597f15a225c3b52f90224b4749ad138a9a8c/lib/stripe.js#L427) - not sure we need all those details, but we could do something similar

Cat input should default to lookup details

Eg this should return the details for 1.1.1.1, so default to bulk:

image

$ echo "8.8.8.8" | ./ipinfo bulk
{
  "8.8.8.8": {
    "ip": "8.8.8.8",
    "hostname": "dns.google",
    "anycast": true,
    "city": "Mountain View",
    "region": "California",
    "country": "US",
    "country_name": "United States",
    "loc": "37.4056,-122.0775",
    "org": "",
    "postal": "94043",
    "timezone": "America/Los_Angeles",
    "asn": {
      "asn": "AS15169",
      "name": "Google LLC",
      "domain": "google.com",
      "route": "8.8.8.0/24",
      "type": "business"
    },
    "company": {
      "name": "Google LLC",
      "domain": "google.com",
      "type": "business"
    }
  }
}

Shell auto-completion

In the initial version we won't have proper shell auto-completion.

There exist some completion frameworks in Golang but they were too buggy and/or didn't support our flag format.

Most preferable would be finding a tool that auto-generates some completion script in whatever language (doesn't have to be Golang), and we include it in the package.

Not creating ipinfo folder by default

Installing the program is not creating ipinfo folder inside .config folder by default that results a cache error

$ ipinfo 8.8.8.8
warn: cache will not be used: error opening database: open /home/umar/.config/ipinfo/cache.boltdb: no such file or directoryCore
- IP           8.8.8.8
- Anycast      true
- Hostname     dns.google
- City         Mountain View
- Region       California
- Country      United States (US)
- Location     37.4056,-122.0775
- Organization AS15169 Google LLC
- Postal       94043
- Timezone     America/Los_Angeles

Documentation enhancement

The documentation is unclear.

How to get Json output?
ipinfo -j myip doesn't work.

How to get one field?
ipinfo -f City myip doesn't work.

Improve display of summary output

Currently looks like this, which isn't very information dense, and has high contrast. We should think about how we can reduce the number of empty lines, and the number of lines per entry:

image

Include flags in auto-completion along with subcommands

Flags like ipinfo --help or ipinfo -h are not getting suggested in auto-completion; only the subcommands are.

This is a bug in the completion fork we made: fix it to ensure it recommends flags along with subcommands in such a context.

ability to resolve FQDN

is there any option to get ipinfo of a domain name?
suppose ipinfo google.com
would be very much useful with DDNS domains

Myip only returns core on macOS

bigmac:bin michael$ ipinfo myip
Core
- IP           147.**.*.*
- Anycast      false
- Hostname     *****
- City         Santa Clara
- Region       California
- Country      United States (US)
- Location    
- Organization AS396097 Sail Internet, Inc.
- Postal       9***
- Timezone     America/Los_Angeles

proxy use

I have a proxy set up on my machine, with a global http_proxy env variable so i can fetch ipinfo via curl

is there a way to make the ipinfo cli tool go through the proxy?

error

==> Upgrading 1 outdated package:
ipinfo-cli 1.1.3 -> 1.1.5
==> Upgrading ipinfo-cli 1.1.3 -> 1.1.5 
==> Downloading https://ghcr.io/v2/homebrew/core/ipinfo-cli/manifests/1.1.5
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/ipinfo-cli/blobs/sha256:215f6613824d7d14ff932d2aa835be7858fe62c046dfe2e22d3bf170f75c0f1c
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:215f6613824d7d14ff932d2aa835be7858fe62c046dfe2e22d3bf170f75c0f1c?se=2021-
######################################################################## 100.0%
==> Pouring ipinfo-cli--1.1.5.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/ipinfo-cli/1.1.5: 5 files, 7.3MB
Removing: /usr/local/Cellar/ipinfo-cli/1.1.3... (5 files, 7.3MB)
Removing: /Users/bierman/Library/Caches/Homebrew/ipinfo-cli--1.1.3... (3.8MB)
cleaning up brew...
Error: 767: unexpected token at '{
  "ipinfo-cli": "homebrew/core"
  "grepip": "homebrew/core"
}
'
Please report this issue:
  https://docs.brew.sh/Troubleshooting
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3_2/lib/ruby/2.6.0/json/common.rb:156:in `parse'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3_2/lib/ruby/2.6.0/json/common.rb:156:in `parse'
/usr/local/Homebrew/Library/Homebrew/tap.rb:605:in `tap_migrations'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:322:in `formula_name_path'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:302:in `initialize'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:508:in `new'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:508:in `loader_for'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:404:in `factory'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:452:in `from_keg'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:425:in `from_rack'
/usr/local/Homebrew/Library/Homebrew/cleanup.rb:85:in `stale_formula?'
/usr/local/Homebrew/Library/Homebrew/cleanup.rb:58:in `stale?'
/usr/local/Homebrew/Library/Homebrew/cleanup.rb:321:in `block in cleanup_cache'
/usr/local/Homebrew/Library/Homebrew/cleanup.rb:304:in `each'
/usr/local/Homebrew/Library/Homebrew/cleanup.rb:304:in `cleanup_cache'
/usr/local/Homebrew/Library/Homebrew/cleanup.rb:192:in `clean!'
/usr/local/Homebrew/Library/Homebrew/cmd/cleanup.rb:58:in `cleanup'
/usr/local/Homebrew/Library/Homebrew/brew.rb:122:in `<main>'

[bug]: runtime error: index out of range [3] with length 0

panic: runtime error: index out of range [3] with length 0

goroutine 1 [running]:
encoding/binary.bigEndian.Uint32(...)
	/usr/lib/go-1.16/src/encoding/binary/binary.go:112
github.com/ipinfo/cli/lib.IPFromStdIP(0x0, 0x0, 0x0, 0x1)
	/go/pkg/mod/github.com/ipinfo/[email protected]/lib/ip.go:24 +0x86
github.com/ipinfo/cli/lib.CmdGrepIP.func1(0x5c713d, 0x10, 0x5fc468, 0xc0000b6000)
	/go/pkg/mod/github.com/ipinfo/[email protected]/lib/cmd_grepip.go:261 +0xbf5
github.com/ipinfo/cli/lib.CmdGrepIP(0x100010000000101, 0xc000092740, 0x0, 0x1, 0x5d1340, 0x0, 0x5d0309)
	/go/pkg/mod/github.com/ipinfo/[email protected]/lib/cmd_grepip.go:324 +0x57b
main.cmd(0x7ffd24fadb1d, 0x6)
	/go/pkg/mod/github.com/ipinfo/[email protected]/grepip/main.go:128 +0x3f3
main.main()
	/go/pkg/mod/github.com/ipinfo/[email protected]/grepip/main.go:139 +0x85
Error: Process completed with exit code 2.

Improve pretty output

We improved the summary output dramatically in #7 but the pretty output for IP and ASN is still super high contrast, and could be improved:

image

(oh, actually looks like the ASN output is always raw json)

Bulk ASN

Right now we don't support looking up ASNs in bulk, but it's a useful feature to have.

In the process, we should actually support mixing together IPs & ASNs in one bulk lookup, by default.

And as a further improvement to the API, we should deprecate the bulk subcommand and allow automatically looking up things in bulk via e.g. ipinfo 1.1.1.1 8.8.8.8 if the number of inputs is more than 1.

Here's a specific checklist of things to consider:

  • support multiple inputs for the no-subcommand case by default, i.e. no need for a bulk subcommand anymore, so write a msg calling it deprecated
  • use non-bulk and support pretty format if we're still only with 1 input.
  • allow bulk ASN lookups as well, and allow this to be mixed with IP lookups.
  • if different data types are used, disallow features that won't make sense for mixed outputs, like csv format, field selection, etc.
  • support ASN range selection format such as ipinfo AS1-AS5, which gives ipinfo AS1 AS2 AS3 AS4 AS5.

Make binary available via Windows package manager(s)

Originally tracking this work in #3 but splitting this out as a more specific issue.

Allow users to download and get automatic updates for our binaries via Windows package managers such as:

  • Chocolatey
  • winget
  • scoop (recommended below)

Range / CIDR conversion utility

Another utility that it'd be great to add to the cli is the ability to convert from cidr to start,end ranges. We commonly do this internally at IPinfo, and our customers sometimes need to do it with our data exports too.

Eg. input:
1.1.1.0,1.1.1.255,other data

Output:
1.1.1.0/24,other data

And vice versa. Should probably support a different range sepator too (eg. 1.1.1.0-1.1.1.255).

Make binary available via OS distribution repositories

We can distribute the binary for each platform via Github initially so it can be installed with curl/wget/etc, but it'd be even better if developers (the most likely users here) could grab it via their OS distributor's package repo. This could give us auto-completion automatically as well without a separate install step for that.

We can start with making it available via Ubuntu's package repos first, and/or make our own PPA.

I don't use macOS so not sure of the distribution model there (I think most people use Homebrew?), but we can look into that afterwards.

Design initial API

There's a lot to be thought of here, but we can definitely start with something impactful and real use cases we've hit that a CLI could've made easier.

We should do the following, at least:

  1. Look into the greynoise CLI for some motivation: https://github.com/GreyNoise-Intelligence/pygreynoise

    What's interesting is they have a "GNQL", a domain-specific query language for their data. I don't know if we want to invent something like that, but it might be possible and provide insane flexibility without having to update the CLI at all for new use cases.

    Another thing that catches my eye is that you can check your account details from the CLI. Sounds like an easy add for us since we already have APIs for it. So you could check your usage via the CLI, for example.

    In general, I think the main motivation from this is that we want the CLI to allow some pretty tough data manipulation on IPinfo data to become much smoother, powerful and flexible.

  2. Consider a way to make use cases like https://github.com/ipinfo/web/issues/2544#issuecomment-714022130 a lot simpler.

    It seems like we'd really want to be able to do a bunch of transforms on a large set of data. I.e., get the result for all these IPs or ASNs, and then do some useful transform for all of them, expressed in a simple way, and give me result X.

  3. See other users' use cases that they've tried to achieve via bash, e.g. https://github.com/niklasberglund/ipinfo.

    This one at least looks very simple. I was thinking of a very simple feature to cover this along the lines of: ipinfo fmt <ip> <fmt-string>, with format flags like %c for city, %tz for timezone, etc.

Support output format options

should support json, csv and pretty output for most commands. If it already does it's not documented in the usage output

[Bug]: Certain IPv6 addresses are not being recognized

Examples include:

2001:2030:21:18f::27dc
2001:2030:21:1a0::27dc
2001:2030:21:1a1::27dc
2001:2030:21:1a6::27dc
2001:2030:21:1b5::27dc
2001:2030:22::3e73:fdca
2001:2030:22::3e73:fde8
2001:4998:64:800::6000
2001:4998:64:800::6001
2400:3200:1500::f9
2401:8700:ff04::28
2401:b180:2000:30::2e
2401:b180:2000:50::e
2401:b180:2000:60::13
2401:b180:2000:80::10
2401:b180:7003::1fb
2401:b180:7003::8c
2402:4e00:40:40::2:30f
2402:4e00:8020:2::53
2402:4e00:8030:1::83
2402:4e00:8030:1::84
2408:4001:f00::117
2408:4001:f00::135
2408:4001:f00::19
2408:4001:f00::1af
2408:4001:f00::1b7
2408:4001:f00::1c9
2408:4001:f00::1fa
2408:4001:f00::20d
2408:4001:f00::21
2408:4001:f00::251
2408:4001:f00::289
2408:4001:f00::29f
2408:4001:f00::2ea
2408:4001:f00::2f
2408:4001:f00::b4
2408:4001:f10::fd
2408:4002:1f10::109
2408:4004:1f8::1a1
2408:80f1:100:1010::29
2408:80f1:100:1010::d
2408:80f1:21:4013::84
2408:80f1:21:4013::88
2408:80f1:31:10::4f
2408:8711:10:10::55
2408:8752:0:2:30::1
2408:8752:0:2:30::2
2408:8752:0:2:30::3
2408:8752:0:2:30::4
2408:8752:0:30:30::1
2408:8752:0:30:30::2
2408:8752:0:e:30::1
2408:8752:0:e:30::2
2408:8752:0:e:30::4
2408:8756:3af0:10::16a
240d:c040:0:40::116
240d:c040:1:40::11d
240e:83:201:110::7
240e:83:201:4d10::3df9
240e:b1:a810:1800::6a75:d82a
240e:ff:f101:10::1a0
240e:ff:f101:10::1a3
2600:1409:7800::17dd:df12
2600:1409:7800::17dd:df39
2600:1409:9800:784::27dc
2600:1409:9800:786::27dc
2600:1409:9800:788::27dc
2600:1409:9800:78a::27dc
2600:1409:9800:78c::27dc
2600:3c02::f03c:91ff:fee2:5b0f
2604:980:7002:6::2c
2604:980:7002:6::2d
2606:4700:3033::6815:4699
2606:4700:3033::ac43:a864
2606:ae80:1451:22::820
2607:a400:2:b::4
2607:f8b0:400a:801::2008
2607:f8b0:400a:801::200e
2607:f8b0:400a:80a::2001
2607:f8b0:400a:80b::2002
2607:f8b0:400a:80b::2006
2620:1ec:46::70
2620:1ec:bdf::70
2a00:1288:80:800::7000
2a00:1288:80:800::7001
2a00:1450:4010:c08::64
2a00:1450:4010:c08::65
2a00:1450:4010:c08::8a
2a00:1450:4010:c08::8b
2a00:1450:4010:c0b::9a
2a00:1450:4010:c0b::9b
2a00:1450:4010:c0b::9c
2a00:1450:4010:c0b::9d
2a01:53c0:ff0f::2e
2a01:53c0:ff0f::34
2a0d:5300:10::2
2a0d:5300:10::3

File-based cache

We should implement a file-based cache with a relatively low TTL so that users can save on their quota for repeatedly asking for the same data, especially in batch operations.

The TTL and such details should be configurable if possible.

The cache should be ignorable by a flag on any command that uses the cache.

Some nested cache management subcommands should exist to e.g. clear the cache.

Non-informative incorrect behaviour when using bad token (at least on windows x64)

The cli says the login was successful whether the token is valid or not.

Steps to reproduce:

ipinfo login

Write any random string. The CLI does not validate it. It will say the token was configured.

ipinfo 1.1.1.1

The CLI informs the credentials and the token is incorrect, even though the login subcommand previously informed the token is correct.

grepip

Seeing Andrew's tweet just inspired an idea https://twitter.com/Andrew___Morris/status/1375516879351992320?s=03

image

I have this alias in my bash:

$ alias gip
alias gip='grep -Eo "([0-9]{1,3}\.){3}[0-9]{1,3}"'

but andrew is doing filtering of localhost and bogons. It'd be awesome to wrap this all up into a tiny standalone utility, eg:

grepip

  • default, it greps any ipv4 or ipv6 IP
  • flags to only include v4 or v6
  • flag for localhost
  • flag for bogons (would include localhost)
  • flag for just the ip, or the full matching line

Anything else?

This could be a subcommand of the ipinfo command, but it could be something we could release as a standalone tool too.

Make binary available via DockerHub

Allow users to download a docker image from DockerHub which contains the CLI, and then run a container using that image as a one-off execution.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.