Sha256: e4df04373fb2ea0f00d918618da4642f49287cf1b3bc32525c89329b433ac000

Contents?: true

Size: 967 Bytes

Versions: 18

Compression:

Stored size: 967 Bytes

Contents

module OverSIP::SIP

  module Tags

    PREFIX_FOR_TOTAG_SL_REPLIED = ::SecureRandom.hex(4) + "."
    REGEX_PREFIX_FOR_TOTAG_SL_REPLIED = /^#{PREFIX_FOR_TOTAG_SL_REPLIED}/

    ROUTE_OVID_VALUE = ::SecureRandom.hex(4)
    ROUTE_OVID_VALUE_HASH = ROUTE_OVID_VALUE.hash

    ANTILOOP_CONST = ::SecureRandom.hex(1)


    def self.totag_for_sl_reply
      PREFIX_FOR_TOTAG_SL_REPLIED + ::SecureRandom.hex(4)
    end

    def self.check_totag_for_sl_reply totag
      return nil unless totag
      totag =~ REGEX_PREFIX_FOR_TOTAG_SL_REPLIED
    end

    def self.value_for_route_ovid
      ROUTE_OVID_VALUE
    end

    def self.check_value_for_route_ovid value
      return nil unless value
      value.hash == ROUTE_OVID_VALUE_HASH
    end

    def self.create_antiloop_id request
      # It produces a 32 chars string.
      ::Digest::MD5.hexdigest "#{ANTILOOP_CONST}#{request.ruri.to_s}#{request.call_id}#{request.routes[0].uri if request.routes}"
    end

  end

end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
oversip_p-1.0.2 lib/oversip/sip/tags.rb
oversip_p-1.0.0 lib/oversip/sip/tags.rb
oversip-2.0.4 lib/oversip/sip/tags.rb
oversip-2.0.3 lib/oversip/sip/tags.rb
oversip-2.0.2 lib/oversip/sip/tags.rb
oversip-2.0.1 lib/oversip/sip/tags.rb
oversip-2.0.0 lib/oversip/sip/tags.rb
oversip-1.4.1 lib/oversip/sip/tags.rb
oversip-1.4.0 lib/oversip/sip/tags.rb
oversip-1.3.8 lib/oversip/sip/tags.rb
oversip-1.3.7 lib/oversip/sip/tags.rb
oversip-1.3.6 lib/oversip/sip/tags.rb
oversip-1.3.5 lib/oversip/sip/tags.rb
oversip-1.3.3 lib/oversip/sip/tags.rb
oversip-1.3.2 lib/oversip/sip/tags.rb
oversip-1.3.1 lib/oversip/sip/tags.rb
oversip-1.3.0 lib/oversip/sip/tags.rb
oversip-1.3.0.dev1 lib/oversip/sip/tags.rb