Sha256: e95f21b6075e9f3e44e7f301a25df60bee5256108d581c922f8a570df44ed64a
Contents?: true
Size: 775 Bytes
Versions: 10
Compression:
Stored size: 775 Bytes
Contents
module Rollbar module Util module IPAnonymizer require 'ipaddr' def self.anonymize_ip(ip_string) return ip_string unless Rollbar.configuration.anonymize_user_ip ip = IPAddr.new(ip_string) return anonymize_ipv6 ip if ip.ipv6? return anonymize_ipv4 ip if ip.ipv4? rescue nil end def self.anonymize_ipv4(ip) ip_parts = ip.to_s.split '.' ip_parts[ip_parts.count - 1] = '0' IPAddr.new(ip_parts.join('.')).to_s end def self.anonymize_ipv6(ip) ip_parts = ip.to_s.split ':' ip_string = ip_parts[0..2].join(':') + ':0000:0000:0000:0000:0000' IPAddr.new(ip_string).to_s end end end end
Version data entries
10 entries across 10 versions & 1 rubygems