mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-10-08 16:50:07 +00:00
fix logic
This commit is contained in:
@@ -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)),
|
||||
|
||||
Reference in New Issue
Block a user