Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No ice #607

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 17 additions & 8 deletions agent.go
Expand Up @@ -53,6 +53,7 @@ type Agent struct {

tieBreaker uint64
lite bool
iceNone bool

connectionState ConnectionState
gatheringState GatheringState
Expand Down Expand Up @@ -283,6 +284,7 @@ func NewAgent(config *AgentConfig) (*Agent, error) { //nolint:gocognit
chanCandidatePair: make(chan *CandidatePair),
tieBreaker: globalMathRandomGenerator.Uint64(),
lite: config.Lite,
iceNone: config.ICENone,
gatheringState: GatheringStateNew,
connectionState: ConnectionStateNew,
localCandidates: make(map[NetworkType][]Candidate),
Expand Down Expand Up @@ -390,8 +392,11 @@ func (a *Agent) startConnectivityChecks(isControlling bool, remoteUfrag, remoteP
return ErrMultipleStart
default:
}
if err := a.SetRemoteCredentials(remoteUfrag, remotePwd); err != nil { //nolint:contextcheck
return err

if !a.iceNone {
if err := a.SetRemoteCredentials(remoteUfrag, remotePwd); err != nil { //nolint:contextcheck
return err
}
}

a.log.Debugf("Started agent: isControlling? %t, remoteUfrag: %q, remotePwd: %q", isControlling, remoteUfrag, remotePwd)
Expand All @@ -401,14 +406,18 @@ func (a *Agent) startConnectivityChecks(isControlling bool, remoteUfrag, remoteP
agent.remoteUfrag = remoteUfrag
agent.remotePwd = remotePwd

if isControlling {
a.selector = &controllingSelector{agent: a, log: a.log}
if a.iceNone {
a.selector = &iceNoneSelector{agent: a, log: a.log}
} else {
a.selector = &controlledSelector{agent: a, log: a.log}
}
if isControlling {
a.selector = &controllingSelector{agent: a, log: a.log}
} else {
a.selector = &controlledSelector{agent: a, log: a.log}
}

if a.lite {
a.selector = &liteSelector{pairCandidateSelector: a.selector}
if a.lite {
a.selector = &liteSelector{pairCandidateSelector: a.selector}
}
}

a.selector.Start()
Expand Down
1 change: 1 addition & 0 deletions agent_config.go
Expand Up @@ -113,6 +113,7 @@ type AgentConfig struct {

// Lite agents do not perform connectivity check and only provide host candidates.
Lite bool
ICENone bool

// NAT1To1IPCandidateType is used along with NAT1To1IPs to specify which candidate type
// the 1:1 NAT IP addresses should be mapped to.
Expand Down
34 changes: 34 additions & 0 deletions selection.go
Expand Up @@ -297,3 +297,37 @@ func (s *liteSelector) ContactCandidates() {
v.agent.validateSelectedPair()
}
}


type iceNoneSelector struct {
agent *Agent
log logging.LeveledLogger
}

func (s *iceNoneSelector) Start() {
}

func (s *iceNoneSelector) ContactCandidates() {
if s.agent.getSelectedPair() == nil {
p := s.agent.getBestAvailableCandidatePair()
if p != nil {
p.state = CandidatePairStateSucceeded
s.agent.setSelectedPair(p)
} else {
s.log.Debug("Not found best available candidate pair")
}
}
}

func (s *iceNoneSelector) PingCandidate(local, remote Candidate) {
s.log.Info("ICENone selector does not support ice stun")
}

func (s *iceNoneSelector) HandleSuccessResponse(m *stun.Message, local, remote Candidate, remoteAddr net.Addr) {
s.log.Info("ICENone selector does not support ice stun")
}

func (s *iceNoneSelector) HandleBindingRequest(m *stun.Message, local, remote Candidate) {
s.log.Info("ICENone selector does not support ice stun")
}