chore: better tuic conn close

This commit is contained in:
wwqgtxx
2022-11-25 11:32:05 +08:00
parent cce42b4b83
commit d47ce79a24
2 changed files with 26 additions and 11 deletions

View File

@ -9,6 +9,7 @@ import (
"fmt"
"net"
"os"
"runtime"
"strconv"
"sync"
"time"
@ -199,6 +200,7 @@ func NewTuic(option TuicOption) (*Tuic, error) {
RequestTimeout: option.RequestTimeout,
}
clientMap[o] = client
runtime.SetFinalizer(client, closeTuicClient)
return client
}
@ -214,3 +216,7 @@ func NewTuic(option TuicOption) (*Tuic, error) {
getClient: getClient,
}, nil
}
func closeTuicClient(client *tuic.Client) {
client.Close(nil)
}