diff --git a/component/outbound/dialer/connectivity_check.go b/component/outbound/dialer/connectivity_check.go index 46eef9e827..e761ae52ea 100644 --- a/component/outbound/dialer/connectivity_check.go +++ b/component/outbound/dialer/connectivity_check.go @@ -465,6 +465,13 @@ func getActiveDialerCount() int { } func (d *Dialer) aliveBackground() { + // If check_interval is 0 or not configured, skip connectivity check entirely + if d.CheckInterval == 0 { + d.Log.WithField("dialer", d.Property().Name). + Debugln("Connectivity check disabled (check_interval=0)") + return + } + cycle := d.CheckInterval var tcpSomark uint32 var mptcp bool @@ -563,7 +570,28 @@ func (d *Dialer) aliveBackground() { }, CheckFunc: makeDnsCheckFunc(func(o *CheckDnsOption) netip.Addr { return o.Ip6 }, &udpNetwork), } - var CheckOpts = []*CheckOption{tcp4CheckOpt, tcp6CheckOpt, udp4CheckDnsOpt, udp6CheckDnsOpt} + // Build CheckOpts dynamically based on configuration: + // - Only add TCP checks if tcp_check_url is configured + // - Only add UDP DNS checks if udp_check_dns is configured + useTcpCheck := len(d.TcpCheckOptionRaw.Raw) > 0 + useUdpDns := len(d.CheckDnsOptionRaw.Raw) > 0 + + var CheckOpts []*CheckOption + if useTcpCheck { + CheckOpts = append(CheckOpts, tcp4CheckOpt) + CheckOpts = append(CheckOpts, tcp6CheckOpt) + } + if useUdpDns { + CheckOpts = append(CheckOpts, udp4CheckDnsOpt) + CheckOpts = append(CheckOpts, udp6CheckDnsOpt) + } + + // If neither TCP nor UDP checks are configured, return early + if len(CheckOpts) == 0 { + d.Log.WithField("dialer", d.Property().Name). + Debugln("No connectivity checks configured, skipping") + return + } var unusedOnce bool checkUnused := func() bool { diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go index 745b5a925b..6885c5ec5a 100644 --- a/pkg/logger/logger.go +++ b/pkg/logger/logger.go @@ -6,11 +6,23 @@ package logger import ( + "time" + "github.com/sirupsen/logrus" prefixed "github.com/x-cray/logrus-prefixed-formatter" "gopkg.in/natefinch/lumberjack.v2" ) +func init() { + // Always use CST (UTC+8) for log timestamps. + // On minimal OpenWrt/ImmortalWrt without tzdata, fall back to fixed offset. + if loc, err := time.LoadLocation("Asia/Shanghai"); err == nil { + time.Local = loc + } else { + time.Local = time.FixedZone("CST", 8*3600) + } +} + func SetLogger(log *logrus.Logger, logLevel string, disableTimestamp bool, logFileOpt *lumberjack.Logger) { level, err := logrus.ParseLevel(logLevel) if err != nil {