feat(utils): implement MagicDNS suffix handling and normalization for dst_addr

- Added support for extracting and setting MagicDNS suffix.
- Normalized `dst_addr` using the MagicDNS suffix to simplify configuration.
- Improved logging for normalized and failed addresses during `connect` rule processing.
This commit is contained in:
nullcat
2026-06-01 16:07:23 +08:00
parent a9828b4461
commit e60a6b76c7
4 changed files with 110 additions and 184 deletions
+8
View File
@@ -53,6 +53,14 @@ func InitTsNet(ctx context.Context, cfg *Core, logger *slog.Logger, withDebugLog
logger.With(slog.String("ip", ip.String())).Info("ip got from tsnet")
}
rawSuffix, err := GetMagicDNSSuffixFromStatus(status)
if err != nil {
logger.Debug("failed to extract MagicDNS suffix", slog.String("error", err.Error()))
} else {
SetMagicDNSSuffix(rawSuffix)
logger.Info("MagicDNS suffix extracted", slog.String("suffix", rawSuffix))
}
if cfg.AcceptRoutes {
lc, err := srv.LocalClient()
if err != nil {