Move Plugs.RemoteIP.maybe_add_cidr/1 to InetHelper.parse_cidr/1
This commit is contained in:
parent
06c58bce00
commit
f271ea6e43
2 changed files with 13 additions and 12 deletions
|
|
@ -16,4 +16,15 @@ defmodule Pleroma.Helpers.InetHelper do
|
|||
def parse_address(ip) do
|
||||
:inet.parse_address(ip)
|
||||
end
|
||||
|
||||
def parse_cidr(proxy) when is_binary(proxy) do
|
||||
proxy =
|
||||
cond do
|
||||
"/" in String.codepoints(proxy) -> proxy
|
||||
InetCidr.v4?(InetCidr.parse_address!(proxy)) -> proxy <> "/32"
|
||||
InetCidr.v6?(InetCidr.parse_address!(proxy)) -> proxy <> "/128"
|
||||
end
|
||||
|
||||
InetCidr.parse(proxy, true)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue