Skip to Content
⚠ Under Construction
ReferenceC++ APIIpBanList

endstone::IpBanList

Represents a ban list, containing banned IP addresses.

Bases: endstone::BanList< IpBanEntry >

Functions:

NameDescription
addBanAdds a ban to this list. If a previous ban exists, this will update the previous entry.
addBanAdds a ban to this list. If a previous ban exists, this will update the previous entry.
getBanEntryGets a BanEntry by IP address.
getBanEntryGets a BanEntry by IP address.
getEntriesGets a vector containing pointers to every BanEntry in this list.
getEntriesGets a vector containing pointers to every BanEntry in this list.
isBannedChecks if a BanEntry exists for the target, indicating an active ban status.
removeBanRemoves the specified IP address from this list, therefore indicating a “not banned” status.

addBan

IpBanEntry &addBan(std::string address, std::optional<std::string> reason, std::optional<BanEntry::Date> expires, std::optional<std::string> source) override

Adds a ban to this list. If a previous ban exists, this will update the previous entry.

Parameters:

  • address The IP address of the target.
  • reason The reason for the ban, std::nullopt indicates implementation default.
  • expires The date for the ban’s expiration (unban), or std::nullopt to imply forever.
  • source The source of the ban, std::nullopt indicates implementation default.

Returns:

IpBanEntry& The entry for the newly created ban, or the entry for the (updated) previous ban.

IpBanEntry &addBan(std::string address, std::optional<std::string> reason, std::chrono::seconds duration, std::optional<std::string> source) override

Adds a ban to this list. If a previous ban exists, this will update the previous entry.

Parameters:

  • address The IP address of the target.
  • reason The reason for the ban, std::nullopt indicates implementation default.
  • duration The duration of the ban
  • source The source of the ban, std::nullopt indicates implementation default.

Returns:

IpBanEntry& The entry for the newly created ban, or the entry for the (updated) previous ban.

getBanEntry

const IpBanEntry *getBanEntry(std::string address) override const

Gets a BanEntry by IP address.

Parameters:

  • address The IP address to search for.

Returns:

IpBanEntry* The corresponding entry, or nullptr if none found.

IpBanEntry *getBanEntry(std::string address) override

Gets a BanEntry by IP address.

Parameters:

  • address The IP address to search for.

Returns:

IpBanEntry* The corresponding entry, or nullptr if none found.

getEntries

std::vector<const IpBanEntry *> getEntries() override const

Gets a vector containing pointers to every BanEntry in this list.

Returns:

A vector containing pointers to every entry tracked by this list.

std::vector<IpBanEntry *> getEntries() override

Gets a vector containing pointers to every BanEntry in this list.

Returns:

A vector containing pointers to every entry tracked by this list.

isBanned

bool isBanned(std::string address) override const

Checks if a BanEntry exists for the target, indicating an active ban status.

Parameters:

  • address The IP address to find.

Returns:

true If a BanEntry exists for the target, indicating an active ban status.

Returns:

false Otherwise.

removeBan

void removeBan(std::string address) override

Removes the specified IP address from this list, therefore indicating a “not banned” status.

Parameters:

  • address The IP address to remove from this list.
Last updated on