netsnmp 0.4.2 → 0.5.0

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: 8b92d6d77d4874c6d3d76ed0bbbb3358a72fd33131d9a971e41b73cb5584cfbd
4
- data.tar.gz: c2ae854a2a1f8268115291447bdd1ede0686258840aa41ba1778e41bb6c94c22
3
+ metadata.gz: 5119f7e6ec751a4d3ba54076e5597b0667de904eda86802e5e3544e40a753172
4
+ data.tar.gz: 35924abe6afc24d8a41c8b6429a0566644d6bf4674b2b83704ac3f215e217487
5
5
  SHA512:
6
- metadata.gz: f439b2ebd5777390ed34ec9bd893e943918b201f81fcfa1f9e55cb5800d1eba20712d5ebd2e9660b291383ba6d413977691842124cb97dad909283cbf1483fff
7
- data.tar.gz: fde5a6b1ec4340505e65c2f8dc49f04b6621136f4fc48c366742d8acb32e8f157f25554790fe2e64d672801307289f0b00d7f9945c561970729bc326dd5af34d
6
+ metadata.gz: 7662ff27d3242840034b7e72f0a85132fa7007ef44ab4e207ac79f13cfdc29c3709884b098bba97d83e0f157618a8ca8c4dab5d8919bc6686aba4452b990213f
7
+ data.tar.gz: 673c3ce56ca0154f5efc6247204ffebbd9d0966d43ba4371ba2cee98d10f1496e579eef84acf24349109315d35febb7c42716a8b88c432200cee3eeddd63cca3
@@ -120,7 +120,8 @@ module NETSNMP
120
120
  log { "signing V3 message..." }
121
121
  auth_salt = OpenSSL::ASN1::OctetString.new(signature).with_label(:auth)
122
122
  log(level: 2) { auth_salt.to_hex }
123
- encoded.sub!(AUTHNONE.to_der, auth_salt.to_der)
123
+ none_der = AUTHNONE.to_der
124
+ encoded[encoded.index(none_der), none_der.size] = auth_salt.to_der
124
125
  log { Hexdump.dump(encoded) }
125
126
  end
126
127
  encoded
data/lib/netsnmp/pdu.rb CHANGED
@@ -7,7 +7,7 @@ module NETSNMP
7
7
  class PDU
8
8
  using ASNExtensions
9
9
 
10
- MAXREQUESTID = 2147483647
10
+ MAXREQUESTID = 0x7fffffff
11
11
 
12
12
  using ASNExtensions
13
13
  class << self
@@ -75,7 +75,7 @@ module NETSNMP
75
75
 
76
76
  def initialize(host, port, timeout:)
77
77
  @socket = UDPSocket.new
78
- @socket.connect(host, port)
78
+ @destaddr = Socket.sockaddr_in(port, host)
79
79
  @timeout = timeout
80
80
  end
81
81
 
@@ -90,13 +90,13 @@ module NETSNMP
90
90
 
91
91
  def write(payload)
92
92
  perform_io do
93
- @socket.send(payload, 0)
93
+ @socket.sendmsg(payload, Socket::MSG_DONTWAIT | Socket::MSG_NOSIGNAL, @destaddr)
94
94
  end
95
95
  end
96
96
 
97
97
  def recv(bytesize = MAXPDUSIZE)
98
98
  perform_io do
99
- datagram, = @socket.recvfrom_nonblock(bytesize)
99
+ datagram, = @socket.recvmsg_nonblock(bytesize, Socket::MSG_DONTWAIT)
100
100
  datagram
101
101
  end
102
102
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NETSNMP
4
- VERSION = "0.4.2"
4
+ VERSION = "0.5.0"
5
5
  end
@@ -4,7 +4,7 @@ require "celluloid/io"
4
4
  require_relative "../support/request_examples"
5
5
  require_relative "../support/celluloid"
6
6
 
7
- RSpec.describe "with cellulloid", type: :celluloid, if: RUBY_ENGINE == "truffleruby" do
7
+ RSpec.describe "with cellulloid", type: :celluloid do
8
8
  include CelluloidHelpers
9
9
  let(:user_options) do
10
10
  { username: "authprivmd5des", auth_password: "maplesyrup",
@@ -26,7 +26,7 @@ module CelluloidHelpers
26
26
  end
27
27
  end
28
28
 
29
- class Proxy < NETSNMP::Session::Transport
29
+ class Proxy
30
30
  MAXPDUSIZE = 0xffff + 1
31
31
 
32
32
  def initialize(host, port)
@@ -35,18 +35,22 @@ module CelluloidHelpers
35
35
  @timeout = 2
36
36
  end
37
37
 
38
- def close
39
- @socket.close
38
+ def send(payload)
39
+ @socket.send(payload, 0)
40
+ recv
40
41
  end
41
42
 
42
- private
43
-
44
- def wait(mode)
43
+ def recv(bytesize = MAXPDUSIZE)
45
44
  Celluloid.timeout(@timeout) do
46
- @socket.__send__(mode)
45
+ datagram, = @socket.recvfrom(bytesize)
46
+ datagram
47
47
  end
48
48
  rescue Celluloid::TaskTimeout
49
49
  raise Timeout::Error, "Timeout after #{@timeout} seconds"
50
50
  end
51
+
52
+ def close
53
+ @socket.close
54
+ end
51
55
  end
52
56
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netsnmp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Cardoso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-07 00:00:00.000000000 Z
11
+ date: 2021-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parslet