From 9897b5a9d3813e366333b15703256ec219209fb8 Mon Sep 17 00:00:00 2001 From: null Date: Thu, 8 Oct 2026 21:12:51 +0800 Subject: [PATCH] refine logic --- transport/internet/hysteria/dialer.go | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/transport/internet/hysteria/dialer.go b/transport/internet/hysteria/dialer.go index ddf0e018c..036bdba78 100644 --- a/transport/internet/hysteria/dialer.go +++ b/transport/internet/hysteria/dialer.go @@ -30,7 +30,7 @@ type client struct { sync.Mutex instance *core.Instance - isremoved func() bool + isRemoved func() bool dest net.Destination config *Config tlsConfig *gotls.Config @@ -70,14 +70,10 @@ func (c *client) close() { } func (c *client) dial(ctx context.Context) error { - if c.instance != nil && !c.instance.IsRunning() { + if c.isRemoved() { return errors.New("client is closed") } - if c.isremoved() { - return errors.New("conn is removed") - } - switch c.status() { case StatusActive: return nil @@ -103,7 +99,7 @@ func (c *client) dial(ctx context.Context) error { ChromeParrot: !quicParams.DisableChromeParrot, EnableDatagrams: true, MaxDatagramFrameSize: MaxDatagramFrameSize, - OmitMaxDatagramFrameSize: time.Now().After(time.Date(2026, 9, 1, 0, 0, 0, 0, time.UTC)), + OmitMaxDatagramFrameSize: true, DisablePathManager: true, } if quicParams.InitStreamReceiveWindow == 0 { @@ -333,12 +329,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me c = manager.m[dialerConfKey] if c == nil { c = &client{ - instance: core.FromContext(ctx), - isremoved: func() bool { - manager.Lock() - defer manager.Unlock() - return manager.m[dialerConfKey] == nil - }, + instance: core.FromContext(ctx), dest: dest, config: streamSettings.ProtocolSettings.(*Config), tlsConfig: tlsConfig.GetTLSConfig(tls.WithDestination(dest)), @@ -346,6 +337,11 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me finalMask: streamSettings.FinalMask, quicParams: streamSettings.QuicParams, } + c.isRemoved = func() bool { + manager.RLock() + defer manager.RUnlock() + return manager.m[dialerConfKey] != c + } manager.m[dialerConfKey] = c } manager.Unlock()