jake-scripts 1.8.4 → 1.8.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/netgeo +105 -0
- data/lib/jake/scripts/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39558a39b97276df33df585ce9d6caaffc127204
|
4
|
+
data.tar.gz: 6b3d87aebbeca49e6364bdeae097f64702c043af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20f83ea0c7fedbdb418fbd9207acd0c0b2c6632e403cf847b0bbb099874e41dd87f376954c11d1cb3866645098aa0975387014bc00c428461247f90f7a49adef
|
7
|
+
data.tar.gz: e769d1ac8cd3ebdb6d2dd194907823ac76b4e089382cf00b15b0026df398497acf0f61be94b314f906c75cc84d2a4c934091c75a83a224b21d338e959cff8594
|
data/exe/netgeo
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#
|
4
|
+
# Simple CLI app for basic network information
|
5
|
+
# with options for nice output or simple stdout
|
6
|
+
# to make all your piping dreams come true.
|
7
|
+
#
|
8
|
+
|
9
|
+
|
10
|
+
require 'slop'
|
11
|
+
require 'rest-client'
|
12
|
+
require 'json'
|
13
|
+
require 'os'
|
14
|
+
require 'socket'
|
15
|
+
|
16
|
+
|
17
|
+
def netutil
|
18
|
+
opts = Slop.parse do |o|
|
19
|
+
o.banner = 'Usage: netgeo [flag] [option]'
|
20
|
+
|
21
|
+
# Gets WAN address
|
22
|
+
o.on '-w', '--wan', 'Returns WAN IP' do
|
23
|
+
url = "https://api.ipify.org"
|
24
|
+
response = RestClient.get(url)
|
25
|
+
puts response
|
26
|
+
end
|
27
|
+
|
28
|
+
# Gets LAN(s)
|
29
|
+
o.on '-l', '--lan', 'Returns LAN(s) IP(s)' do
|
30
|
+
lans = Socket.ip_address_list.select{|intf| intf.ipv4_private?}.map { |intf| intf.ip_address }
|
31
|
+
puts lans.join(', ')
|
32
|
+
end
|
33
|
+
|
34
|
+
# Gets Router IP
|
35
|
+
o.on '-r', '--router', 'Returns Router IP' do
|
36
|
+
if OS.linux?
|
37
|
+
router = %x[ip route | grep default | head -1 | awk '{print$3}']
|
38
|
+
elsif OS.mac?
|
39
|
+
router = %x[netstat -rn | grep default | head -1 | awk '{print$2}']
|
40
|
+
else
|
41
|
+
puts "OS not supported!"
|
42
|
+
exit(1)
|
43
|
+
end
|
44
|
+
puts router
|
45
|
+
end
|
46
|
+
|
47
|
+
# Gets DNS nameserver
|
48
|
+
o.on '-d', '--dns', 'Returns DNS Nameserver' do
|
49
|
+
if OS.linux?
|
50
|
+
dns = %x[cat /etc/resolv.conf | grep nameserver | head -1 | awk '{print$2}']
|
51
|
+
elsif OS.mac?
|
52
|
+
dns = %x[scutil --dns | grep nameserver | head -1 | awk '{print$3}']
|
53
|
+
else
|
54
|
+
puts "OS not supported!"
|
55
|
+
exit(1)
|
56
|
+
end
|
57
|
+
puts dns
|
58
|
+
end
|
59
|
+
|
60
|
+
o.on '-g', '--geo', 'Returns Current IP Geodata' do
|
61
|
+
url = "http://ip-api.com/json/"
|
62
|
+
response = RestClient.get(url)
|
63
|
+
info = JSON.parse(response)
|
64
|
+
puts info['query']
|
65
|
+
puts info['city']
|
66
|
+
puts info['region']
|
67
|
+
puts info['country']
|
68
|
+
puts info['zip']
|
69
|
+
puts info['isp']
|
70
|
+
end
|
71
|
+
o.separator ''
|
72
|
+
o.separator 'Custom Geo Output:'
|
73
|
+
o.separator '[all] [ip] [city] [region] [country] [zip] [isp]'
|
74
|
+
o.separator 'Example: netgeo -s ip,city,isp 8.8.8.8'
|
75
|
+
o.array '-s', '[options] [ip address]', 'Specific Geodata'
|
76
|
+
o.on '-h', '--help', 'version 1.0.0' do
|
77
|
+
puts o
|
78
|
+
exit
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
options = opts[:s]
|
83
|
+
ip = opts.arguments || ''
|
84
|
+
|
85
|
+
url = "http://ip-api.com/json/#{ip.join}"
|
86
|
+
response = RestClient.get(url)
|
87
|
+
info = JSON.parse(response)
|
88
|
+
if options.include? 'all'
|
89
|
+
puts info['query']
|
90
|
+
puts info['city']
|
91
|
+
puts info['region']
|
92
|
+
puts info['country']
|
93
|
+
puts info['zip']
|
94
|
+
puts info['isp']
|
95
|
+
else
|
96
|
+
puts info['query'] if options.include? 'ip'
|
97
|
+
puts info['city'] if options.include? 'city'
|
98
|
+
puts info['region'] if options.include? 'region'
|
99
|
+
puts info['country'] if options.include? 'country'
|
100
|
+
puts info['zip'] if options.include? 'zip'
|
101
|
+
puts info['isp'] if options.include? 'isp'
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
netutil
|
data/lib/jake/scripts/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jake-scripts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jake Meyer
|
@@ -161,6 +161,7 @@ executables:
|
|
161
161
|
- ip_list
|
162
162
|
- ip_location
|
163
163
|
- movie
|
164
|
+
- netgeo
|
164
165
|
- stock
|
165
166
|
- weather
|
166
167
|
extensions: []
|
@@ -181,6 +182,7 @@ files:
|
|
181
182
|
- exe/ip_list
|
182
183
|
- exe/ip_location
|
183
184
|
- exe/movie
|
185
|
+
- exe/netgeo
|
184
186
|
- exe/stock
|
185
187
|
- exe/weather
|
186
188
|
- jake-scripts.gemspec
|