network_interface 0.0.2 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 52fb1a0e9f04f0062700dce9cd2afc292c7b15c9
4
- data.tar.gz: ab551e02256081dd51b60606ac8665a4fdac489f
2
+ SHA256:
3
+ metadata.gz: 758a87463cdbf1569ad80a19c47a95e2c91e1eacb6cace97885d84cad09fd8a9
4
+ data.tar.gz: 6599981462fab25a7914b847f9ddbf42fabf7c260ad3501e3ab3441100e6a6ed
5
5
  SHA512:
6
- metadata.gz: bc7398db2eb281e5348898ca0af4e99a53aa0db0eaef22740915dbebfd323a043106cd842c7350e6d0e7394a6bc448df9635a52f4b7c1c4d34d2b626ae11de9c
7
- data.tar.gz: 2dc7d93eed2dfa8a778d64c615619505e0188f10f7f0b505486559fbb7447397f482668496c5a7316067953e3ada5abf70f1d26ac55e6af29d7921c62ce9912c
6
+ metadata.gz: bf7eaade6035c18e9120a75c0eb86ab2303f9b7ea76f96f6e33b8e256874f854550144f3350309fb6291f2ddd1b78afda9269054c1f3c601ff910c1c6fdeac78
7
+ data.tar.gz: f5903780de195f98824f5ccdbbee8f749f21094d1885d1e1de5f7d0067ba1c65a3fba1c4ce820bddcf1a48a54ad47b597507bad9ad29bd290fa22a20add80737
checksums.yaml.gz.sig ADDED
Binary file
@@ -0,0 +1,60 @@
1
+ name: Verify
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - '*'
7
+ pull_request:
8
+ branches:
9
+ - '*'
10
+
11
+ jobs:
12
+ test:
13
+ timeout-minutes: 40
14
+
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ os:
19
+ - ubuntu-20.04
20
+ ruby:
21
+ - '2.5'
22
+ - '2.6'
23
+ - '2.7'
24
+ - '3.0'
25
+ include:
26
+ - { os: ubuntu-latest, ruby: '3.0', docker_image: 'ruby:3.0' }
27
+ env:
28
+ RAILS_ENV: test
29
+
30
+ runs-on: ${{ matrix.os }}
31
+
32
+ name: Ruby ${{ matrix.ruby }} ${{ matrix.docker_image && 'Docker' || matrix.os }}
33
+ steps:
34
+ - name: Checkout code
35
+ uses: actions/checkout@v2
36
+
37
+ - name: Setup Ruby
38
+ if: ${{ !matrix.docker_image }}
39
+ uses: ruby/setup-ruby@v1
40
+ with:
41
+ ruby-version: ${{ matrix.ruby }}
42
+ bundler-cache: true
43
+
44
+ - name: Rake Compile with Bundle
45
+ if: ${{ !matrix.docker_image }}
46
+ run: |
47
+ bundle exec rake compile
48
+
49
+ - name: ${{ matrix.test_cmd }}
50
+ if: ${{ !matrix.docker_image }}
51
+ run: |
52
+ bundle exec rspec
53
+
54
+ - name: Run tests in docker
55
+ if: ${{ matrix.docker_image }}
56
+ env:
57
+ DOCKER_IMAGE: ${{ matrix.docker_image }}
58
+ run: |
59
+ docker network create --ipv6 --subnet 2001:0DB8::/112 ip6net
60
+ docker run --rm --network ip6net -w $(pwd) -v $(pwd):$(pwd) ${DOCKER_IMAGE} /bin/sh -c "ls -lah; apt update; apt install -y git net-tools; bundle install; bundle exec rake compile; bundle exec rspec"
data/Gemfile.lock CHANGED
@@ -1,38 +1,37 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- network_interface (0.0.2)
4
+ network_interface (0.0.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- diff-lcs (1.3)
10
- rake (12.0.0)
11
- rake-compiler (1.0.4)
9
+ diff-lcs (1.4.4)
10
+ rake (13.0.3)
11
+ rake-compiler (1.1.1)
12
12
  rake
13
- rspec (3.6.0)
14
- rspec-core (~> 3.6.0)
15
- rspec-expectations (~> 3.6.0)
16
- rspec-mocks (~> 3.6.0)
17
- rspec-core (3.6.0)
18
- rspec-support (~> 3.6.0)
19
- rspec-expectations (3.6.0)
13
+ rspec (3.10.0)
14
+ rspec-core (~> 3.10.0)
15
+ rspec-expectations (~> 3.10.0)
16
+ rspec-mocks (~> 3.10.0)
17
+ rspec-core (3.10.1)
18
+ rspec-support (~> 3.10.0)
19
+ rspec-expectations (3.10.1)
20
20
  diff-lcs (>= 1.2.0, < 2.0)
21
- rspec-support (~> 3.6.0)
22
- rspec-mocks (3.6.0)
21
+ rspec-support (~> 3.10.0)
22
+ rspec-mocks (3.10.2)
23
23
  diff-lcs (>= 1.2.0, < 2.0)
24
- rspec-support (~> 3.6.0)
25
- rspec-support (3.6.0)
24
+ rspec-support (~> 3.10.0)
25
+ rspec-support (3.10.2)
26
26
 
27
27
  PLATFORMS
28
28
  ruby
29
29
 
30
30
  DEPENDENCIES
31
- bundler (~> 1.3)
32
31
  network_interface!
33
32
  rake
34
33
  rake-compiler
35
34
  rspec
36
35
 
37
36
  BUNDLED WITH
38
- 1.15.4
37
+ 2.1.4
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # NetworkInterface
2
2
 
3
- TODO: Write a gem description
3
+ A simple Ruby wrapper for accessing network interface information
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,7 +18,75 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ ```ruby
22
+ require 'network_interface'
23
+
24
+ puts NetworkInterface.interfaces
25
+ puts NetworkInterface.addresses('eth0')
26
+ ```
27
+
28
+ ## Development
29
+
30
+ Compiling:
31
+
32
+ ```
33
+ bundle install
34
+ bundle exec rake clean
35
+ bundle exec rake compile
36
+ ```
37
+
38
+ Running the test suite, requires `ifconfig`/`ipconfig` to be installed:
39
+
40
+ ```
41
+ bundle exec rspec
42
+ ```
43
+
44
+ To debug with GDB:
45
+
46
+ 1. Optional: Explicitly add `asm("int3");` into the C code that you wish to have a breakpoint for:
47
+
48
+ ```c
49
+ VALUE rb_cNetworkInterface;
50
+ void
51
+ Init_network_interface_ext()
52
+ {
53
+ asm("int3");
54
+
55
+ // ...
56
+ }
57
+ ```
58
+
59
+ 2. Compile and start GDB:
60
+
61
+ ```shell
62
+ bundle exec rake compile
63
+ gdb run --args ruby -e '$LOAD_PATH.unshift(File.join(Dir.pwd, "lib")); require("network_interface"); puts NetworkInterface.interfaces'
64
+ ```
65
+
66
+ 3. Add a runtime breakpoint:
67
+
68
+ ```shell
69
+ (gdb) add-symbol-file ./lib/network_interface_ext.so
70
+ Reading symbols from ./lib/network_interface_ext.so...
71
+
72
+ (gdb) break Init_network_interface_ext
73
+ Breakpoint 1 at 0x1850: file ../../../../ext/network_interface_ext/netifaces.c, line 825.
74
+
75
+ (gdb) run
76
+ Starting program: /usr/bin/ruby -e \$LOAD_PATH.unshift\(File.join\(Dir.pwd,\ \"lib\"\)\)\;\ require\(\"network_interface\"\)\;\ puts\ NetworkInterface.interfaces
77
+ [Thread debugging using libthread_db enabled]
78
+ Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
79
+
80
+ Breakpoint 1.2, Init_network_interface_ext () at ../../../../ext/network_interface_ext/netifaces.c:825
81
+ 825 rb_cNetworkInterface = rb_define_module("NetworkInterface");
82
+ (gdb)
83
+ ```
84
+
85
+ To use a development build of this gem in another project, add this to the target project's `Gemfile`:
86
+
87
+ ```
88
+ gem 'network_interface', path: '../network_interface'
89
+ ```
22
90
 
23
91
  ## Contributing
24
92
 
@@ -1,6 +1,9 @@
1
1
  #include "ruby.h"
2
2
  #include "netifaces.h"
3
3
 
4
+ VALUE rb_cNetworkInterface;
5
+ VALUE rb_cNetworkInterfaceError;
6
+
4
7
  #if !defined(WIN32)
5
8
  #if !HAVE_GETNAMEINFO
6
9
  #undef getnameinfo
@@ -245,7 +248,7 @@ rbnetifaces_s_addresses (VALUE class, VALUE dev)
245
248
 
246
249
  if (!pAdapterInfo)
247
250
  {
248
- rb_raise(rb_eRuntimeError, "Unknow error at OS level");
251
+ rb_raise(rb_cNetworkInterfaceError, "Could not malloc ADAPTER_INFO");
249
252
  return Qnil;
250
253
  }
251
254
  }
