From 29781c8d879243b020d52af1e1da50efd71ff90e Mon Sep 17 00:00:00 2001 From: Xavier Demompion Date: Fri, 26 Jan 2024 17:57:11 +0100 Subject: [PATCH] Fix router introspection on big projects. --- CHANGELOG.md | 4 ++++ lib/phoenix_ddos/core/configure.ex | 4 ++-- mix.exs | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2224f7d..9f79a25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # PhoenixDDoS changelog +## 1.1.19 + +- fix: phoenix router instropection too slow on big projects + ## 1.1.18 - fix: phoenix router instropection fail on module Hex.API diff --git a/lib/phoenix_ddos/core/configure.ex b/lib/phoenix_ddos/core/configure.ex index c22bca1..e70b5c4 100644 --- a/lib/phoenix_ddos/core/configure.ex +++ b/lib/phoenix_ddos/core/configure.ex @@ -130,8 +130,8 @@ defmodule PhoenixDDoS.Configure do end def phoenix_router?(module) when is_atom(module) do - case Code.ensure_loaded(module) do - {:module, module} -> function_exported?(module, :__routes__, 0) + case module |> inspect() |> String.contains?("Router") && Code.ensure_loaded?(module) do + true -> function_exported?(module, :__routes__, 0) _ -> false end end diff --git a/mix.exs b/mix.exs index 36f6a85..938d152 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule PhoenixDDoS.MixProject do use Mix.Project - @version "1.1.18" + @version "1.1.19" @source_url "https://github.com/xward/phoenix_ddos" def project do