diff --git a/lib/blather.rb b/lib/blather.rb index 355e19cf..e4045307 100644 --- a/lib/blather.rb +++ b/lib/blather.rb @@ -8,6 +8,7 @@ digest/sha1 logger openssl + securerandom active_support/core_ext/class/attribute active_support/core_ext/object/blank diff --git a/lib/blather/stanza.rb b/lib/blather/stanza.rb index 06bf422e..394f0a36 100644 --- a/lib/blather/stanza.rb +++ b/lib/blather/stanza.rb @@ -11,6 +11,8 @@ class Stanza < XMPPNode @@last_id = 0 # @private @@handler_list = [] + # @private + @@id_base = SecureRandom.hex(8) class_attribute :handler_hierarchy attr_writer :handler_hierarchy @@ -52,7 +54,7 @@ def self.handler_list # @return [String] a new unique ID def self.next_id @@last_id += 1 - 'blather%04x' % @@last_id + '%s%04x' % [@@id_base, @@last_id] end # Check if the stanza is an error stanza