@@ -256,7 +259,7 @@ rbnetifaces_s_addresses (VALUE class, VALUE dev)
256
259
  {
257
260
  if (pAdapterInfo)
258
261
  free (pAdapterInfo);
259
- rb_raise(rb_eRuntimeError, "Unable to obtain adapter information.");
262
+ rb_raise(rb_cNetworkInterfaceError, "Unable to obtain adapter information via GetAdaptersInfo");
260
263
  return Qnil;
261
264
  }
262
265
 
@@ -347,7 +350,7 @@ rbnetifaces_s_addresses (VALUE class, VALUE dev)
347
350
  #elif HAVE_GETIFADDRS
348
351
  if (getifaddrs (&addrs) < 0)
349
352
  {
350
- rb_raise(rb_eRuntimeError, "Unknow error at OS level");
353
+ rb_raise(rb_cNetworkInterfaceError, "Unable to retrieve network interface info via getifaddrs");
351
354
  }
352
355
 
353
356
  for (addr = addrs; addr; addr = addr->ifa_next)
@@ -401,7 +404,7 @@ rbnetifaces_s_addresses (VALUE class, VALUE dev)
401
404
 
402
405
  if (sock < 0)
403
406
  {
404
- rb_raise(rb_eRuntimeError, "Unknow error at OS level");
407
+ rb_raise(rb_cNetworkInterfaceError, "Socket not created");
405
408
  return Qnil;
406
409
  }
