summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2026-01-26 17:29:04 +0700
committerShulhan <ms@kilabit.info>2026-02-02 16:28:11 +0700
commit85b44587e111fb92722f436ebf9dddbb68556895 (patch)
tree00571227402be8f6e55941bcde01ca46d048a1e4
parent69ccba6797c5e74957759427654f8e11a2e9d09b (diff)
downloadpakakeh.go-85b44587e111fb92722f436ebf9dddbb68556895.tar.xz
lib/dns: remove DebugLevelDNS
The DebugLevelDNS log the error on DNS level, for example empty answer, error on name, class not implemented, refused; which is now on by default.
-rw-r--r--CHANGELOG.adoc6
-rw-r--r--lib/dns/server.go4
-rw-r--r--lib/dns/server_options.go18
3 files changed, 13 insertions, 15 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index 805fd45f..dc6d0ccb 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -38,6 +38,12 @@ Legend,
[#v0_61_0]
== pakakeh.go v0.61.0 (2026-xx-xx)
+**🌼 lib/dns: remove DebugLevelDNS**
+
+The DebugLevelDNS log the error on DNS level, for example empty answer,
+error on name, class not implemented, refused; which is now on by
+default.
+
**🌼 lib/dns: add option to set hook on server when receiving answer**
The hook function, OnAnswerReceived, will be triggered when server
diff --git a/lib/dns/server.go b/lib/dns/server.go
index f834a38b..e4dcbac5 100644
--- a/lib/dns/server.go
+++ b/lib/dns/server.go
@@ -557,9 +557,7 @@ func (srv *Server) serveTCPClient(logp string, cl *TCPClient, kind string) {
func (srv *Server) isImplemented(msg *Message) bool {
switch msg.Question.Class {
case RecordClassCH, RecordClassHS:
- if srv.opts.Debug&DebugLevelDNS != 0 {
- log.Printf(`dns: class %d is not implemented`, msg.Question.Class)
- }
+ log.Printf(`dns: class %d is not implemented`, msg.Question.Class)
return false
}
diff --git a/lib/dns/server_options.go b/lib/dns/server_options.go
index 9c042b5a..d53b1abd 100644
--- a/lib/dns/server_options.go
+++ b/lib/dns/server_options.go
@@ -14,21 +14,15 @@ import (
libnet "git.sr.ht/~shulhan/pakakeh.go/lib/net"
)
-// List of [ServerOptions] Debug mode.
-// For example, to log DNS error and cache operations, set the Debug value
-// to 3 or (DebugLevelDNS|DebugLevelCache).
+// List of [ServerOptions.Debug] mode.
const (
- // Log error on DNS level, in example EMPTY answer, ERR_NAME,
- // ERR_NOT_IMPLEMENTED, ERR_REFUSED.
- DebugLevelDNS = 1
-
- // Log cache operations, including new record, updating records,
- // and pruning record in caches.
- DebugLevelCache = 2
+ // Log cache operations, including insert, update, and deleting
+ // record into/from caches.
+ DebugLevelCache = 1
// Log low level DNS connection and packet, including request and
// response.
- DebugLevelConnPacket = 4
+ DebugLevelConnPacket = 2
)
// HookFunc define type function that will be triggered on specific event.
@@ -109,7 +103,7 @@ type ServerOptions struct {
// accessed in the last 1 minute will be removed from cache.
PruneThreshold time.Duration `ini:"dns:server:cache.prune_threshold"`
- // Debug level for server, accept value [DebugLevelDNS],
+ // Debug level for server, accept value
// [DebugLevelCache], [DebugLevelConnPacket], or any combination of
// it.
Debug int `ini:"dns:server:debug"`