Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion component/outbound/dialer/connectivity_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
12 changes: 12 additions & 0 deletions pkg/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down