removed unwanted log write

doctor logging per-ip
This commit is contained in:
2026-04-20 13:45:03 +03:00
parent f32ca9f568
commit 98aa31b5f5
3 changed files with 18 additions and 38 deletions
+2 -33
View File
@@ -381,39 +381,8 @@ metric-prefix = "mtg"
[dc] [dc]
dc1 = [ dc1 = [
"149.154.175.59:443", "149.154.175.50:443",
"149.154.175.54:443", "149.154.175.54:443",
"149.154.175.59:443",
"[2001:b28:f23d:f001::a]: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"
]
+13
View File
@@ -50,6 +50,12 @@ var (
tplEDCConnect = template.Must( tplEDCConnect = template.Must(
template.New("").Parse(" ❌ DC {{ .dc }}: {{ .error }}\n"), 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( tplODNSSNIMatch = template.Must(
template.New("").Parse(" ✅ IP address {{ .ip }} matches secret hostname {{ .hostname }}\n"), 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 { for _, addr := range checkAddresses {
conn, err = ntw.DialContext(ctx, "tcp", addr) conn, err = ntw.DialContext(ctx, "tcp", addr)
if err != nil { if err != nil {
tplEDCIPConnect.Execute(os.Stdout, map[string]any{
"error": err,
"ip": addr,
})
continue continue
} }
tplODCIPConnect.Execute(os.Stdout, map[string]any{
"ip": addr,
})
conn.Close() //nolint: errcheck conn.Close() //nolint: errcheck
+3 -5
View File
@@ -2,7 +2,6 @@ package utils
import ( import (
"fmt" "fmt"
"log"
"os" "os"
"github.com/9seconds/mtg/v2/essentials" "github.com/9seconds/mtg/v2/essentials"
@@ -62,20 +61,18 @@ func readCustomDC(cfg *config.Config) {
} }
if len(cfg.DCs.DC10002) > 0 { if len(cfg.DCs.DC10002) > 0 {
var ips []string var ips []string
for _, addr := range cfg.DCs.DC203 { for _, addr := range cfg.DCs.DC10002 {
ips = append(ips, addr.Value) ips = append(ips, addr.Value)
} }
essentials.TelegramCoreAddresses[10002] = ips essentials.TelegramCoreAddresses[10002] = ips
} }
if len(cfg.DCs.DC10003) > 0 { if len(cfg.DCs.DC10003) > 0 {
var ips []string var ips []string
for _, addr := range cfg.DCs.DC203 { for _, addr := range cfg.DCs.DC10003 {
ips = append(ips, addr.Value) ips = append(ips, addr.Value)
} }
essentials.TelegramCoreAddresses[10003] = ips essentials.TelegramCoreAddresses[10003] = ips
} }
log.Println(essentials.TelegramCoreAddresses)
log.Println(cfg.DCs)
} }
func ReadConfig(path string) (*config.Config, error) { func ReadConfig(path string) (*config.Config, error) {
@@ -92,6 +89,7 @@ func ReadConfig(path string) (*config.Config, error) {
if err := conf.Validate(); err != nil { if err := conf.Validate(); err != nil {
return nil, fmt.Errorf("invalid config: %w", err) return nil, fmt.Errorf("invalid config: %w", err)
} }
readCustomDC(conf) readCustomDC(conf)
return conf, nil return conf, nil