407
410
 
@@ -530,7 +533,6 @@ rbnetifaces_s_addresses (VALUE class, VALUE dev)
530
533
  return Qnil;
531
534
 
532
535
  }
533
-
534
536
  VALUE
535
537
  rbnetifaces_s_interfaces (VALUE self)
536
538
  {
@@ -566,7 +568,7 @@ rbnetifaces_s_interfaces (VALUE self)
566
568
 
567
569
  if (!pAdapterInfo)
568
570
  {
569
- rb_raise(rb_eRuntimeError, "Unknow error at OS level");
571
+ rb_raise(rb_cNetworkInterfaceError, "Could not malloc ADAPTER_INFO");
570
572
  }
571
573
  }
572
574
  } while (dwRet == ERROR_BUFFER_OVERFLOW);
@@ -577,7 +579,7 @@ rbnetifaces_s_interfaces (VALUE self)
577
579
  if (pAdapterInfo)
578
580
  free (pAdapterInfo);
579
581
 
580
- rb_raise(rb_eRuntimeError, "Unknow error at OS level");
582
+ rb_raise(rb_cNetworkInterfaceError, "Unable to retrieve adapter info via GetAdaptersInfo");
581
583
  return Qnil;
582
584
  }
583
585
  if (dwRet == ERROR_NO_DATA)
