package turn
import (
"fmt"
"net"
"strconv"
"github.com/pion/transport/v3"
"github.com/pion/transport/v3/stdnet"
)
type RelayAddressGeneratorNone struct {
Address string
Net transport .Net
}
func (r *RelayAddressGeneratorNone ) Validate () error {
if r .Net == nil {
var err error
r .Net , err = stdnet .NewNet ()
if err != nil {
return fmt .Errorf ("failed to create network: %w" , err )
}
}
switch {
case r .Address == "" :
return errListeningAddressInvalid
default :
return nil
}
}
func (r *RelayAddressGeneratorNone ) AllocatePacketConn (network string , requestedPort int ) (
net .PacketConn ,
net .Addr ,
error ,
) {
conn , err := r .Net .ListenPacket (network , r .Address +":" +strconv .Itoa (requestedPort ))
if err != nil {
return nil , nil , err
}
return conn , conn .LocalAddr (), nil
}
func (r *RelayAddressGeneratorNone ) AllocateConn (string , int ) (net .Conn , net .Addr , error ) {
return nil , nil , errTODO
}
The pages are generated with Golds v0.8.2 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .