mmdbinspect icon indicating copy to clipboard operation
mmdbinspect copied to clipboard

add option for selecing an element of the JSON tree

Open pbiering opened this issue 5 years ago • 5 comments
trafficstars

I don't know how others are thinking about, but having the option to lookup a dedicated element of the JSON treen and return this in a simple output line (optionally with element=value to be used in "eval") would be a great advantage for any script related action to avoid using any sophisticated pipe methods e.g. in Bash to get the value of one element...

pbiering avatar Feb 28 '20 19:02 pbiering

+1 I was about to open the same issue. For people just trying to use this as a one-liner (which is probably >90% of people arriving here), forcing them to dive into the JSON tree with jq or other commands is somewhat cumbersome.

It would be great if the use case of "just get me the raw city, country for this IP" is covered without needing external commands.

$ mmdbinspect -db somedb.mmdb -format '{.city.names.en}, {.country.names.en}' 123.123.123.123
Transylvania, Romania

pirate avatar Feb 28 '20 20:02 pirate

Thanks for the feedback! Something like you describe sounds useful, although having something flexible enough for all use cases might be a challenge. We could probably expand the examples to cover some more cases as a step in this direction.

horgh avatar Apr 01 '20 22:04 horgh

  • [ ] Can someone please help me.? These hacks are making me suicidal (or worse). Just want a normal life. No men using me or making me do things I don't want to do. If it's crypto, I don't know how to get rid of the files but they can have it all. Just stop the mean men. I'm not a developer. I don't know how to program or code or fix this my stuff back to factory settings

motobrowning avatar Sep 01 '21 15:09 motobrowning

In the mindset of "Do One Thing And Do It Well", I think it would suffice to show some examples in the examples section of the README.md on how to extract some common queries using jq and link to the jq tutorials for advanced use cases.

ravage84 avatar Nov 16 '22 11:11 ravage84

In the mindset of "Do One Thing And Do It Well", I think it would suffice to show some examples in the examples section of the README.md on how to extract some common queries using jq and link to the jq tutorials for advanced use cases.

somehow convinced if I compare sniplets extracting the country code from the past (GeoIP v1):

$ geoiplookup -i 1.1.1.1 | awk 'match($0, /GeoIP.*: ([A-Z0-9]+),.*/, a) { print a[1]; exit; }'
AU

with present (GeoIP v2 / MMDB)

$ mmdbinspect --db /var/local/share/GeoIP/GeoLite2-City.mmdb 1.1.1.1 | jq -r '.[].Records[].Record.country.iso_code'
AU

or

$ mmdblookup -f /var/local/share/GeoIP/GeoLite2-City.mmdb --ip 1.1.1.1 country iso_code | awk 'match($0, /.*"([A-Z0-9]+)".*/, a )  { print a[1]; exit; }'
AU

Advertisment: ipv6vcalc can do this in one-shot

$ ipv6calc -q --addr2cc 1.1.1.1
AU

BTW:

  • mmdblookup is packaged in EL versions in libmaxminddb RPM
  • mmdbinspect isn't so far available in any repository: https://pkgs.org/search/?q=mmdbinspect (empty result) but only available from Github: https://github.com/maxmind/mmdbinspect/releases

pbiering avatar Nov 19 '22 13:11 pbiering