From 803a7a700297bde6c65863dcf39701a75521541c Mon Sep 17 00:00:00 2001 From: QianEric <307361214+qianeric-backup@users.noreply.github.com> Date: Thu, 29 Oct 2026 22:59:05 +0800 Subject: [PATCH] fix(dns): set the log level on the Console logger, not on the Console module Server#initialize called `logger.level = Logger::ERROR`. `logger` here is Async::DNS::Server#logger, which is a deprecated shim that returns the Console module itself: # @deprecated Use {Console} instead. def logger Console end The Console module has no `level=` method, so constructing the singleton raised `NoMethodError: undefined method 'level=' for module Console`. The REST layer builds that singleton in a `before` filter, so every `/api/dns/*` request answered 500 and the extension was unusable. The logger instance that does accept a level is the one behind `Console.logger`: - `Console.logger` returns the current logger (Console::Interface), a Console::Logger instance. - Console::Logger is built as `Filter[debug: 0, info: 1, warn: 2, error: 3, fatal: 4]`, so `Console::Logger::ERROR` resolves to 3. - Filter defines `level=`, accepting either a Symbol or an Integer. No behaviour changes beyond the logging call: the level is still ERROR, it is just applied to an object that has the writer. I could not execute the extension here (no Ruby toolchain in my environment), so this is verified against the sources of the locked versions rather than at run time: async-dns 1.4.1 for #logger and console 1.34.0 for the logger/level API, both as pinned in Gemfile.lock. This addresses Bug 1 of #3680 only. Bug 2 (the nameserver never binding, because run/stop still assume an EventMachine reactor) is a structural change that needs an Async reactor and a way to exercise it, and I would rather not bundle it with a one-line fix. Refs #3680 --- extensions/dns/dns.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions/dns/dns.rb b/extensions/dns/dns.rb index 9a0d0f7fd5..4672a4f2e0 100644 --- a/extensions/dns/dns.rb +++ b/extensions/dns/dns.rb @@ -15,7 +15,10 @@ class Server < Async::DNS::Server def initialize super() - logger.level = Logger::ERROR + # Async::DNS::Server#logger returns the Console module itself, which + # has no level= method. The per-instance logger behind Console is the + # one that accepts a level. + Console.logger.level = Console::Logger::ERROR @lock = Mutex.new @database = BeEF::Core::Models::Dns::Rule @data_chunks = {}