EpochtalkServer.Models.BannedAddress (epochtalk_server v0.1.0)

BannedAddress model, for performing actions relating to banning by ip/hostname

Link to this section Summary

Functions

Calculates the malicious score of the provided IP address, float score is returned if IP/Hostname are malicious, otherwise nil

Creates changeset of BannedAddress model with hostname information

Creates changeset of BannedAddress model with IP information

Upserts a BannedAddress into the database and handles calculation of weight accounting for decay

Creates changeset for upsert of BannedAddress model

Link to this section Types

@type t() :: %EpochtalkServer.Models.BannedAddress{
  __meta__: term(),
  created_at: NaiveDateTime.t() | nil,
  decay: boolean() | nil,
  hostname: String.t() | nil,
  imported_at: NaiveDateTime.t() | nil,
  ip1: non_neg_integer() | nil,
  ip2: non_neg_integer() | nil,
  ip3: non_neg_integer() | nil,
  ip4: non_neg_integer() | nil,
  updates: [NaiveDateTime.t()] | nil,
  weight: float() | nil
}

Link to this section Functions

Link to this function

calculate_malicious_score_from_ip(ip)

@spec calculate_malicious_score_from_ip(ip_address :: String.t()) :: float() | nil

Calculates the malicious score of the provided IP address, float score is returned if IP/Hostname are malicious, otherwise nil

Link to this function

hostname_changeset(banned_address, attrs \\ %{})

@spec hostname_changeset(banned_address :: t(), attrs :: map() | nil) ::
  Ecto.Changeset.t()

Creates changeset of BannedAddress model with hostname information

Link to this function

ip_changeset(banned_address, attrs \\ %{})

@spec ip_changeset(banned_address :: t(), attrs :: map() | nil) :: Ecto.Changeset.t()

Creates changeset of BannedAddress model with IP information

Link to this function

upsert(address_list)

@spec upsert(banned_address_or_list :: map() | [map()] | t() | [t()]) ::
  {:ok, banned_address_changeset :: Ecto.Changeset.t()}
  | {:error, :banned_address_error}

Upserts a BannedAddress into the database and handles calculation of weight accounting for decay

Link to this function

upsert_changeset(banned_address, attrs \\ %{})

@spec upsert_changeset(banned_address :: t(), attrs :: map() | nil) ::
  Ecto.Changeset.t()

Creates changeset for upsert of BannedAddress model