From 98aa31b5f5f6a98c4f1d1cd3d46e81f660e56615 Mon Sep 17 00:00:00 2001 From: ScuroNeko Date: Mon, 20 Apr 2026 13:45:03 +0300 Subject: [PATCH] removed unwanted log write doctor logging per-ip --- example.config.toml | 35 ++--------------------------------- internal/cli/doctor.go | 13 +++++++++++++ internal/utils/read_config.go | 8 +++----- 3 files changed, 18 insertions(+), 38 deletions(-) diff --git a/example.config.toml b/example.config.toml index 64020a3..52ebe90 100644 --- a/example.config.toml +++ b/example.config.toml @@ -381,39 +381,8 @@ metric-prefix = "mtg" [dc] dc1 = [ - "149.154.175.59:443", + "149.154.175.50:443", "149.154.175.54:443", + "149.154.175.59:443", "[2001:b28:f23d:f001::a]:443" -] -dc2 = [ - "149.154.167.41:443", - "149.154.167.151:443", - "[2001:67c:4e8:f002::a]:443", - "[2001:67c:4e8:f002::b]:443" -] -dc3 = [ - "149.154.175.100:443", - "[2001:b28:f23d:f003::a]:443" -] -dc4 = [ - "149.154.167.92:443", - "149.154.165.111:443", - "[2001:67c:4e8:f004::a]:443", - "[2001:67c:4e8:f004::b]:443" -] -dc5 = [ - "91.108.56.115:443", - "[2001:b28:f23f:f005::a]:443" -] -dc10001 = [ - "149.154.175.10:443", - "[2001:b28:f23d:f001::e]:443" -] -dc10002 = [ - "149.154.167.40:443", - "[2001:67c:4e8:f002::e]:443" -] -dc10003 = [ - "149.154.175.117:443", - "[2001:b28:f23d:f003::e]:443" ] \ No newline at end of file diff --git a/internal/cli/doctor.go b/internal/cli/doctor.go index 48563bc..e11d7b0 100644 --- a/internal/cli/doctor.go +++ b/internal/cli/doctor.go @@ -50,6 +50,12 @@ var ( tplEDCConnect = template.Must( template.New("").Parse(" ❌ DC {{ .dc }}: {{ .error }}\n"), ) + tplODCIPConnect = template.Must( + template.New("").Parse(" ✅ {{ .ip }}\n"), + ) + tplEDCIPConnect = template.Must( + template.New("").Parse(" ❌ {{ .ip }}: {{ .error }}\n"), + ) tplODNSSNIMatch = template.Must( template.New("").Parse(" ✅ IP address {{ .ip }} matches secret hostname {{ .hostname }}\n"), @@ -285,8 +291,15 @@ func (d *Doctor) checkNetworkAddresses(ntw mtglib.Network, addresses []string) e for _, addr := range checkAddresses { conn, err = ntw.DialContext(ctx, "tcp", addr) if err != nil { + tplEDCIPConnect.Execute(os.Stdout, map[string]any{ + "error": err, + "ip": addr, + }) continue } + tplODCIPConnect.Execute(os.Stdout, map[string]any{ + "ip": addr, + }) conn.Close() //nolint: errcheck diff --git a/internal/utils/read_config.go b/internal/utils/read_config.go index 7199319..9eb11f2 100644 --- a/internal/utils/read_config.go +++ b/internal/utils/read_config.go @@ -2,7 +2,6 @@ package utils import ( "fmt" - "log" "os" "github.com/9seconds/mtg/v2/essentials" @@ -62,20 +61,18 @@ func readCustomDC(cfg *config.Config) { } if len(cfg.DCs.DC10002) > 0 { var ips []string - for _, addr := range cfg.DCs.DC203 { + for _, addr := range cfg.DCs.DC10002 { ips = append(ips, addr.Value) } essentials.TelegramCoreAddresses[10002] = ips } if len(cfg.DCs.DC10003) > 0 { var ips []string - for _, addr := range cfg.DCs.DC203 { + for _, addr := range cfg.DCs.DC10003 { ips = append(ips, addr.Value) } essentials.TelegramCoreAddresses[10003] = ips } - log.Println(essentials.TelegramCoreAddresses) - log.Println(cfg.DCs) } func ReadConfig(path string) (*config.Config, error) { @@ -92,6 +89,7 @@ func ReadConfig(path string) (*config.Config, error) { if err := conf.Validate(); err != nil { return nil, fmt.Errorf("invalid config: %w", err) } + readCustomDC(conf) return conf, nil