Closed stevecrozz- closed 10 years ago
recent change by @drbrain - if you or he can submit a pr that'd be great!
@stevecrozz-rs what values do you have for Socket.constants
Also:
ruby -v -rsocket -rpp -e 'pp Socket.getifaddrs'
you probably know this @drbrain but
a:~ $ ruby -v -rsocket -rpp -e 'pp Socket.getifaddrs'
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin12.5.0]
-e:1:in `<main>': undefined method `getifaddrs' for Socket:Class (NoMethodError)
@ahoward yep, due to https://github.com/ahoward/macaddr/blob/master/lib/macaddr.rb#L79 ruby 2.0 and earlier users will fall back to ifconfig
, etc. detection of the MAC address. Socket.getifaddrs
exists on 2.1+
yeah that makes sense totally. just fyi. and trying to prompt @stevecrozz-rs into action so we can (maybe) fix a broken gem?
rirb(main):001:0> require 'socket'
=> true
irb(main):002:0> Socket.constants
=> [:Option, :AncillaryData, :Ifaddr, :Constants, :SOCK_STREAM, :SOCK_DGRAM, :SOCK_RAW, :SOCK_RDM, :SOCK_SEQPACKET, :SOCK_PACKET, :AF_UNSPEC, :PF_UNSPEC, :AF_INET, :PF_INET, :AF_INET6, :PF_INET6, :AF_UNIX, :PF_UNIX, :AF_AX25, :PF_AX25, :AF_IPX, :PF_IPX, :AF_APPLETALK, :PF_APPLETALK, :AF_LOCAL, :PF_LOCAL, :AF_SNA, :PF_SNA, :AF_ROUTE, :PF_ROUTE, :AF_ISDN, :PF_ISDN, :AF_MAX, :PF_MAX, :AF_PACKET, :PF_PACKET, :PF_KEY, :MSG_OOB, :MSG_PEEK, :MSG_DONTROUTE, :MSG_EOR, :MSG_TRUNC, :MSG_CTRUNC, :MSG_WAITALL, :MSG_DONTWAIT, :MSG_PROXY, :MSG_FIN, :MSG_SYN, :MSG_CONFIRM, :MSG_RST, :MSG_ERRQUEUE, :MSG_NOSIGNAL, :MSG_MORE, :MSG_FASTOPEN, :SOL_SOCKET, :SOL_IP, :SOL_TCP, :SOL_UDP, :IPPROTO_IP, :IPPROTO_ICMP, :IPPROTO_IGMP, :IPPROTO_TCP, :IPPROTO_EGP, :IPPROTO_PUP, :IPPROTO_UDP, :IPPROTO_IDP, :IPPROTO_TP, :IPPROTO_AH, :IPPROTO_DSTOPTS, :IPPROTO_ESP, :IPPROTO_FRAGMENT, :IPPROTO_HOPOPTS, :IPPROTO_ICMPV6, :IPPROTO_IPV6, :IPPROTO_NONE, :IPPROTO_ROUTING, :IPPROTO_RAW, :IPPORT_RESERVED, :IPPORT_USERRESERVED, :INADDR_ANY, :INADDR_BROADCAST, :INADDR_LOOPBACK, :INADDR_UNSPEC_GROUP, :INADDR_ALLHOSTS_GROUP, :INADDR_MAX_LOCAL_GROUP, :INADDR_NONE, :IP_OPTIONS, :IP_HDRINCL, :IP_TOS, :IP_TTL, :IP_RECVOPTS, :IP_RECVRETOPTS, :IP_RETOPTS, :IP_MINTTL, :IP_RECVTTL, :IP_MULTICAST_IF, :IP_MULTICAST_TTL, :IP_MULTICAST_LOOP, :IP_ADD_MEMBERSHIP, :IP_DROP_MEMBERSHIP, :IP_DEFAULT_MULTICAST_TTL, :IP_DEFAULT_MULTICAST_LOOP, :IP_MAX_MEMBERSHIPS, :IP_ROUTER_ALERT, :IP_PKTINFO, :IP_PKTOPTIONS, :IP_MTU_DISCOVER, :IP_RECVERR, :IP_RECVTOS, :IP_MTU, :IP_FREEBIND, :IP_IPSEC_POLICY, :IP_XFRM_POLICY, :IP_PASSSEC, :IP_PMTUDISC_DONT, :IP_PMTUDISC_WANT, :IP_PMTUDISC_DO, :IP_UNBLOCK_SOURCE, :IP_BLOCK_SOURCE, :IP_ADD_SOURCE_MEMBERSHIP, :IP_DROP_SOURCE_MEMBERSHIP, :IP_MSFILTER, :MCAST_JOIN_GROUP, :MCAST_BLOCK_SOURCE, :MCAST_UNBLOCK_SOURCE, :MCAST_LEAVE_GROUP, :MCAST_JOIN_SOURCE_GROUP, :MCAST_LEAVE_SOURCE_GROUP, :MCAST_MSFILTER, :MCAST_EXCLUDE, :MCAST_INCLUDE, :SO_DEBUG, :SO_REUSEADDR, :SO_REUSEPORT, :SO_TYPE, :SO_ERROR, :SO_DONTROUTE, :SO_BROADCAST, :SO_SNDBUF, :SO_RCVBUF, :SO_KEEPALIVE, :SO_OOBINLINE, :SO_NO_CHECK, :SO_PRIORITY, :SO_LINGER, :SO_PASSCRED, :SO_PEERCRED, :SO_RCVLOWAT, :SO_SNDLOWAT, :SO_RCVTIMEO, :SO_SNDTIMEO, :SO_ACCEPTCONN, :SO_SECURITY_AUTHENTICATION, :SO_SECURITY_ENCRYPTION_TRANSPORT, :SO_SECURITY_ENCRYPTION_NETWORK, :SO_BINDTODEVICE, :SO_ATTACH_FILTER, :SO_DETACH_FILTER, :SO_PEERNAME, :SO_TIMESTAMP, :SO_TIMESTAMPNS, :TCP_NODELAY, :TCP_MAXSEG, :TCP_CORK, :TCP_DEFER_ACCEPT, :TCP_INFO, :TCP_KEEPCNT, :TCP_KEEPIDLE, :TCP_KEEPINTVL, :TCP_LINGER2, :TCP_MD5SIG, :TCP_QUICKACK, :TCP_SYNCNT, :TCP_WINDOW_CLAMP, :TCP_FASTOPEN, :UDP_CORK, :EAI_ADDRFAMILY, :EAI_AGAIN, :EAI_BADFLAGS, :EAI_FAIL, :EAI_FAMILY, :EAI_MEMORY, :EAI_NODATA, :EAI_NONAME, :EAI_OVERFLOW, :EAI_SERVICE, :EAI_SOCKTYPE, :EAI_SYSTEM, :AI_PASSIVE, :AI_CANONNAME, :AI_NUMERICHOST, :AI_NUMERICSERV, :AI_ALL, :AI_ADDRCONFIG, :AI_V4MAPPED, :NI_MAXHOST, :NI_MAXSERV, :NI_NOFQDN, :NI_NUMERICHOST, :NI_NAMEREQD, :NI_NUMERICSERV, :NI_DGRAM, :SHUT_RD, :SHUT_WR, :SHUT_RDWR, :IPV6_JOIN_GROUP, :IPV6_LEAVE_GROUP, :IPV6_MULTICAST_HOPS, :IPV6_MULTICAST_IF, :IPV6_MULTICAST_LOOP, :IPV6_UNICAST_HOPS, :IPV6_V6ONLY, :IPV6_CHECKSUM, :IPV6_DSTOPTS, :IPV6_HOPLIMIT, :IPV6_HOPOPTS, :IPV6_NEXTHOP, :IPV6_PKTINFO, :IPV6_RECVDSTOPTS, :IPV6_RECVHOPLIMIT, :IPV6_RECVHOPOPTS, :IPV6_RECVPKTINFO, :IPV6_RECVRTHDR, :IPV6_RECVTCLASS, :IPV6_RTHDR, :IPV6_RTHDRDSTOPTS, :IPV6_RTHDR_TYPE_0, :IPV6_TCLASS, :INET_ADDRSTRLEN, :INET6_ADDRSTRLEN, :IFNAMSIZ, :IF_NAMESIZE, :SOMAXCONN, :SCM_RIGHTS, :SCM_TIMESTAMP, :SCM_TIMESTAMPNS, :SCM_CREDENTIALS, :IFF_ALLMULTI, :IFF_AUTOMEDIA, :IFF_BROADCAST, :IFF_DEBUG, :IFF_DYNAMIC, :IFF_LOOPBACK, :IFF_MASTER, :IFF_MULTICAST, :IFF_NOARP, :IFF_NOTRAILERS, :IFF_POINTOPOINT, :IFF_PORTSEL, :IFF_PROMISC, :IFF_RUNNING, :IFF_SLAVE, :IFF_UP, :UDPSource, :WaitReadable, :WaitWritable, :EAGAINWaitReadable, :EAGAINWaitWritable, :EWOULDBLOCKWaitReadable, :EWOULDBLOCKWaitWritable, :EINPROGRESSWaitReadable, :EINPROGRESSWaitWritable, :SEEK_SET, :SEEK_CUR, :SEEK_END, :SEEK_DATA, :SEEK_HOLE, :RDONLY, :WRONLY, :RDWR, :APPEND, :CREAT, :EXCL, :NONBLOCK, :TRUNC, :NOCTTY, :BINARY, :SYNC, :DSYNC, :RSYNC, :NOFOLLOW, :NOATIME, :DIRECT, :LOCK_SH, :LOCK_EX, :LOCK_UN, :LOCK_NB, :NULL, :FNM_NOESCAPE, :FNM_PATHNAME, :FNM_DOTMATCH, :FNM_CASEFOLD, :FNM_EXTGLOB, :FNM_SYSCASE]
and
$ ruby -v -rsocket -rpp -e 'pp Socket.getifaddrs'
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]
[#<Socket::Ifaddr lo UP,LOOPBACK,RUNNING,0x10000 PACKET[protocol=0 lo hatype=772 HOST hwaddr=00:00:00:00:00:00]>,
#15 <Socket::Ifaddr eth0 UP,BROADCAST,MULTICAST PACKET[protocol=0 eth0 hatype=1 HOST hwaddr=f0:de:f1:fd:0d:28] broadcast=PACKET[protocol=0 eth0 hatype=1 HOST hwaddr=ff:ff:ff:ff:ff:ff]>,
#<Socket::Ifaddr wlan0 UP,BROADCAST,RUNNING,MULTICAST,0x10000 PACKET[protocol=0 wlan0 hatype=1 HOST hwaddr=8c:70:5a:bf:0d:04] broadcast=PACKET[protocol=0 wlan0 hatype=1 HOST hwaddr=ff:ff:ff:ff:ff:ff]>,
#<Socket::Ifaddr docker0 UP,BROADCAST,RUNNING,MULTICAST,0x10000 PACKET[protocol=0 docker0 hatype=1 HOST hwaddr=32:ae:4c:06:1f:09] broadcast=PACKET[protocol=0 docker0 hatype=1 HOST hwaddr=ff:ff:ff:ff:ff:ff]>,
#<Socket::Ifaddr veth1486 UP,BROADCAST,RUNNING,0x10000 PACKET[protocol=0 veth1486 hatype=1 HOST hwaddr=32:ae:4c:06:1f:09] broadcast=PACKET[protocol=0 veth1486 hatype=1 HOST hwaddr=ff:ff:ff:ff:ff:ff]>,
#<Socket::Ifaddr veth3c96 UP,BROADCAST,RUNNING,0x10000 PACKET[protocol=0 veth3c96 hatype=1 HOST hwaddr=42:23:fc:68:98:9b] broadcast=PACKET[protocol=0 veth3c96 hatype=1 HOST hwaddr=ff:ff:ff:ff:ff:ff]>,
#<Socket::Ifaddr lo UP,LOOPBACK,RUNNING,0x10000 127.0.0.1 netmask=255.0.0.0>,
#<Socket::Ifaddr wlan0 UP,BROADCAST,RUNNING,MULTICAST,0x10000 10.10.12.53 netmask=255.255.254.0 broadcast=10.10.13.255>,
#<Socket::Ifaddr docker0 UP,BROADCAST,RUNNING,MULTICAST,0x10000 172.17.42.1 netmask=255.255.0.0 broadcast=172.17.42.1>]
@stevecrozz can you try the above commit ↑ I forgot that Linux and BSD use different interface types for the raw (ethernet, wifi, etc.) interface
Nope, there's a bug now that I'm trying it. Proper fix coming up…
Ok ↑
7e1cdc2ece3edef8f9305d35d967c6c21a7fc097 looks good to me. Thanks!
irb(main):001:0> require './lib/macaddr'
=> true
irb(main):002:0> Mac.from_getifaddrs
=> "f0:de:f1:fd:0d:28"
Yay!
@ahoward its ready for release
@drbrain #12
a:~/git/ahoward/macaddr $ git pull && rake gem
remote: Counting objects: 8, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 8 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (8/8), done.
From https://github.com/ahoward/macaddr
301c26f..7e1cdc2 master -> origin/master
Updating 301c26f..7e1cdc2
Fast-forward
lib/macaddr.rb | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
a:~/git/ahoward/macaddr $ gem push pkg/macaddr-1.7.0.gem
Pushing gem to https://rubygems.org...
Repushing of gem versions is not allowed.
Please use `gem yank` to remove bad gem releases.
a:~/git/ahoward/macaddr $ vim lib/macaddr.rb
# ...
a:~/git/ahoward/macaddr $ rake gem
a:~/git/ahoward/macaddr $ gem push pkg/macaddr-1.7.1.gem
Pushing gem to https://rubygems.org...
Successfully registered gem: macaddr (1.7.1)
also, @drbrain
a:~/git/ahoward/macaddr $ gem owner macaddr|grep drb
- drbrain@segment7.net
just #FYI
thanks!