-
-
Notifications
You must be signed in to change notification settings - Fork 733
Expand file tree
/
Copy pathnone.go
More file actions
32 lines (24 loc) · 801 Bytes
/
Copy pathnone.go
File metadata and controls
32 lines (24 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package turn
import (
"errors"
"fmt"
"net"
"github.com/pion/turn/v5"
)
type RelayAddressGeneratorNone struct{}
func (r *RelayAddressGeneratorNone) Validate() error {
return nil
}
func (r *RelayAddressGeneratorNone) AllocatePacketConn(conf turn.AllocateListenerConfig) (net.PacketConn, net.Addr, error) {
conn, err := net.ListenPacket("udp", fmt.Sprintf(":%d", conf.RequestedPort))
if err != nil {
return nil, nil, err
}
return conn, conn.LocalAddr(), nil
}
func (r *RelayAddressGeneratorNone) AllocateListener(_ turn.AllocateListenerConfig) (net.Listener, net.Addr, error) {
return nil, nil, errors.New("TCP relay not supported")
}
func (r *RelayAddressGeneratorNone) AllocateConn(_ turn.AllocateConnConfig) (net.Conn, error) {
return nil, errors.New("TCP relay not supported")
}