dmarcator 0.10.0 → 0.11.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: a1bd93bc4b534e2b9613241e920dd4a71c41e564c92c10ab8abaf6be7294feb8
4
- data.tar.gz: fb95401f394f53189a0db431f7d31bc4ffe8c25c87ce87f825f18a99962dadba
3
+ metadata.gz: 689cd037f395f7803f4157fd148305f1d9d6c3dbb19fd42b61311b8e37d57124
4
+ data.tar.gz: 80518a23a140cb7102cb4d20a5fa896852ca8b104a3047939bcf4ba018e89699
5
5
  SHA512:
6
- metadata.gz: c94318c4ac8a5f7089276f5d6bf91ae90ab8cf576f6367acf418e86adba5fe4bb5e28f7df4a478f8783d134b82bd9390555b3af48c713ca869fd276be4cfe08b
7
- data.tar.gz: 6b10b30dfc64acd1cdef7427c4a475d7d9fa90b4c9d387cbc1e2293e8b693e66d3fa4bc23d80d254d92a5a4137ab65b1fe98adfc0e28e573bafc8342274e7995
6
+ metadata.gz: c3b5f59702e05d0ffeeec17c9c3e7f8c1bd078448ba029fd4cf6bc8e6cbd8107dbda2e3633c228d1706f09832023a8a64b9806d6ee843b1fe13d449b19379e0c
7
+ data.tar.gz: de98c5111a0eb8023fa10807c7227d18bead12e17f2f43d084d8c5e3d27a2b1a4e86212c0c075fa2e75a97e5710e738de2baad45b833c31249d54a1abec80bb2
data/ChangeLog.md CHANGED
@@ -1,3 +1,9 @@
1
+ ### 0.11.0 / 2026-10-29
2
+
3
+ * Add `DMARCator.configure` for process-wide defaults, so a resolver can be set from code instead of only through the `DMARCATOR_DNS` environment variables. A configured resolver takes precedence over the environment, and `DMARCator.reset_configuration!` discards it.
4
+ * A configured resolver may be a callable, in which case it is invoked for each lookup. This lets threaded applications use one resolver per lookup instead of sharing a `Resolv::DNS`, which does not serialise concurrent lookups.
5
+ * Run CI on macOS 15 as well as Ubuntu 24.04, covering the Socket/OpenSSL and Net::HTTP paths used by the DoT and DoH transports.
6
+
1
7
  ### 0.10.0 / 2026-10-29
2
8
 
3
9
  Breaking changes, taken before 1.0 so the release does not carry them:
data/README.md CHANGED
@@ -193,6 +193,31 @@ helper returning "the" record would hide exactly those conditions. DKIM is also
193
193
  per-selector and selectors cannot be enumerated, so any convenience method would
194
194
  have to take a selector and would only build the name above.
195
195
 
196
+ ## Configuration
197
+
198
+ Process-wide defaults can be set from code, and take precedence over the
199
+ `DMARCATOR_DNS` environment variables:
200
+
201
+ ```ruby
202
+ DMARCator.configure do |config|
203
+ config.resolver = DMARCator::Resolver::DoH.new(url: "https://dns.example/dns-query")
204
+ end
205
+ ```
206
+
207
+ A resolver object is shared by every thread, and `Resolv::DNS` does not
208
+ serialise concurrent lookups, so threaded applications should configure a
209
+ factory instead:
210
+
211
+ ```ruby
212
+ DMARCator.configure do |config|
213
+ config.resolver = -> { Resolv::DNS.new }
214
+ end
215
+ ```
216
+
217
+ `DMARCator.reset_configuration!` discards configured values, which is useful in
218
+ tests. Passing `resolver:` to a lookup still overrides both the configured
219
+ default and the environment.
220
+
196
221
  ## Strict parsing
197
222
 
198
223
  By default, unknown tags and tags with invalid values are ignored. Pass
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DMARCator
4
+ #
5
+ # Process-wide defaults.
6
+ #
7
+ # @since 0.11.0
8
+ #
9
+ class Config
10
+ #
11
+ # The default resolver used when a lookup is not given one.
12
+ #
13
+ # Either a resolver ({Resolv::DNS}, {Resolver::DoH}, {Resolver::DoT}) or a
14
+ # callable returning one. Prefer a callable in threaded applications: a
15
+ # resolver object is shared by every thread, and `Resolv::DNS` does not
16
+ # serialise concurrent lookups.
17
+ #
18
+ # @return [Object, #call, nil]
19
+ #
20
+ attr_accessor :resolver
21
+ end
22
+
23
+ #
24
+ # The process-wide configuration.
25
+ #
26
+ # @return [Config]
27
+ #
28
+ # @since 0.11.0
29
+ #
30
+ def self.config
31
+ @config ||= Config.new
32
+ end
33
+
34
+ #
35
+ # Configures process-wide defaults.
36
+ #
37
+ # DMARCator.configure do |config|
38
+ # config.resolver = -> { Resolv::DNS.new }
39
+ # end
40
+ #
41
+ # When set, a configured resolver takes precedence over `DMARCATOR_DNS` and
42
+ # is used by {txt}, {txt_records}, {dmarc} and {Record.lookup} whenever no
43
+ # resolver is passed explicitly.
44
+ #
45
+ # @yieldparam [Config] config
46
+ #
47
+ # @return [Config]
48
+ #
49
+ # @since 0.11.0
50
+ #
51
+ def self.configure
52
+ yield config if block_given?
53
+ config
54
+ end
55
+
56
+ #
57
+ # Discards any configured defaults.
58
+ #
59
+ # @return [Config]
60
+ #
61
+ # @since 0.11.0
62
+ #
63
+ def self.reset_configuration!
64
+ @config = Config.new
65
+ end
66
+ end
@@ -3,6 +3,7 @@
3
3
  require 'resolv'
4
4
  require 'rubygems'
5
5
 
6
+ require_relative 'config'
6
7
  require_relative 'resolver'
7
8
 
8
9
  module DMARCator
@@ -125,7 +126,11 @@ module DMARCator
125
126
  end
126
127
 
127
128
  #
128
- # Builds the resolver configured by the environment.
129
+ # The default resolver: a {configure}d one, or one built from the
130
+ # environment.
131
+ #
132
+ # A configured resolver may be an object or a callable; a callable is called
133
+ # for each lookup, which is what threaded applications should use.
129
134
  #
130
135
  # @return [Resolv::DNS, Resolver::DoH, Resolver::DoT]
131
136
  #
@@ -135,7 +140,11 @@ module DMARCator
135
140
  # @since 0.6.0
136
141
  #
137
142
  def self.default_resolver
138
- Resolver.build
143
+ configured = config.resolver
144
+
145
+ return configured.call if configured.respond_to?(:call)
146
+
147
+ configured || Resolver.build
139
148
  end
140
149
 
141
150
  #
@@ -2,5 +2,5 @@
2
2
 
3
3
  module DMARCator
4
4
  # dmarcator version
5
- VERSION = '0.10.0'
5
+ VERSION = '0.11.0'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dmarcator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noah Berman
@@ -69,6 +69,7 @@ files:
69
69
  - LICENSE.txt
70
70
  - README.md
71
71
  - lib/dmarcator.rb
72
+ - lib/dmarcator/config.rb
72
73
  - lib/dmarcator/exceptions.rb
73
74
  - lib/dmarcator/parser.rb
74
75
  - lib/dmarcator/query.rb