fix(stunreachability): avoid goroutine spin and memleak (#255)

This fix addresses the bug described in issue https://github.com/ooni/probe/issues/1403.
This commit is contained in:
Simone Basso 2021-03-15 10:59:28 +01:00 committed by GitHub
parent a02052fb0c
commit c324822870
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -122,15 +122,15 @@ func (tk *TestKeys) do(
if err != nil {
return err
}
defer conn.Close()
newClient := stun.NewClient
if config.newClient != nil {
newClient = config.newClient
}
client, err := newClient(conn, stun.WithNoConnClose)
client, err := newClient(conn)
if err != nil {
return err
}
defer client.Close()
message := stun.MustBuild(stun.TransactionID, stun.BindingRequest)
ch := make(chan error)
err = client.Start(message, func(ev stun.Event) {