netgeo 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +28 -0
  3. data/exe/netgeo +18 -19
  4. data/lib/netgeo/version.rb +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 570b73ac609c08dd02afcacbf2583d56177cfd63
4
- data.tar.gz: ff37a1367636d75a1b440e2401cda7f24ae74cfa
3
+ metadata.gz: d2bcbbf15c62f2edc3c53616f423a0eb764ee2c0
4
+ data.tar.gz: dec319db743a3e8da000e9237e928fec3dddf47d
5
5
  SHA512:
6
- metadata.gz: adee6a17384f533d26eda8dce4177188e8d15c190e1d05b2e961306ed7eb434a5d57cd4f4c9c5465f9d76bfe74b6939b67d35d4de66490b720da69f7eda12f9e
7
- data.tar.gz: 7700714e87c33551465963301b50b246900b04eb4187ea04a3a625491af1e3effb0ee5945a75b2d032101b1bf087005a8b1c6570a218a49a8111d22cc85dc2c3
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
- url = "https://api.ipify.org"
25
- response = RestClient.get(url)
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{|intf| intf.ipv4_private?}.map { |intf| intf.ip_address }
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 = %x[ip route | grep default | head -1 | awk '{print$3}']
41
+ router = `ip route | grep default | head -1 | awk '{print$3}'`
39
42
  elsif OS.mac?
40
- router = %x[netstat -rn | grep default | head -1 | awk '{print$2}']
43
+ router = `netstat -rn | grep default | head -1 | awk '{print$2}'`
41
44
  else
42
- puts "OS not supported!"
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 = %x[cat /etc/resolv.conf | grep nameserver | head -1 | awk '{print$2}']
54
+ dns = `cat /etc/resolv.conf | grep nameserver | head -1 | awk '{print$2}'`
52
55
  elsif OS.mac?
53
- dns = %x[scutil --dns | grep nameserver | head -1 | awk '{print$3}']
56
+ dns = `scutil --dns | grep nameserver | head -1 | awk '{print$3}'`
54
57
  else
55
- puts "OS not supported!"
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 = "http://ip-api.com/json/"
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.0.2' do
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
- unless options == nil
114
- puts %x[ifconfig #{options} | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}']
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
@@ -1,3 +1,3 @@
1
1
  module Netgeo
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
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.0
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-26 00:00:00.000000000 Z
11
+ date: 2017-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler