fix(client): Potential channel blocking issue for SCTP endpoints (#962)

fixing channel blocking in client.go

Co-authored-by: TwiN <twin@linux.com>
This commit is contained in:
Zuhair Zaki 2025-01-14 10:30:15 +06:00 committed by GitHub
parent 1ddaf5f3e5
commit 9157b5bf67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -96,16 +96,18 @@ func CanCreateUDPConnection(address string, config *Config) bool {
// CanCreateSCTPConnection checks whether a connection can be established with a SCTP endpoint // CanCreateSCTPConnection checks whether a connection can be established with a SCTP endpoint
func CanCreateSCTPConnection(address string, config *Config) bool { func CanCreateSCTPConnection(address string, config *Config) bool {
ch := make(chan bool) ch := make(chan bool, 1)
go (func(res chan bool) { go (func(res chan bool) {
addr, err := sctp.ResolveSCTPAddr("sctp", address) addr, err := sctp.ResolveSCTPAddr("sctp", address)
if err != nil { if err != nil {
res <- false res <- false
return
} }
conn, err := sctp.DialSCTP("sctp", nil, addr) conn, err := sctp.DialSCTP("sctp", nil, addr)
if err != nil { if err != nil {
res <- false res <- false
return
} }
_ = conn.Close() _ = conn.Close()
res <- true res <- true