mac_rotator 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,18 @@
1
+ .ruby-version
2
+ *.gem
3
+ *.rbc
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mac-rotator.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Bradley J. Spaulding
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # MACRotator
2
+
3
+ A utility to rotate your mac address, and reset it when you're done. Useful for those annoying timed sessions at coffee shops and airports.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'mac_rotator'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install mac_rotator
18
+
19
+ ## Usage
20
+
21
+ mac_rotator git:(master) ✗ be bin/mac_rotator
22
+ Current MAC Address: 82:f6:f9:0c:b4:b3
23
+ Press any key to rotate the address.
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,7 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'mac_rotator'
4
+ require 'mac_rotator/cli'
5
+
6
+ MACRotator::CLI.run
7
+
@@ -0,0 +1,8 @@
1
+ require "mac_rotator/version"
2
+ require "mac_rotator/mac_generator"
3
+ require "mac_rotator/mac_manager"
4
+ require "mac_rotator/rotator"
5
+
6
+ module MACRotator
7
+ # Your code goes here...
8
+ end
@@ -0,0 +1,23 @@
1
+ class MACRotator::CLI
2
+ def self.run
3
+ new.run
4
+ end
5
+
6
+ def run
7
+ while true
8
+ puts "Current MAC Address: #{rotator.current_address}\nPress any key to rotate the address. Use CTRL-C when you're done, and I'll reset it to your original mac address."
9
+ gets
10
+ rotator.rotate
11
+ end
12
+ rescue Exception
13
+ rotator.reset
14
+ raise
15
+ end
16
+
17
+ private
18
+
19
+ def rotator
20
+ @rotator ||= MACRotator::Rotator.new
21
+ end
22
+ end
23
+
@@ -0,0 +1,9 @@
1
+ class MACRotator::MACGenerator
2
+ def self.generate
3
+ new.generate
4
+ end
5
+
6
+ def generate
7
+ %x[openssl rand -hex 6].strip.scan(/(..)/).join(":")
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ class MACRotator::MACManager
2
+ def set(new_mac)
3
+ %x[sudo ifconfig en0 lladdr #{new_mac}]
4
+ unless get == new_mac
5
+ raise MACSetFailed.new("Tried to change MAC from #{get} to #{new_mac}, but it didn't change.")
6
+ end
7
+ end
8
+
9
+ def get
10
+ %x[sudo ifconfig en0 lladdr].split("\n").last.strip.split(' ').last
11
+ end
12
+
13
+ class MACSetFailed < StandardError; end
14
+ end
@@ -0,0 +1,33 @@
1
+ class MACRotator::Rotator
2
+ def initialize
3
+ macs << manager.get
4
+ @original_mac = macs.last
5
+ end
6
+
7
+ def rotate
8
+ macs << generator.generate
9
+ manager.set macs.last
10
+ end
11
+
12
+ def reset
13
+ manager.set @original_mac
14
+ end
15
+
16
+ def current_address
17
+ macs.last
18
+ end
19
+
20
+ private
21
+
22
+ def generator
23
+ @mac_generator ||= MACRotator::MACGenerator.new
24
+ end
25
+
26
+ def manager
27
+ @mac_manager ||= MACRotator::MACManager.new
28
+ end
29
+
30
+ def macs
31
+ @macs ||= []
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module MACRotator
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mac_rotator/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "mac_rotator"
8
+ gem.version = MACRotator::VERSION
9
+ gem.authors = ["Bradley J. Spaulding"]
10
+ gem.email = ["bspaulding@dataxu.com"]
11
+ gem.description = %q{A utility to rotate your mac address.}
12
+ gem.summary = %q{A utility to rotate your mac address.}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ ['rake', 'rspec'].each do |gem_name|
21
+ gem.add_development_dependency gem_name
22
+ end
23
+
24
+ gem.add_dependency 'thor'
25
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mac_rotator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Bradley J. Spaulding
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: thor
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: A utility to rotate your mac address.
63
+ email:
64
+ - bspaulding@dataxu.com
65
+ executables:
66
+ - mac_rotator
67
+ extensions: []
68
+ extra_rdoc_files: []
69
+ files:
70
+ - .gitignore
71
+ - Gemfile
72
+ - LICENSE.txt
73
+ - README.md
74
+ - Rakefile
75
+ - bin/mac_rotator
76
+ - lib/mac_rotator.rb
77
+ - lib/mac_rotator/cli.rb
78
+ - lib/mac_rotator/mac_generator.rb
79
+ - lib/mac_rotator/mac_manager.rb
80
+ - lib/mac_rotator/rotator.rb
81
+ - lib/mac_rotator/version.rb
82
+ - mac_rotator.gemspec
83
+ homepage: ''
84
+ licenses: []
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ segments:
96
+ - 0
97
+ hash: 3715208519833072933
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ segments:
105
+ - 0
106
+ hash: 3715208519833072933
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 1.8.23
110
+ signing_key:
111
+ specification_version: 3
112
+ summary: A utility to rotate your mac address.
113
+ test_files: []