Compare commits

...

2 Commits

Author SHA1 Message Date
世界
83238d6a81
Fix time service wrapper 2025-07-23 18:23:07 +08:00
dyhkwong
51e4330b8c
Fix disable_sni nil time func 2025-07-23 17:51:39 +08:00
2 changed files with 9 additions and 4 deletions

View File

@ -87,13 +87,15 @@ func NewSTDClient(ctx context.Context, serverAddress string, options option.Outb
tlsConfig.VerifyConnection = func(state tls.ConnectionState) error {
verifyOptions := x509.VerifyOptions{
Roots: tlsConfig.RootCAs,
CurrentTime: tlsConfig.Time(),
DNSName: serverName,
Intermediates: x509.NewCertPool(),
}
for _, cert := range state.PeerCertificates[1:] {
verifyOptions.Intermediates.AddCert(cert)
}
if tlsConfig.Time != nil {
verifyOptions.CurrentTime = tlsConfig.Time()
}
_, err := state.PeerCertificates[0].Verify(verifyOptions)
return err
}

View File

@ -11,10 +11,13 @@ type TimeServiceWrapper struct {
}
func (w *TimeServiceWrapper) TimeFunc() func() time.Time {
if w.TimeService == nil {
return nil
return func() time.Time {
if w.TimeService != nil {
return w.TimeService.TimeFunc()()
} else {
return time.Now()
}
}
return w.TimeService.TimeFunc()
}
func (w *TimeServiceWrapper) Upstream() any {