dns_mock 1.6.2 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dns_mock.gemspec +1 -1
- data/lib/dns_mock/response/message.rb +3 -1
- data/lib/dns_mock/server.rb +10 -3
- data/lib/dns_mock/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fa8fa6db5cdaa0081f155c1a1c80f763eb51ab39965b2bc127d3b10efb40abc
|
4
|
+
data.tar.gz: c8ae788a8b5c5ffe1bb6a00a09b7351988bfad3ab233dec73aaa8f082f326009
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ab0d7ab53a79ba63eeee19ed543c1ed0edf65c8ebcc54078ac8c4fce93a6e846cf6d8c09f5b9ac47786d7897d8b717248dc83bc3c944e25b11d5efdd0e7c39a
|
7
|
+
data.tar.gz: e23f63ccd026071469f128c972d454bd28d9b51bebc78a48d8492f9d214e53880b5b32e79ad1a74e7e2a286267d6d0b184377fa9d7feba6820fc41e4660f59c6
|
data/dns_mock.gemspec
CHANGED
@@ -34,6 +34,6 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_development_dependency 'ffaker', ffaker_version
|
35
35
|
spec.add_development_dependency 'net-ftp', '~> 0.3.4' if current_ruby_version >= ::Gem::Version.new('3.1.0')
|
36
36
|
spec.add_development_dependency 'rake', '~> 13.1'
|
37
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
37
|
+
spec.add_development_dependency 'rspec', '~> 3.13'
|
38
38
|
spec.add_development_dependency 'rspec-dns', '~> 0.1.8'
|
39
39
|
end
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module DnsMock
|
4
4
|
module Response
|
5
5
|
class Message
|
6
|
+
attr_reader :dns_message
|
7
|
+
|
6
8
|
def initialize(
|
7
9
|
packet,
|
8
10
|
records,
|
@@ -23,7 +25,7 @@ module DnsMock
|
|
23
25
|
|
24
26
|
private
|
25
27
|
|
26
|
-
attr_reader :dns_answer
|
28
|
+
attr_reader :dns_answer
|
27
29
|
|
28
30
|
def compose_answer
|
29
31
|
dns_message.each_question do |hostname, record_type|
|
data/lib/dns_mock/server.rb
CHANGED
@@ -9,7 +9,7 @@ module DnsMock
|
|
9
9
|
WARMUP_DELAY = 0.1
|
10
10
|
PACKET_MAX_BYTES_SIZE = 65_535
|
11
11
|
|
12
|
-
attr_reader :port
|
12
|
+
attr_reader :port, :messages
|
13
13
|
|
14
14
|
def initialize( # rubocop:disable Metrics/ParameterLists
|
15
15
|
socket = ::UDPSocket.new,
|
@@ -25,10 +25,11 @@ module DnsMock
|
|
25
25
|
@records = records_dictionary_builder.call(records || {})
|
26
26
|
@port = port || 0
|
27
27
|
@exception_if_not_found = exception_if_not_found
|
28
|
+
@messages = []
|
28
29
|
prepare_server_thread
|
29
30
|
end
|
30
31
|
|
31
|
-
def run
|
32
|
+
def run # rubocop:disable Metrics/AbcSize
|
32
33
|
prepare_socket_for_session
|
33
34
|
update_server_port
|
34
35
|
|
@@ -38,7 +39,9 @@ module DnsMock
|
|
38
39
|
break if packet.empty?
|
39
40
|
|
40
41
|
address, port = addr.values_at(3, 1)
|
41
|
-
|
42
|
+
message = DnsMock::Response::Message.new(packet, records, exception_if_not_found)
|
43
|
+
socket.send(message.as_binary_string, 0, address, port)
|
44
|
+
messages.push(message.dns_message)
|
42
45
|
end
|
43
46
|
ensure
|
44
47
|
socket.close
|
@@ -53,6 +56,10 @@ module DnsMock
|
|
53
56
|
records.clear.empty?
|
54
57
|
end
|
55
58
|
|
59
|
+
def clear_messages!
|
60
|
+
!!messages.clear
|
61
|
+
end
|
62
|
+
|
56
63
|
def without_mocks?
|
57
64
|
records.empty?
|
58
65
|
end
|
data/lib/dns_mock/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dns_mock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladislav Trotsenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simpleidn
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '3.
|
61
|
+
version: '3.13'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '3.
|
68
|
+
version: '3.13'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec-dns
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|