@@ -606,7 +608,7 @@ rbnetifaces_s_interfaces (VALUE self)
606
608
  #elif HAVE_GETIFADDRS
607
609
  if (getifaddrs (&addrs) < 0)
608
610
  {
609
- rb_raise(rb_eRuntimeError, "Unknow error at OS level");
611
+ rb_raise(rb_cNetworkInterfaceError, "Unable to retrieve adapter info via getifaddrs");
610
612
  }
611
613
 
612
614
  for (addr = addrs; addr; addr = addr->ifa_next)
@@ -628,7 +630,7 @@ rbnetifaces_s_interfaces (VALUE self)
628
630
  fd = socket (AF_INET, SOCK_DGRAM, 0);
629
631
  len = -1;
630
632
  if (fd < 0) {
631
- rb_raise(rb_eRuntimeError, "Unknow error at OS level");
633
+ rb_raise(rb_cNetworkInterfaceError, "Error creating socket");
632
634
  return Qnil;
633
635
  }
634
636
 
@@ -661,7 +663,7 @@ rbnetifaces_s_interfaces (VALUE self)
661
663
 
662
664
  if (!ifc.CNAME(ifc_buf)) {
663
665
  close (fd);
664
- rb_raise(rb_eRuntimeError, "Not enough memory");
666
+ rb_raise(rb_cNetworkInterfaceError, "Not enough memory");
665
667
  return Qnil;
666
668
  }
667
669
 
@@ -673,7 +675,7 @@ rbnetifaces_s_interfaces (VALUE self)
673
675
  #endif
674
676
  free (ifc.CNAME(ifc_req));
675
677
  close (fd);
676
- rb_raise(rb_eRuntimeError, "Unknow error at OS level");
678
+ rb_raise(rb_cNetworkInterfaceError, "Unable to calculate buffer size");
677
679
  return Qnil;
678
680
  }
679
681
 
@@ -724,7 +726,7 @@ rbnetifaces_s_interface_info (VALUE self, VALUE dev)
724
726
 
725
727
  if (!pAdapterInfo)
726
728
  {
727
- rb_raise(rb_eRuntimeError, "Unknow error at OS level");
729
+ rb_raise(rb_cNetworkInterfaceError, "Could not malloc ADAPTER_INFO");
728
730
  }
729
731
  }
730
732
  } while (dwRet == ERROR_BUFFER_OVERFLOW);
@@ -735,7 +737,7 @@ rbnetifaces_s_interface_info (VALUE self, VALUE dev)
735
737
  if (pAdapterInfo)
736
738
  free (pAdapterInfo);
737
739
 
738
- rb_raise(rb_eRuntimeError, "Unknow error at OS level");
740
+ rb_raise(rb_cNetworkInterfaceError, "Unable to obtain adapter information via GetAdaptersInfo");
739
741
  return Qnil;
740
742
  }
741
743
  if (dwRet == ERROR_NO_DATA)
@@ -817,11 +819,11 @@ rbnetifaces_s_interface_info (VALUE self, VALUE dev)
817
819
  return result;
818
820
  }
819
821
 
820
- VALUE rb_cNetworkInterface;
821
822
  void
822
823
  Init_network_interface_ext()
