net-proto 1.4.1 → 1.4.2

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
2
  SHA256:
3
- metadata.gz: b1bb0410a112bffe12fb31973dae5747d6b7fee011b0c6004bb3b70a113705d5
4
- data.tar.gz: 1520a184788ead801920378b3900924d20f34181b5aa3ffb26cc1863b3cafe7d
3
+ metadata.gz: 82de82e11a8d4cca74f1b807925b90c89a9dccf50907c5f29edfecf60e43d00d
4
+ data.tar.gz: 0f9f4da5409f7e6e6c1ba1b1ca6bb396964283edf1d01917fd168ccf666ec30c
5
5
  SHA512:
6
- metadata.gz: 0022bcec3b3fcd9e6070b04fe0a619bab1508b7a939865ffd26f068ac57ddbc69ff89ec35a1b040075ff4f88eac0d7aba69369244fea8426eea9240963e0aae0
7
- data.tar.gz: e31b0e71126f44869040fb630968aaaea482a83aef4599f2389198f90ec26b57db0e2e82b9b526323f4135799f77e8d76054bf628e2860df7dacb471ac47a392
6
+ metadata.gz: f31941974311642c93785c9885524cd724822cffc7d3e7a3954f033c6787125b6d50405a7edc2b41f9685114be2ec82c1dd758570fb0806cc769fa28fcafc777
7
+ data.tar.gz: 887a80b0657627809196abcbb4ae6966ab4d3147d79f9780bea662f3d5a1eb71e3180cb5c1af57746a61cc9ac57bb5d4c4e49fbf8ae4651aadcded2c67145040
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 1.4.2 - 3-Aug-2021
2
+ * Properly set the p_proto type (short, not int) for Windows.
3
+ * Minor updates suggested by rubocop.
4
+ * Added a Gemfile.
5
+
1
6
  ## 1.4.1 - 18-Feb-2021
2
7
  * Switch rdoc format to markdown where appropriate.
3
8
 
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/Rakefile CHANGED
@@ -3,15 +3,15 @@ require 'rake/testtask'
3
3
  require 'rake/clean'
4
4
  require 'rspec/core/rake_task'
5
5
 
6
- CLEAN.include('**/*.gem', '**/*.rbx', '**/*.rbc')
6
+ CLEAN.include('**/*.gem', '**/*.rbx', '**/*.rbc', '**/*.lock')
7
7
 
8
8
  namespace 'gem' do
9
9
  desc 'Create the net-proto gem'
10
10
  task :create => :clean do
11
11
  require 'rubygems/package'
12
- spec = eval(IO.read('net-proto.gemspec'))
12
+ spec = Gem::Specification.load('net-proto.gemspec')
13
13
  spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
14
- Gem::Package.build(spec, true)
14
+ Gem::Package.build(spec)
15
15
  end
16
16
 
17
17
  desc 'Install the net-proto gem'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'net/proto/common'
2
4
 
3
5
  # The Net module serves as a namespace only.
@@ -92,7 +94,7 @@ module Net
92
94
  endprotoent() if respond_to?(:endprotoent, true)
93
95
  end
94
96
 
95
- ptr.null? ? nil: struct[:p_name]
97
+ ptr.null? ? nil : struct[:p_name]
96
98
  end
97
99
 
98
100
  # In block form, yields each entry from /etc/protocols as a struct of type
@@ -1,17 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'net/proto/common'
2
4
 
3
5
  # The Net module serves as a namespace only.
4
6
  module Net
5
-
6
7
  # The Proto class serves as the base class for the various protocol methods.
7
8
  class Proto
8
9
  ffi_lib FFI::Library::LIBC
9
10
 
10
11
  attach_function :setprotoent, [:int], :void
11
12
  attach_function :endprotoent, [], :void
12
- attach_function :getprotobyname_r, [:string, :pointer, :pointer, :long, :pointer], :int
13
- attach_function :getprotobynumber_r, [:int, :pointer, :pointer, :long, :pointer], :int
14
- attach_function :getprotoent_r, [:pointer, :pointer, :long, :pointer], :int
13
+ attach_function :getprotobyname_r, %i[string pointer pointer long pointer], :int
14
+ attach_function :getprotobynumber_r, %i[int pointer pointer long pointer], :int
15
+ attach_function :getprotoent_r, %i[pointer pointer long pointer], :int
15
16
 
16
17
  private_class_method :setprotoent, :endprotoent, :getprotobyname_r
17
18
  private_class_method :getprotobynumber_r, :getprotoent_r
data/lib/net-proto.rb CHANGED
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'net/proto'
data/lib/net/proto.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rbconfig'
2
4
 
3
5
  case RbConfig::CONFIG['host_os']
@@ -1,29 +1,45 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'ffi'
2
4
 
5
+ # The Net module serves as a namespace only.
3
6
  module Net
