Adapter Helper: Use built-in ip address type

This commit is contained in:
rinpatch 2020-06-16 16:20:28 +03:00
parent bf3492ceb3
commit 00926a63fb
1 changed files with 2 additions and 6 deletions

View File

@ -8,12 +8,8 @@ defmodule Pleroma.HTTP.AdapterHelper do
"""
@defaults [pool: :federation]
@type ip_address :: ipv4_address() | ipv6_address()
@type ipv4_address :: {0..255, 0..255, 0..255, 0..255}
@type ipv6_address ::
{0..65_535, 0..65_535, 0..65_535, 0..65_535, 0..65_535, 0..65_535, 0..65_535, 0..65_535}
@type proxy_type() :: :socks4 | :socks5
@type host() :: charlist() | ip_address()
@type host() :: charlist() | :inet.ip_address()
alias Pleroma.Config
alias Pleroma.HTTP.AdapterHelper
@ -114,7 +110,7 @@ def parse_proxy(proxy) when is_tuple(proxy) do
end
end
@spec parse_host(String.t() | atom() | charlist()) :: charlist() | ip_address()
@spec parse_host(String.t() | atom() | charlist()) :: charlist() | :inet.ip_address()
def parse_host(host) when is_list(host), do: host
def parse_host(host) when is_atom(host), do: to_charlist(host)