mirror of
https://github.com/MetaCubeX/Clash.Meta.git
synced 2025-04-20 01:00:56 +00:00
delay close client
This commit is contained in:
parent
29ac82e320
commit
df8d1c0161
1 changed files with 7 additions and 1 deletions
|
@ -77,7 +77,7 @@ func (h *Hysteria2) DialContext(ctx context.Context, metadata *C.Metadata, opts
|
|||
|
||||
client, err := hysteria2.NewClient(*h.clientOptions)
|
||||
if err == nil {
|
||||
h.client.CloseWithError(closedForPortHopping)
|
||||
runtime.SetFinalizer(client, closeHysteria2Client)
|
||||
h.client = client
|
||||
h.addr = net.JoinHostPort(h.option.Server, strconv.Itoa(int(h.option.Port)))
|
||||
log.Infoln("[%s] hopped to port %d", h.name, h.option.Port)
|
||||
|
@ -115,6 +115,12 @@ func closeHysteria2(h *Hysteria2) {
|
|||
}
|
||||
}
|
||||
|
||||
func closeHysteria2Client(c *hysteria2.Client) {
|
||||
if c != nil {
|
||||
c.CloseWithError(closedForPortHopping)
|
||||
}
|
||||
}
|
||||
|
||||
func NewHysteria2(option Hysteria2Option) (*Hysteria2, error) {
|
||||
var ports []uint16
|
||||
if option.Ports != "" {
|
||||
|
|
Loading…
Add table
Reference in a new issue