From 6bcf81b0ab5fcd2d1743b4b3247e062a9730243a Mon Sep 17 00:00:00 2001 From: null Date: Thu, 8 Oct 2026 20:38:06 +0800 Subject: [PATCH] fix logic --- transport/internet/hysteria/dialer.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/transport/internet/hysteria/dialer.go b/transport/internet/hysteria/dialer.go index 29b8a5d18..ddf0e018c 100644 --- a/transport/internet/hysteria/dialer.go +++ b/transport/internet/hysteria/dialer.go @@ -30,6 +30,7 @@ type client struct { sync.Mutex instance *core.Instance + isremoved func() bool dest net.Destination config *Config tlsConfig *gotls.Config @@ -73,6 +74,10 @@ func (c *client) dial(ctx context.Context) error { return errors.New("client is closed") } + if c.isremoved() { + return errors.New("conn is removed") + } + switch c.status() { case StatusActive: return nil @@ -270,7 +275,7 @@ func (c *client) clean() bool { if c.status() == StatusInactive { c.close() } - return c.status() == StatusNull + return c.instance != nil && !c.instance.IsRunning() } type dialerConf struct { @@ -328,7 +333,12 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me c = manager.m[dialerConfKey] if c == nil { c = &client{ - instance: core.FromContext(ctx), + instance: core.FromContext(ctx), + isremoved: func() bool { + manager.Lock() + defer manager.Unlock() + return manager.m[dialerConfKey] == nil + }, dest: dest, config: streamSettings.ProtocolSettings.(*Config), tlsConfig: tlsConfig.GetTLSConfig(tls.WithDestination(dest)),