Skip to content

Commit

Permalink
Hash ip address (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
lalabuy948 authored Jan 13, 2025
1 parent 6b94e9d commit 52d53f0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/phoenix_analytics/plugs/request_tracker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ defmodule PhoenixAnalytics.Plugs.RequestTracker do

defp generate_uuid, do: Utility.uuid()

defp format_ip({a, b, c, d}), do: "#{a}.#{b}.#{c}.#{d}"
defp format_ip(ip), do: to_string(ip)
defp hash_ip(ip), do: :erlang.phash2(ip, 1_000_000) |> Integer.to_string()

defp format_ip({a, b, c, d}), do: "#{a}.#{b}.#{c}.#{d}" |> hash_ip
defp format_ip(ip), do: to_string(ip) |> hash_ip

defp remote_ip(conn = %Plug.Conn{}) do
remote_ip =
Expand Down

0 comments on commit 52d53f0

Please sign in to comment.