Sha256: e3e23b187b1be603220b97ba8596c0efbd086f6421d3312aca892c47ded6a111
Contents?: true
Size: 746 Bytes
Versions: 11
Compression:
Stored size: 746 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 StandardError 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
11 entries across 11 versions & 1 rubygems