823
824
  {
824
825
  rb_cNetworkInterface = rb_define_module("NetworkInterface");
826
+ rb_cNetworkInterfaceError = rb_define_class_under(rb_cNetworkInterface, "Error", rb_eRuntimeError);
825
827
  rb_define_module_function(rb_cNetworkInterface, "interfaces", rbnetifaces_s_interfaces, 0);
826
828
  rb_define_module_function(rb_cNetworkInterface, "addresses", rbnetifaces_s_addresses, 1);
827
829
  rb_define_module_function(rb_cNetworkInterface, "interface_info", rbnetifaces_s_interface_info, 1);
@@ -1,3 +1,3 @@
1
1
  module NetworkInterface
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -16,14 +16,17 @@ Gem::Specification.new do |spec|
16
16
  spec.homepage = "https://github.com/rapid7/network_interface"
17
17
  spec.license = "MIT"
18
18
 
19
- spec.files = `git ls-files`.split($/)
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features|tmp)/}) }
23
+ end
20
24
  spec.extensions = ['ext/network_interface_ext/extconf.rb']
21
25
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
26
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
27
  spec.require_paths = ["lib"]
24
28
 
25
- spec.add_development_dependency "bundler", "~> 1.3"
26
29
  spec.add_development_dependency "rake"
27
- spec.add_development_dependency "rake-compiler", ">= 0"
30
+ spec.add_development_dependency "rake-compiler"
28
31
  spec.add_development_dependency "rspec"
29
32
  end