7
+ # The Proto class serves as the base class for the various protocol methods.
4
8
  class Proto
5
9
  extend FFI::Library
6
10
 
7
11
  # The version of the net-proto library
8
- VERSION = '1.4.1'.freeze
12
+ VERSION = '1.4.2'
9
13
 
10
14
  private_class_method :new
11
15
 
16
+ # Struct used internally by C functions
12
17
  class ProtocolStruct < FFI::Struct
13
- layout(
14
- :p_name, :string,
15
- :p_aliases, :pointer,
16
- :p_proto, :int
17
- )
18
+ if File::ALT_SEPARATOR
19
+ layout(
20
+ :p_name, :string,
21
+ :p_aliases, :pointer,
22
+ :p_proto, :short
23
+ )
24
+ else
25
+ layout(
26
+ :p_name, :string,
27
+ :p_aliases, :pointer,
28
+ :p_proto, :int
29
+ )
30
+ end
18
31
  end
19
32
 
33
+ private_constant :ProtocolStruct
34
+
35
+ # Reopen the FFI::Pointer class and add our own method.
20
36
  class FFI::Pointer
21
37
  def read_array_of_string
22
38
  elements = []
23
39
 
24
40
  loc = self
25
41
 
26
- until ((element = loc.read_pointer).null?)
42
+ until (element = loc.read_pointer).null?
27
43
  elements << element.read_string
28
44
  loc += FFI::Type::POINTER.size
29
45
  end
@@ -1,17 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'net/proto/common'
2
4
 
3
5
  # The Net module serves as a namespace only.
4
6
  module Net
5
-
6
7
  # The Proto class serves as the base class for the various protocol methods.
7
8
  class Proto
8
9
  ffi_lib 'socket'
9
10
 
10
11
  attach_function :setprotoent, [:int], :void
11
12
  attach_function :endprotoent, [], :void
12
- attach_function :getprotobyname_r, [:string, :pointer, :pointer, :int], :pointer
13
- attach_function :getprotobynumber_r, [:int, :pointer, :pointer, :int], :pointer
14
- attach_function :getprotoent_r, [:pointer, :pointer, :int], :pointer
13
+ attach_function :getprotobyname_r, %i[string pointer pointer int], :pointer
14
+ attach_function :getprotobynumber_r, %i[int pointer pointer int], :pointer
15
+ attach_function :getprotoent_r, %i[pointer pointer int], :pointer
15
16
 
16
17
  private_class_method :setprotoent, :endprotoent, :getprotobyname_r
17
18
  private_class_method :getprotobynumber_r, :getprotoent_r
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'net/proto/common'
2
4
 
3
5
  # The Net module serves as a namespace only.
@@ -13,8 +15,8 @@ module Net
13
15
  # These should exist on every platform.
14
16
  attach_function :getprotobyname_c, :getprotobyname, [:string], :pointer
15
17
  attach_function :getprotobynumber_c, :getprotobynumber, [:int], :pointer
16
- attach_function :WSAAsyncGetProtoByName, [:uintptr_t, :uint, :string, :pointer, :pointer], :uintptr_t
17
- attach_function :WSAAsyncGetProtoByNumber, [:uintptr_t, :uint, :int, :pointer, :pointer], :uintptr_t
18
+ attach_function :WSAAsyncGetProtoByName, %i[uintptr_t uint string pointer pointer], :uintptr_t
19
+ attach_function :WSAAsyncGetProtoByNumber, %i[uintptr_t uint int pointer pointer], :uintptr_t
18
20
  attach_function :WSAGetLastError, [], :int
19
21
 
20
22
  private_class_method :getprotobyname_c
@@ -67,9 +69,7 @@ module Net
67
69
 
68
70
  handle = WSAAsyncGetProtoByName(hwnd, msg, protocol, struct, size_ptr)
69
71
 
70
- if handle == 0
71
- raise SystemCallError.new('WSAAsyncGetProtoByName', WSAGetLastError())
72
- end
72
+ raise SystemCallError.new('WSAAsyncGetProtoByName', WSAGetLastError()) if handle == 0
73
73
 
74
74
  yield struct[:p_proto], handle
75
75
  else
@@ -109,9 +109,7 @@ module Net
109
109
 
110
110
  handle = WSAAsyncGetProtoByNumber(hwnd, msg, protocol, struct, size_ptr)
111
111
 
112
- if handle == 0
113
- raise SystemCallError.new('WSAAsyncGetProtoByNumber', WSAGetLastError())
114
- end
112
+ raise SystemCallError.new('WSAAsyncGetProtoByNumber', WSAGetLastError()) if handle == 0
115
113
 
116
114
  yield struct[:p_name], handle
117
115
  else
@@ -146,11 +144,11 @@ module Net
146
144
  #
147
145
  def self.getprotoent
148
146
  structs = block_given? ? nil : []
