ruby_wifi_scanner 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90daf1cf8fb63b5af08330c4685e5031792f730246a1579c4ca8f153ef48a5ec
4
- data.tar.gz: 1dd0e27fe74cbe7a0e9ebb7ea7c94815ec79220569a442d350f0e7783c7f1285
3
+ metadata.gz: 5214504fd208f3dfe71db7013359528894339660a003be86e6a739c9d07f54d8
4
+ data.tar.gz: fb0ac2e0dde5ceea42d98e04af19fd7e8e1a0251fd2d4c0bdf781d80848c7d6e
5
5
  SHA512:
6
- metadata.gz: f0f46982d73459444588fb3eb40633f4b1efbac1d6bc93a92585825abe40679823546c185218dd7e43d59fd0662acdf540ad1964b707aa22feca99e2c510092a
7
- data.tar.gz: 7b3b431f2a1cd63377d7b392ea99518f31e00e01ade356609b8215fc7cbbeaeb07c14edddff93dc79168524026771848d5c9a93cbbf009288593f42f310045c4
6
+ metadata.gz: 7c6aba5413ac050e6656be419aba6f48c3981e7bfe7cb481985c41fd3d7e45138d565a5f83a3ee0aeedc66db8545fb2b13e6a29ac0541fbc726b24d920b2a030
7
+ data.tar.gz: f4bc4d5459f23f6df01c5fa455eb8ad02a3300b3749888aac5d0554cbadd812a8c9258c3f4f269a19ee0b044d8f1c4aa6b9015c4f76dfc8945f2ab4c0a820e18
data/CHANGELOG.md CHANGED
@@ -1,9 +1,28 @@
1
+ # (2019-09-17)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Fixed a bug where an unnamed SSID for OS X would cause an error ([b0e38a1](https://github.com/D3MNetworks/ruby-wifi-scanner/commit/b0e38a1))
7
+ * Linux actually works now ([bb21dfb](https://github.com/D3MNetworks/ruby-wifi-scanner/commit/bb21dfb))
8
+ * No longer omitting hidden SSIDs on OS X ([5257451](https://github.com/D3MNetworks/ruby-wifi-scanner/commit/5257451))
9
+
10
+
11
+ ### Features
12
+
13
+ * Added filtering on network type and directed scan ([d824c56](https://github.com/D3MNetworks/ruby-wifi-scanner/commit/d824c56))
14
+ * Displaying channel in print_fmt ([8607e3d](https://github.com/D3MNetworks/ruby-wifi-scanner/commit/8607e3d))
15
+ * First release ([6078fa3](https://github.com/D3MNetworks/ruby-wifi-scanner/commit/6078fa3))
16
+
17
+
18
+
1
19
  # (2019-05-27)
2
20
 
3
21
 
4
22
  ### Bug Fixes
5
23
 
6
- * Fixed a bug where an unnamed SSID for OS X would cause an error ([7a42b41](https://github.com/D3MNetworks/ruby-wifi-scanner/commit/7a42b41))
24
+ * Fixed a bug where an unnamed SSID for OS X would cause an error ([b0e38a1](https://github.com/D3MNetworks/ruby-wifi-scanner/commit/b0e38a1))
25
+ * Linux actually works now ([bb21dfb](https://github.com/D3MNetworks/ruby-wifi-scanner/commit/bb21dfb))
7
26
 
8
27
 
9
28
  ### Features
data/exe/rws CHANGED
@@ -2,6 +2,27 @@
2
2
 
3
3
  require "bundler/setup"
4
4
  require "ruby_wifi_scanner"
5
+ require 'optparse'
6
+
7
+ options = {}
8
+ OptionParser.new do |opts|
9
+ opts.banner = "Usage: example.rb [options]"
10
+
11
+ opts.on("-d", "--deep", "Run a longer deep scan") do |v|
12
+ options[:deep] = v
13
+ end
14
+
15
+ opts.on("-f", "--freq=FREQ", "Choose 2 or 5") do |v|
16
+ options[:freq] = v
17
+ end
18
+ end.parse!
19
+
5
20
 
6
21
  scanner = RubyWifiScanner::Scanner.create
7
- puts scanner.print_fmt
22
+
23
+ if options[:deep]
24
+ scanner.deep_scan
25
+ end
26
+
27
+
28
+ puts scanner.print_fmt(options)
@@ -3,13 +3,13 @@ module RubyWifiScanner
3
3
 
4
4
  protected
5
5
 
6
- def parse
7
- split = raw_scan.split "\n"
6
+ def parse scan_str
7
+ split = scan_str.split "\n"
8
8
  resp = []
9
9
  split[1..-1].each do |row|
10
10
  break if row == ""
11
- m = row.strip.match(/(?<ssid>\w+)? ?(?<rssi>[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}) (?<level>-?[\d]{1,4})/i)
12
- resp << WifiInfo.new(m[:ssid], m[:rssi], m[:level]) if m
11
+ m = row.strip.match(/(?<ssid>\w*)? ?(?<rssi>[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}) (?<level>-?[\d]{1,4})\s\s(?<channel>[0-9,+-]+)/i)
12
+ resp << WifiInfo.new(m[:ssid], m[:rssi], m[:level], m[:channel]) if m
13
13
  end
14
14
  resp.compact
15
15
  end
@@ -19,6 +19,15 @@ module RubyWifiScanner
19
19
  %x{/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport --scan}
20
20
  end
21
21
 
22
+ def directed_scan ssid
23
+ user = `whoami`.chomp
24
+ if user == 'root'
25
+ %x{/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -z --scan='#{ssid}'}
26
+ else
27
+ raise 'Deep scan must be ran as root'
28
+ end
29
+ end
30
+
22
31
  end
23
32
  end
24
33
 
@@ -2,7 +2,7 @@ module RubyWifiScanner
2
2
  class Scanner
3
3
  attr_reader :networks
4
4
 
5
- WifiInfo = Struct.new(:ssid, :rssi, :level)
5
+ WifiInfo = Struct.new(:ssid, :rssi, :level, :channel)
6
6
 
7
7
  def self.create(raw_scan=nil)
8
8
  case
@@ -24,15 +24,41 @@ module RubyWifiScanner
24
24
 
25
25
  def initialize(raw_scan = nil)
26
26
  @raw_scan = raw_scan || self.raw_scan
27
- @networks = parse.sort_by { |w| -w.level }
27
+ @networks = parse(@raw_scan).sort_by { |w| -w.level }
28
28
  end
29
29
 
30
- def print_fmt
31
- @networks.map do |n|
32
- "#{n.rssi}\t#{n.level}\t#{n.ssid}"
30
+ def deep_scan
31
+ ssids = @networks.map(&:ssid).uniq
32
+ @networks = []
33
+
34
+ ssids.each do |ssid|
35
+ @networks += parse directed_scan ssid
33
36
  end
34
37
  end
35
38
 
39
+ def print_fmt freq: nil, **kargs
40
+ @networks.select do |n|
41
+ if freq.nil?
42
+ true
43
+ else
44
+ channel, _ = n.channel.split ?,
45
+
46
+ if freq == '2'
47
+ channel.to_i <= 14
48
+ else
49
+ channel.to_i >= 32 && channel.to_i <= 73
50
+ end
51
+ end
52
+
53
+
54
+ end.map do |n|
55
+ "#{n.rssi}\t#{n.level}\t#{n.channel}\t#{n.ssid}"
56
+ end
57
+ end
58
+
59
+ def print_json
60
+ end
61
+
36
62
  protected
37
63
 
38
64
  def parse
@@ -1,3 +1,3 @@
1
1
  module RubyWifiScanner
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
data/version_bump CHANGED
@@ -1,3 +1,4 @@
1
1
  #!/bin/bash
2
2
 
3
- /usr/local/bin/conventional-changelog -p angular -i CHANGELOG.md -s
3
+ # /usr/local/bin/conventional-changelog -p angular -i CHANGELOG.md -s
4
+ conventional-changelog -p angular -i CHANGELOG.md -s
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_wifi_scanner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uri Gorelik
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-27 00:00:00.000000000 Z
11
+ date: 2019-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler