Git Product home page Git Product logo

macaddr's Introduction

NAME

  macaddr

DESCRIPTION

  cross platform mac address determination for ruby

URI

  http://github.com/ahoward/macaddr
  http://rubyforg.org/projects/codeforpeople

INSTALL

  gem install macaddr

HISTORY
  New:
    - added a Gemfile for easier testing/dev with Bundler
    - added an example .rvmrc file that will setup for ruby 1.9.3
    - updated systemu gem to ~>2.4.0 to work with ruby 1.9.3

  1.1.0:
    - added dependancy on systemu to work around butt-licky windoze io
      capture: http://redmine.ruby-lang.org/issues/show/3215

  1.0.0:
    - rdoc added
    - eric hodel kicks ass.  to find why, see
      http://drawohara.com/post/44678286/eric-hodel-kicks-ass

SYNOPSIS

  require 'macaddr'

  Mac.addr      #=> first mac addr on your system
  Mac.addr.list #=> all mac addrs on your system

macaddr's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

macaddr's Issues

can' read mac address on w2k8r2 system

When I use macaddr on a w2k8r2 system it does not find the mac address

irb(main):026:0> Mac.addr

RuntimeError: all of /sbin/ifconfig /bin/ifconfig ifconfig ipconfig /all failed
from C:/Program Files (x86)/Shoreline Communications/ShoreWare Director/Ruby/mingw32/lib/ruby/gems/1.9.1
caddr-1.4.0/lib/macaddr.rb:67:in address' from (irb):26 from C:/Program Files (x86)/Shoreline Communications/ShoreWare Director/Ruby/mingw32/lib/ruby/gems/1.9.1 ilties-3.1.1/lib/rails/commands/console.rb:45:instart'
from C:/Program Files (x86)/Shoreline Communications/ShoreWare Director/Ruby/mingw32/lib/ruby/gems/1.9.1
ilties-3.1.1/lib/rails/commands/console.rb:8:in start' from C:/Program Files (x86)/Shoreline Communications/ShoreWare Director/Ruby/mingw32/lib/ruby/gems/1.9.1 ilties-3.1.1/lib/rails/commands.rb:40:in<top (required)>'
from script/rails:6:in require' from script/rails:6:in

'
irb(main):027:0>

If i run

systemu('ipconfig /all') 

from rails console i do get output

using ruby 1.9.2.p136

License text in the sources

I'm packaging macaddr gem for Fedora, and there are some information due to license text:
https://fedoraproject.org/wiki/Packaging:LicensingGuidelines?rd=Packaging/LicensingGuidelines#License_Text

Ruby is using these license files:

https://raw.githubusercontent.com/ruby/ruby/trunk/COPYING
https://raw.githubusercontent.com/ruby/ruby/trunk/BSDL

Can you confirm the files are OK for macaddr? (for example is macaddr dual-licensed the same way as ruby?) Could you provide the full license texts in the sources?

Thanks.

Macaddr 1.6.2 Systemu Issue

I'm not sure if this is a systemu or macaddr issue. Ran into this trouble on a simple Ruby/Sinatra stack app.

rerun -p '**/*.{rb,js,css,scss,sass,erb,html,haml,ru,slim}' --dir routes,views,public,models,models/general,models/session,helpers,lib,config -- 'rackup config/config.ru'

13:18:10 [rerun] Src launched
/home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/backports-3.6.0/lib/backports/tools.rb:343:in `require': cannot load such file -- systemu (LoadError)
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/backports-3.6.0/lib/backports/tools.rb:343:in `require_with_backports'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/macaddr-1.6.2/lib/macaddr.rb:23:in `<top (required)>'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/backports-3.6.0/lib/backports/tools.rb:343:in `require'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/backports-3.6.0/lib/backports/tools.rb:343:in `require_with_backports'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/uuid-2.3.7/lib/uuid.rb:14:in `<top (required)>'
        from /home/br/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
        from /home/br/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
        from /home/br/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
        from /home/br/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
        from /home/br/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
        from /home/br/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
        from /home/br/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
        from /home/br/companies/clothesnetwork/companies/clients/external.dev.clothesnetwork.com/ascots_website/src/config/config.ru:6:in `block in <main>'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
        from /home/br/companies/clothesnetwork/companies/clients/external.dev.clothesnetwork.com/ascots_website/src/config/config.ru:in `new'
        from /home/br/companies/clothesnetwork/companies/clients/external.dev.clothesnetwork.com/ascots_website/src/config/config.ru:in `<main>'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rack-1.5.2/lib/rack/server.rb:250:in `start'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rack-1.5.2/lib/rack/server.rb:141:in `start'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rack-1.5.2/bin/rackup:4:in `<top (required)>'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/bin/rackup:23:in `load'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/bin/rackup:23:in `<main>'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/bin/ruby_executable_hooks:15:in `eval'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/bin/ruby_executable_hooks:15:in `<main>'
NoMethodError: undefined method `stop' for nil:NilClass stopping listener
/home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rerun-0.8.2/lib/rerun/watcher.rb:74:in `sleep': execution expired (Timeout::Error)
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rerun-0.8.2/lib/rerun/watcher.rb:74:in `block in adapter'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rerun-0.8.2/lib/rerun/watcher.rb:73:in `adapter'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rerun-0.8.2/lib/rerun/runner.rb:162:in `start'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rerun-0.8.2/lib/rerun/runner.rb:9:in `keep_running'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rerun-0.8.2/bin/rerun:12:in `<top (required)>'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/bin/rerun:23:in `load'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/bin/rerun:23:in `<main>'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/bin/ruby_executable_hooks:15:in `eval'
        from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/bin/ruby_executable_hooks:15:in `<main>'

Current workarouind for me is to pin the macaddr gem to 1.6.1 by adding

gem 'macaddr', '=1.6.1'

to gemfile. With 1.6.1 it works like a charm.

  • Ruby -v ruby 2.1.0p0 (2013-12-25 revision 44422) [i686-linux]
  • Macaddr gem used is 1.6.2
  • Systemu gem used is 2.5.2

NoMethodError: undefined method `pfamily' for nil:NilClass

system: Windows7
ruby-version: ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32]

irb(main):004:0> Mac.addr
NoMethodError: undefined method pfamily' for nil:N from C:/Ruby23/lib/ruby/gems/2.3.0/gems/mac from C:/Ruby23/lib/ruby/gems/2.3.0/gems/mac from C:/Ruby23/lib/ruby/gems/2.3.0/gems/mac from C:/Ruby23/lib/ruby/gems/2.3.0/gems/mac from (irb):4 from C:/Ruby23/bin/irb.cmd:19:in

'

Socket::PF_PACKET and Socket::PF_LINK undefined on Windows

I am running a windows 7 virtual machine and both Socket::PF_PACKET and Socket::PF_LINK are undefined. I can confirm this in the constants list for Socket in irb.

irb(main):001:0> require 'socket'
=> true
irb(main):002:0> Socket.const_defined? :PF_LINK
=> false
irb(main):003:0> Socket.const_defined? :PF_PACKET
=> false

Is there another constant that will work instead or is there a reason why these constants may not be defined that is explainable that can lead to a solution?

return the device => mac address mapping

using the Mac.addr.list method, it would be useful to get more info regarding each mac address. I imagine something like this:

{ 'eth0' => '00:ff:23:45:67:89', 'wlan0' => '00:ff:12:34:56:78' }

uninitialized constant Socket::PF_LINK

irb(main):001:0> require 'macaddr'
=> true
irb(main):002:0> Mac.from_getifaddrs
NameError: uninitialized constant Socket::PF_LINK
    from /home/stevecrozz/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/macaddr-1.7.0/lib/macaddr.rb:83:in `block in from_getifaddrs'
    from /home/stevecrozz/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/macaddr-1.7.0/lib/macaddr.rb:82:in `select'
    from /home/stevecrozz/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/macaddr-1.7.0/lib/macaddr.rb:82:in `from_getifaddrs'
    from (irb):2
    from /home/stevecrozz/.rbenv/versions/2.1.1/bin/irb:11:in `<main>'

Cannot update on Windows

Fetching: macaddr-1.3.0.gem (100%)
ERROR:  While executing gem ... (Errno::EINVAL)
    Invalid argument - C:/Ruby192/lib/ruby/gems/1.9.1/gems/macaddr-1.3.0/test/data/c8:bc:c8:9b:28:b1

Dependency missing

Hi, in your gemspec you missed systemu gem dependency. And now it's looks like this:

$ bundle exec rspec
/home/travis/.rvm/gems/ruby-1.9.3-p484/gems/macaddr-1.6.2/lib/macaddr.rb:23:in `require': cannot load such file -- systemu (LoadError)
    from /home/travis/.rvm/gems/ruby-1.9.3-p484/gems/macaddr-1.6.2/lib/macaddr.rb:23:in `<top (required)>'

depends on systemu

Looks like you need to declare a runtime dependency on the systemu gem.

/Users/mperham/.rvm/gems/jruby-1.5.6@banyan/gems/macaddr-1.2.0/lib/macaddr.rb:23:in `require': no such file to load -- systemu (LoadError)

Please choose a license

Having some issues with unlicensed gems here. Can you please pick a license for this project and commit a LICENSE and specify it in gemspec. Thanks.

#list doesn't behave as it should?

Forgot to thank you for this gem ;)

Mac.addr returns a string. "mac", and the singlemethod #list is not applied to it.
So I need: Mac.addr.respond_to?(:list) . Can't get any uglier.

Also, a better approach here: https://github.com/tsilen/macaddr
The singleton method #list really doesn't make sense.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.