mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-20 06:37:59 +01:00
mask ip6 spec to /64
This commit is contained in:
parent
38c4e35bb7
commit
dfaee1e34d
1 changed files with 16 additions and 0 deletions
|
@ -34,5 +34,21 @@ defmodule Philomena.Bans.Subnet do
|
||||||
|> assign_time(:until, :valid_until)
|
|> assign_time(:until, :valid_until)
|
||||||
|> put_ban_id("S")
|
|> put_ban_id("S")
|
||||||
|> validate_required([:reason, :enabled, :specification, :valid_until])
|
|> validate_required([:reason, :enabled, :specification, :valid_until])
|
||||||
|
|> mask_specification()
|
||||||
|
end
|
||||||
|
|
||||||
|
defp mask_specification(changeset) do
|
||||||
|
specification =
|
||||||
|
changeset
|
||||||
|
|> get_field(:specification)
|
||||||
|
|> case do
|
||||||
|
%Postgrex.INET{address: {h1, h2, h3, h4, h5, h6, h7, h8}, netmask: 128} ->
|
||||||
|
%Postgrex.INET{address: {h1, h2, h3, h4, 0, 0, 0, 0}, netmask: 64}
|
||||||
|
|
||||||
|
val ->
|
||||||
|
val
|
||||||
|
end
|
||||||
|
|
||||||
|
put_change(changeset, :specification, specification)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue