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:
parent
1ddaf5f3e5
commit
9157b5bf67
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user