data.tar.gz.sig ADDED
@@ -0,0 +1 @@
1
+ �G����<�w;��[�{��e�A��.(��Po��0��(P h��v��8v�k�O��h�j 8��I�O���9B�c�;Z�a5�� (�vO�¢�(k1a��uWp���k��%�PM�� g��+a���G\'�-�h\F���/� �]^����I�����_�_ʩٲ}�r�����@�P��ݓ��! � ����g~�8�˚��$�Y�H��Ą�:YK�ȝ�)�m�~�I�G-���$ą��
metadata CHANGED
@@ -1,30 +1,101 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: network_interface
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Turner
8
8
  - Lance Sanchez
9
9
  autorequire:
10
10
  bindir: bin
11
- cert_chain: []
12
- date: 2017-08-29 00:00:00.000000000 Z
11
+ cert_chain:
12
+ - |
13
+ -----BEGIN CERTIFICATE-----
14
+ MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBl
15
+ MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
16
+ d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJv
17
+ b3QgQ0EwHhcNMDYxMTEwMDAwMDAwWhcNMzExMTEwMDAwMDAwWjBlMQswCQYDVQQG
18
+ EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNl
19
+ cnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0EwggEi
20
+ MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtDhXO5EOAXLGH87dg+XESpa7c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AQR4MHYw
87
+ JAYIKwYBBQUHMAGGGGh0dHA6Ly9vY3NwLmRpZ2ljZXJ0LmNvbTBOBggrBgEFBQcw
88
+ AoZCaHR0cDovL2NhY2VydHMuZGlnaWNlcnQuY29tL0RpZ2lDZXJ0U0hBMkFzc3Vy
89
+ ZWRJRENvZGVTaWduaW5nQ0EuY3J0MAwGA1UdEwEB/wQCMAAwDQYJKoZIhvcNAQEL
90
+ BQADggEBAN+GL5/myPWg7oH4mVrG7/OhXF1MoYQF0ddaNiqaweEHMuKJBQCVZRbL
91
+ 37HojoKXXv2yyRJBCeTB+ojrxX+5PdLVZa0ss7toWzJ2A1poPXZ1eZvm5xeFD32z
92
+ YQaTmmNWNI3PCDTyJ2PXUc+bDiNNwcZ7yc5o78UNRvp9Jxghya17Q76c9Ov9wvnv
93
+ dxxQKWGOQy0m4fBrkyjAyH9Djjn81RbQrqYgPuhd5nD0HjN3VUQLhQbIJrk9TVs0
94
+ EknWpNgVhohbot1lfVAMmIhdtOVaRVcQQixWPwprDj/ydB8ryDMDosIMcw+fkoXU
95
+ 9GJsSaSRRYQ9UUkVL27b64okU8D48m8=
96
+ -----END CERTIFICATE-----
97
+ date: 2023-08-17 00:00:00.000000000 Z
13
98
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: bundler
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - "~>"
19
- - !ruby/object:Gem::Version
20
- version: '1.3'
21
- type: :development
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - "~>"
26
- - !ruby/object:Gem::Version
27
- version: '1.3'
28
99
  - !ruby/object:Gem::Dependency
29
100
  name: rake
30
101
  requirement: !ruby/object:Gem::Requirement
@@ -79,6 +150,7 @@ extensions:
79
150
  - ext/network_interface_ext/extconf.rb
80
151
  extra_rdoc_files: []
81
152
  files:
153
+ - ".github/workflows/verify.yml"
82
154
  - ".gitignore"
83
155
  - ".rspec"
84
156
  - Gemfile
@@ -93,8 +165,6 @@ files:
93
165
  - lib/network_interface.rb
94
166
  - lib/network_interface/version.rb
95
167
  - network_interface.gemspec
96
- - spec/netiface_spec.rb
97
- - spec/spec_helper.rb
98
168
  homepage: https://github.com/rapid7/network_interface
99
169
  licenses:
100
170
  - MIT
@@ -114,11 +184,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
184
  - !ruby/object:Gem::Version
115
185
  version: '0'
116
186
  requirements: []
117
- rubyforge_project:
118
- rubygems_version: 2.6.13
187
+ rubygems_version: 3.1.4
119
188
  signing_key:
120
189
  specification_version: 4
121
190
  summary: A cross platform gem to help get network interface information
122
- test_files:
123
- - spec/netiface_spec.rb
124
- - spec/spec_helper.rb
191
+ test_files: []
metadata.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ }̹w�x��6�� ��vy��� LF。�b��_h���u8[�Rǘ� w~�c�߸�NR�7薰�S�B�W��2
2
+ w"����#K�k++/XA:*A��ڱ��|��ѶN��Ռ��1�sM��Ol�T�&{�C��n&��ӂ!g��ֵ/�j:��A?�� .��ʉ?\�Y�Ru+FY����b�km���`���[�E���I�Cd �l�8��2��'�'�dGu�x��M@�ʽ΀�3bD&ߗ�R/*��
@@ -1,48 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe NetworkInterface do
4
-
5
- describe "#interfaces" do
6
- it "should have the same interfaces as the system_interfaces" do
7
- NetworkInterface.interfaces.should include(*system_interfaces_with_addresses.keys)
8
- end
9
- end
10
-
11
- describe "#addresses" do
12
- system_interfaces_with_addresses.each do |interface, hash|
13
- describe "#{friendly_interface_names.key(interface)}" do
14
- if hash.has_key?(:ipv4)
15
- describe "ipv4" do
16
- it "should have an ipv4 address" do
17
- NetworkInterface.addresses(interface).should have_key NetworkInterface::AF_INET
18
- end
19
- it "should match the system interface of #{hash[:ipv4]}" do
20
- NetworkInterface.addresses(interface)[NetworkInterface::AF_INET][0]["addr"].should == hash[:ipv4]
21
- end
22
- end
23
- end
24
- if hash.has_key?(:ipv6)
25
- describe "ipv6" do
26
- it "should have an ipv6 address" do
27
- NetworkInterface.addresses(interface).should have_key NetworkInterface::AF_INET6
28
- end
29
- it "should match the system interface of #{hash[:ipv6]}" do
30
- NetworkInterface.addresses(interface)[NetworkInterface::AF_INET6][0]["addr"].should == hash[:ipv6]
31
- end
32
- end
33
- end
34
- if hash.has_key?(:mac)
35
- describe "MAC address" do
36
- it "should have a MAC address" do
37
- NetworkInterface.addresses(interface).should have_key NetworkInterface::AF_LINK
38
- end
39
- it "should match the system interface of #{hash[:mac]}" do
40
- NetworkInterface.addresses(interface)[NetworkInterface::AF_LINK][0]["addr"].should == hash[:mac]
41
- end
42
- end
43
- end
44
- end
45
- end
46
-
47
- end
48
- end
data/spec/spec_helper.rb DELETED
@@ -1,107 +0,0 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
3
- require 'network_interface'
4
- require 'rspec'
5
- require 'rspec/autorun'
6
-
7
- RSpec.configure do |config|
8
- end
9
-
10
- def friendly_interface_names
11
- interfaces = NetworkInterface.interfaces
12
- interface_names ||= begin
13
- h = {}
14
- interfaces.each do |interface|
15
- info = NetworkInterface.interface_info(interface)
16
- name = if info && info.has_key?('name')
17
- info['name']
18
- else
19
- interface
20
- end
21
- h[name] = interface
22
- end
23
- h
24
- end
25
- interface_names
26
- end
27
-
28
- if RUBY_PLATFORM =~ /i386-mingw32/
29
- def system_interfaces
30
- ipconfig = `ipconfig`
31
- ipconfig_array = ipconfig.split("\n").reject {|s| s.empty?}
32
-
33
- getmac = `getmac -nh`
34
- getmac_array = getmac.split("\n").reject {|s| s.empty?}
35
- getmac_array.map!{|element| element.split(" ")}
36
- getmac_hash = getmac_array.inject({}) do |hash, array|
37
- hash.merge!({array[1][/\{(.*)\}/,1] => array[0].gsub("-",":").downcase})
38
- end
39
-
40
- interfaces = {}
41
- @key = nil
42
- ipconfig_array.each do |element|
43
- if element.start_with? " "
44
- case element
45
- when /IPv6 Address.*: (.*)/
46
- # interfaces[@key][:ipv6] = $1
47
- when /IPv4 Address.*: (.*)/
48
- interfaces[@key][:ipv4] = $1
49
- interfaces[@key][:mac] = getmac_hash[@key[/\{(.*)\}/,1]]
50
- end
51
- elsif element[/Windows IP Configuration/]
52
- elsif element[/Ethernet adapter (.*):/]
53
- @key = friendly_interface_names[$1]
54
- interfaces[@key] = {}
55
- else
56
- @key = element[/(.*):/,1]
57
- interfaces[@key] = {}
58
- end
59
- end
60
-
61
- interfaces
62
- end
63
-
64
- else
65
- def system_interfaces
66
- ifconfig = `/sbin/ifconfig`
67
- ifconfig_array = ifconfig.split("\n")
68
- ifconfig_array.map!{|element| element.split("\n")}
69
- ifconfig_array.flatten!
70
- interfaces = {}
71
- @key = nil
72
- ifconfig_array.each do |element|
73
- if element.start_with?("\t") || element.start_with?(" ")
74
- case element
75
- when /ether ((\w{2}\:){5}(\w{2}))/
76
- interfaces[@key][:mac] = $1
77
- when /inet6 (.*) prefixlen/
78
- interfaces[@key][:ipv6] = $1
79
- when /inet ((\d{1,3}\.){3}\d{1,3}).*broadcast ((\d{1,3}\.){3}\d{1,3})/
80
- interfaces[@key][:ipv4] = $1
81
- interfaces[@key][:broadcast] = $3
82
- when /addr:((\d{1,3}\.){3}\d{1,3})\s+Bcast:((\d{1,3}\.){3}\d{1,3})/i
83
- interfaces[@key][:ipv4] = $1
84
- interfaces[@key][:broadcast] = $3
85
- end
86
- else
87
- @key = element.split(' ').first[/(\w*)/,1]
88
- interfaces[@key] = {}
89
- if element[/HWaddr ((\w{2}\:){5}(\w{2}))/]
90
- interfaces[@key][:mac] = $1
91
- end
92
- end
93
- end
94
- interfaces
95
- end
96
-
97
- end
98
-
99
- def system_interfaces_with_addresses
100
- interfaces = {}
101
- system_interfaces.each do |key, value|
102
- if value.has_key? :ipv4
103
- interfaces[key] = value
104
- end
105
- end
106
- interfaces
107
- end