Close turn connection

Without it the WG can not exit from the read loop
This commit is contained in:
Zoltán Papp
2024-04-18 15:59:50 +02:00
parent b5c4802bb9
commit b68a02acee
5 changed files with 19 additions and 3 deletions

View File

@@ -87,6 +87,20 @@ func (r *PermanentTurn) RelayConn() net.PacketConn {
return r.relayConn
}
func (r *PermanentTurn) Close() {
r.turnClient.Close()
err := r.relayConn.Close()
if err != nil {
log.Errorf("failed to close relayConn: %s", err.Error())
}
err = r.stunConn.Close()
if err != nil {
log.Errorf("failed to close stunConn: %s", err.Error())
}
}
func (r *PermanentTurn) discoverPublicIP() (*net.UDPAddr, error) {
addr, err := r.turnClient.SendBindingRequest()
if err != nil {