Skip to content

Commit 2a083f1

Browse files
committed
fix uuid_v4 error for older rubies
1 parent 9bd03f5 commit 2a083f1

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
## [0.0.3]
66

77
- Temporarirlly add `base64` as a direct dependency while waiting for a new release of `dnsruby` in order to fix a warning. See Gemfile for details.
8+
- Fix `undefined method 'uuid_v4' for Random:Class (NoMethodError)` for Ruby 3.0-3.2 when calling `ADAssault::DNS:DUZDU#checkv4` like in CLI sub-command `ada dns duzdu check`.
89

910
## [0.0.2]
1011

lib/adassault/dns/duzdu.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ def deletev4(name)
102102
def checkv4
103103
networks = ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16'].map { |x| IPAddr.new(x) }
104104
network = networks.sample
105-
name = Random.uuid_v4
105+
begin
106+
name = Random.uuid_v4 # Ruby 3.3+
107+
rescue NoMethodError
108+
# see https://github.com/ruby/securerandom/issues/31
109+
name = Random.uuid # Ruby 3.2-
110+
end
106111
ip = IPAddr.new(rand(network.to_range.begin.succ.to_i..network.to_range.end.to_i - 1), network.family)
107112
created = addv4(name, ip)
108113
# if created

0 commit comments

Comments
 (0)