mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-23 10:07:30 +00:00
36 lines
914 B
Go
36 lines
914 B
Go
package ice
|
|
|
|
import "net"
|
|
|
|
// CandidateServerReflexive ...
|
|
type CandidateServerReflexive struct {
|
|
candidateBase
|
|
}
|
|
|
|
// NewCandidateServerReflexive creates a new server reflective candidate
|
|
func NewCandidateServerReflexive(network string, address string, port int, component uint16, relAddr string, relPort int) (*CandidateServerReflexive, error) {
|
|
ip := net.ParseIP(address)
|
|
if ip == nil {
|
|
return nil, ErrAddressParseFailed
|
|
}
|
|
|
|
networkType, err := determineNetworkType(network, ip)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &CandidateServerReflexive{
|
|
candidateBase: candidateBase{
|
|
networkType: networkType,
|
|
candidateType: CandidateTypeServerReflexive,
|
|
address: address,
|
|
port: port,
|
|
resolvedAddr: &net.UDPAddr{IP: ip, Port: port},
|
|
component: component,
|
|
relatedAddress: &CandidateRelatedAddress{
|
|
Address: relAddr,
|
|
Port: relPort,
|
|
},
|
|
},
|
|
}, nil
|
|
}
|