149
- file = ENV['SystemRoot'] + '/system32/drivers/etc/protocol'
147
+ file = File.join(ENV['SystemRoot'], '/system32/drivers/etc/protocol')
150
148
 
151
149
  IO.foreach(file) do |line|
152
150
  next if line.lstrip[0] == '#' # Skip comments
153
- next if line.lstrip.size == 0 # Skip blank lines
151
+ next if line.lstrip.empty? # Skip blank lines
154
152
  line = line.split
155
153
 
156
154
  ruby_struct = ProtoStruct.new(line[0], line[2].split(','), line[1].to_i).freeze
data/net-proto.gemspec CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'net-proto'
5
- spec.version = '1.4.1'
5
+ spec.version = '1.4.2'
6
6
  spec.author = 'Daniel J. Berger'
7
7
  spec.license = 'Apache-2.0'
8
8
  spec.email = 'djberg96@gmail.com'
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.metadata = {
22
22
  'homepage_uri' => 'https://github.com/djberg96/net-proto',
23
23
  'bug_tracker_uri' => 'https://github.com/djberg96/net-proto/issues',
24
- 'changelog_uri' => 'https://github.com/djberg96/net-proto/blob/ffi/CHANGES',
24
+ 'changelog_uri' => 'https://github.com/djberg96/net-proto/blob/main/CHANGES.md',
25
25
  'documentation_uri' => 'https://github.com/djberg96/net-proto/wiki',
26
26
  'source_code_uri' => 'https://github.com/djberg96/net-proto',
27
27
  'wiki_uri' => 'https://github.com/djberg96/net-proto/wiki'
@@ -19,7 +19,7 @@ RSpec.describe Net::Proto do
19
19
  end
20
20
 
21
21
  example "version number is set to expected value" do
22
- expect(Net::Proto::VERSION).to eq('1.4.1')
22
+ expect(Net::Proto::VERSION).to eq('1.4.2')
23
23
  expect(Net::Proto::VERSION).to be_frozen
24
24
  end
25
25
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-proto
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -35,7 +35,7 @@ cert_chain:
35
35
  ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
36
  WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
37
  -----END CERTIFICATE-----
38
- date:
38
+ date: 2021-08-03 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: ffi
@@ -89,45 +89,31 @@ extensions: []
89
89
  extra_rdoc_files:
90
90
  - doc/netproto.rdoc
91
91
  files:
92
+ - CHANGES.md
93
+ - Gemfile
92
94
  - LICENSE
93
- - spec
94
- - spec/net_proto_spec.rb
95
+ - MANIFEST.md
95
96
  - README.md
96
97
  - Rakefile
97
- - MANIFEST.md
98
- - certs
99
98
  - certs/djberg96_pub.pem
100
- - examples
99
+ - doc/netproto.rdoc
101
100
  - examples/example_net_proto.rb
102
- - lib
103
- - lib/net
101
+ - lib/generic/net/proto.rb
102
+ - lib/linux/net/proto.rb
103
+ - lib/net-proto.rb
104
104
  - lib/net/proto.rb
105
- - lib/net/proto
106
105
  - lib/net/proto/common.rb
107
- - lib/sunos
108
- - lib/sunos/net
109
106
  - lib/sunos/net/proto.rb
110
- - lib/net-proto.rb
111
- - lib/linux
112
- - lib/linux/net
113
- - lib/linux/net/proto.rb
114
- - lib/generic
115
- - lib/generic/net
116
- - lib/generic/net/proto.rb
117
- - lib/windows
118
- - lib/windows/net
119
107
  - lib/windows/net/proto.rb
120
- - CHANGES.md
121
- - doc
122
- - doc/netproto.rdoc
123
108
  - net-proto.gemspec
109
+ - spec/net_proto_spec.rb
124
110
  homepage: https://github.com/djberg96/net-proto
125
111
  licenses:
126
112
  - Apache-2.0
127
113
  metadata:
128
114
  homepage_uri: https://github.com/djberg96/net-proto
129
115
  bug_tracker_uri: https://github.com/djberg96/net-proto/issues
130
- changelog_uri: https://github.com/djberg96/net-proto/blob/ffi/CHANGES
116
+ changelog_uri: https://github.com/djberg96/net-proto/blob/main/CHANGES.md
131
117
  documentation_uri: https://github.com/djberg96/net-proto/wiki
132
118
  source_code_uri: https://github.com/djberg96/net-proto
133
119
  wiki_uri: https://github.com/djberg96/net-proto/wiki
@@ -146,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
132
  - !ruby/object:Gem::Version
147
133
  version: '0'
148
134
  requirements: []
149
- rubygems_version: 3.0.3
135
+ rubygems_version: 3.2.15
150
136
  signing_key:
151
137
  specification_version: 4
152
138
  summary: A Ruby interface for determining protocol information
metadata.gz.sig CHANGED
Binary file