netgeo 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +28 -0
- data/exe/netgeo +18 -19
- data/lib/netgeo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2bcbbf15c62f2edc3c53616f423a0eb764ee2c0
|
4
|
+
data.tar.gz: dec319db743a3e8da000e9237e928fec3dddf47d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef277a42424e76900b6ddab8e7624545021ee8132d7fb7eedea9b6ecfc0b655228e14e1ed808906df8c7c3722d828168395dae531a211d6027e7727a70698554
|
7
|
+
data.tar.gz: 8ac2ad5fc0ca7d99068e5b3632b6e711c5f2309ec6d9b8a30d654a07f44536c5e4756734e388a29987a7f5d96cc3573b970cd6cafd98ba2edaae1330ed33e6df
|
data/.gitignore
CHANGED
@@ -10,3 +10,31 @@
|
|
10
10
|
|
11
11
|
# rspec failure tracking
|
12
12
|
.rspec_status
|
13
|
+
|
14
|
+
# General
|
15
|
+
*.DS_Store
|
16
|
+
.AppleDouble
|
17
|
+
.LSOverride
|
18
|
+
|
19
|
+
# Icon must end with two \r
|
20
|
+
Icon
|
21
|
+
|
22
|
+
|
23
|
+
# Thumbnails
|
24
|
+
._*
|
25
|
+
|
26
|
+
# Files that might appear in the root of a volume
|
27
|
+
.DocumentRevisions-V100
|
28
|
+
.fseventsd
|
29
|
+
.Spotlight-V100
|
30
|
+
.TemporaryItems
|
31
|
+
.Trashes
|
32
|
+
.VolumeIcon.icns
|
33
|
+
.com.apple.timemachine.donotpresent
|
34
|
+
|
35
|
+
# Directories potentially created on remote AFP share
|
36
|
+
.AppleDB
|
37
|
+
.AppleDesktop
|
38
|
+
Network Trash Folder
|
39
|
+
Temporary Items
|
40
|
+
.apdisk
|
data/exe/netgeo
CHANGED
@@ -6,14 +6,12 @@
|
|
6
6
|
# to make all your piping dreams come true.
|
7
7
|
#
|
8
8
|
|
9
|
-
|
10
9
|
require 'slop'
|
11
10
|
require 'rest-client'
|
12
11
|
require 'json'
|
13
12
|
require 'os'
|
14
13
|
require 'socket'
|
15
14
|
|
16
|
-
|
17
15
|
# Contains option parsing logic
|
18
16
|
def netgeo
|
19
17
|
opts = Slop.parse suppress_errors: true do |o|
|
@@ -21,25 +19,30 @@ def netgeo
|
|
21
19
|
|
22
20
|
# Gets WAN address
|
23
21
|
o.on '-w', '--wan', 'Returns WAN IP' do
|
24
|
-
|
25
|
-
|
22
|
+
begin
|
23
|
+
url = 'https://api.ipify.org'
|
24
|
+
response = RestClient.get(url)
|
25
|
+
rescue RestClient::SSLCertificateNotVerified
|
26
|
+
puts 'SSL Error'
|
27
|
+
exit(1)
|
28
|
+
end
|
26
29
|
puts response
|
27
30
|
end
|
28
31
|
|
29
32
|
# Gets LAN(s)
|
30
33
|
o.on '-l', '--lan', 'Returns LAN IP(s)' do
|
31
|
-
lans = Socket.ip_address_list.select
|
34
|
+
lans = Socket.ip_address_list.select(&:ipv4_private?).map(&:ip_address)
|
32
35
|
puts lans.join(', ')
|
33
36
|
end
|
34
37
|
|
35
38
|
# Gets Router IP
|
36
39
|
o.on '-r', '--router', 'Returns Router IP' do
|
37
40
|
if OS.linux?
|
38
|
-
router =
|
41
|
+
router = `ip route | grep default | head -1 | awk '{print$3}'`
|
39
42
|
elsif OS.mac?
|
40
|
-
router =
|
43
|
+
router = `netstat -rn | grep default | head -1 | awk '{print$2}'`
|
41
44
|
else
|
42
|
-
puts
|
45
|
+
puts 'OS not supported!'
|
43
46
|
exit(1)
|
44
47
|
end
|
45
48
|
puts router
|
@@ -48,11 +51,11 @@ def netgeo
|
|
48
51
|
# Gets DNS nameserver
|
49
52
|
o.on '-d', '--dns', 'Returns DNS Nameserver' do
|
50
53
|
if OS.linux?
|
51
|
-
dns =
|
54
|
+
dns = `cat /etc/resolv.conf | grep nameserver | head -1 | awk '{print$2}'`
|
52
55
|
elsif OS.mac?
|
53
|
-
dns =
|
56
|
+
dns = `scutil --dns | grep nameserver | head -1 | awk '{print$3}'`
|
54
57
|
else
|
55
|
-
puts
|
58
|
+
puts 'OS not supported!'
|
56
59
|
exit(1)
|
57
60
|
end
|
58
61
|
puts dns
|
@@ -60,9 +63,8 @@ def netgeo
|
|
60
63
|
|
61
64
|
o.string '-m', '--mac [interface]', 'Returns MAC address for interface. Ex. eth0'
|
62
65
|
|
63
|
-
|
64
66
|
o.on '-g', '--geo', 'Returns Current IP Geodata' do
|
65
|
-
url =
|
67
|
+
url = 'http://ip-api.com/json/'
|
66
68
|
response = RestClient.get(url)
|
67
69
|
info = JSON.parse(response)
|
68
70
|
puts info['query']
|
@@ -77,13 +79,12 @@ def netgeo
|
|
77
79
|
o.separator '[all] [ip] [city] [region] [country] [zip] [isp]'
|
78
80
|
o.separator 'Example: netgeo -s ip,city,isp 8.8.8.8'
|
79
81
|
o.array '-s', '[options] [ip address]', 'Specific Geodata'
|
80
|
-
o.on '-h', '--help', 'version 1.
|
82
|
+
o.on '-h', '--help', 'version 0.1.2' do
|
81
83
|
puts o
|
82
84
|
exit
|
83
85
|
end
|
84
86
|
end
|
85
87
|
|
86
|
-
|
87
88
|
# Logic for specific geodata
|
88
89
|
options = opts[:s]
|
89
90
|
ip = opts.arguments || ''
|
@@ -107,12 +108,10 @@ def netgeo
|
|
107
108
|
puts info['isp'] if options.include? 'isp'
|
108
109
|
end
|
109
110
|
|
110
|
-
|
111
111
|
# Logic for specific MAC address
|
112
112
|
options = opts[:m]
|
113
|
-
|
114
|
-
puts
|
115
|
-
end
|
113
|
+
return if options.nil?
|
114
|
+
puts `ifconfig #{options} | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'`
|
116
115
|
end
|
117
116
|
|
118
117
|
netgeo
|
data/lib/netgeo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: netgeo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jake Meyer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|