GameServerWeb.Plugs.IpBan
(game_server_web v1.0.935)
Copy Markdown
Plug that blocks requests from banned IP addresses.
Ban entries are stored in a dedicated ETS table (:ip_bans). When a ban
exists for the client IP, the request is rejected with 403 Forbidden.
Banning / unbanning an IP
GameServerWeb.Plugs.IpBan.ban("1.2.3.4") # permanent
GameServerWeb.Plugs.IpBan.ban("1.2.3.4", :timer.hours(24)) # 24h ban
GameServerWeb.Plugs.IpBan.unban("1.2.3.4")
GameServerWeb.Plugs.IpBan.banned?("1.2.3.4")
GameServerWeb.Plugs.IpBan.list_bans()This plug runs early in the endpoint pipeline, after RealIp extracts
the true client address.
Summary
Functions
Ban an IP address. Pass ttl_ms for a temporary ban (milliseconds)
or :infinity (default) for a permanent ban.
Check if an IP is currently banned.
Ensure the ETS tables exist (called once at app startup).
List all currently active bans as [{ip, expires_at}].
Return recent ban/unban log entries as a list of maps, newest first.
Remove a ban for the given IP.
Functions
Ban an IP address. Pass ttl_ms for a temporary ban (milliseconds)
or :infinity (default) for a permanent ban.
Check if an IP is currently banned.
Ensure the ETS tables exist (called once at app startup).
List all currently active bans as [{ip, expires_at}].
Return recent ban/unban log entries as a list of maps, newest first.
Each entry: %{action: :ban | :unban, ip: String.t(), ttl: term(), at: DateTime.t()}
Remove a ban for the given IP.