Repository: pion/webrtc
Pull request #2188 (2022-04-21 08:15:30)

Update ice for accept aggressive nomination
Update ice to 2.2.5 for accept aggressive nomination

#### Description

Add AcceptAggressiveNomination to SettingEngine to compatible with browsers which have aggressive nomination

#### Reference issue
Fixes #...


codecov[bot]: # [Codecov](https://codecov.io/gh/pion/webrtc/pull/2188?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion) Report
> Merging [#2188](https://codecov.io/gh/pion/webrtc/pull/2188?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion) (3762553) into [master](https://codecov.io/gh/pion/webrtc/commit/84a8da8516087ea0da032d80a92d26b1e687dc2d?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion) (84a8da8) will **decrease** coverage by `6.95%`.
> The diff coverage is `n/a`.

```diff
@@            Coverage Diff             @@
##           master    #2188      +/-   ##
==========================================
- Coverage   76.90%   69.94%   -6.96%     
==========================================
  Files          87       64      -23     
  Lines        8988     3307    -5681     
==========================================
- Hits         6912     2313    -4599     
+ Misses       1652      867     -785     
+ Partials      424      127     -297     
```

| Flag | Coverage Δ | |
|---|---|---|
| go | `?` | |
| wasm | `69.94% <ø> (ø)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/pion/webrtc/pull/2188?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion) | Coverage Δ | |
|---|---|---|
| [constants.go](https://codecov.io/gh/pion/webrtc/pull/2188/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#diff-Y29uc3RhbnRzLmdv) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [icecandidatepair.go](https://codecov.io/gh/pion/webrtc/pull/2188/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#diff-aWNlY2FuZGlkYXRlcGFpci5nbw==) | `0.00% <0.00%> (-81.82%)` | :arrow_down: |
| [rtpcodec.go](https://codecov.io/gh/pion/webrtc/pull/2188/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#diff-cnRwY29kZWMuZ28=) | `13.33% <0.00%> (-80.00%)` | :arrow_down: |
| [stats.go](https://codecov.io/gh/pion/webrtc/pull/2188/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#diff-c3RhdHMuZ28=) | `0.00% <0.00%> (-75.00%)` | :arrow_down: |
| [track\_local.go](https://codecov.io/gh/pion/webrtc/pull/2188/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#diff-dHJhY2tfbG9jYWwuZ28=) | `0.00% <0.00%> (-66.67%)` | :arrow_down: |
| [icemux.go](https://codecov.io/gh/pion/webrtc/pull/2188/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#diff-aWNlbXV4Lmdv) | `0.00% <0.00%> (-54.55%)` | :arrow_down: |
| [internal/mux/endpoint.go](https://codecov.io/gh/pion/webrtc/pull/2188/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#diff-aW50ZXJuYWwvbXV4L2VuZHBvaW50Lmdv) | `13.79% <0.00%> (-44.83%)` | :arrow_down: |
| [atomicbool.go](https://codecov.io/gh/pion/webrtc/pull/2188/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#diff-YXRvbWljYm9vbC5nbw==) | `57.14% <0.00%> (-42.86%)` | :arrow_down: |
| [sdpsemantics.go](https://codecov.io/gh/pion/webrtc/pull/2188/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#diff-c2Rwc2VtYW50aWNzLmdv) | `0.00% <0.00%> (-34.49%)` | :arrow_down: |
| [dtlsrole.go](https://codecov.io/gh/pion/webrtc/pull/2188/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#diff-ZHRsc3JvbGUuZ28=) | `71.42% <0.00%> (-28.58%)` | :arrow_down: |
| ... and [37 more](https://codecov.io/gh/pion/webrtc/pull/2188/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pion/webrtc/pull/2188?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pion/webrtc/pull/2188?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion). Last update [84a8da8...3762553](https://codecov.io/gh/pion/webrtc/pull/2188?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion).


Patch:
diff --git a/go.mod b/go.mod
index 01a36954..280cb49d 100644
--- a/go.mod
+++ b/go.mod
@@ -7,7 +7,7 @@ require (
 	github.com/onsi/gomega v1.17.0 // indirect
 	github.com/pion/datachannel v1.5.2
 	github.com/pion/dtls/v2 v2.1.3
-	github.com/pion/ice/v2 v2.2.4
+	github.com/pion/ice/v2 v2.2.5
 	github.com/pion/interceptor v0.1.10
 	github.com/pion/logging v0.2.2
 	github.com/pion/randutil v0.1.0
diff --git a/go.sum b/go.sum
index 25ffa4e5..96bf32c5 100644
--- a/go.sum
+++ b/go.sum
@@ -44,8 +44,8 @@ github.com/pion/datachannel v1.5.2 h1:piB93s8LGmbECrpO84DnkIVWasRMk3IimbcXkTQLE6
 github.com/pion/datachannel v1.5.2/go.mod h1:FTGQWaHrdCwIJ1rw6xBIfZVkslikjShim5yr05XFuCQ=
 github.com/pion/dtls/v2 v2.1.3 h1:3UF7udADqous+M2R5Uo2q/YaP4EzUoWKdfX2oscCUio=
 github.com/pion/dtls/v2 v2.1.3/go.mod h1:o6+WvyLDAlXF7YiPB/RlskRoeK+/JtuaZa5emwQcWus=
-github.com/pion/ice/v2 v2.2.4 h1:sTHT39ywr5uqzyEMT7thEhOWsNOcdkHSZBbgQohFuZU=
-github.com/pion/ice/v2 v2.2.4/go.mod h1:SWuHiOGP17lGromHTFadUe1EuPgFh/oCU6FCMZHooVE=
+github.com/pion/ice/v2 v2.2.5 h1:8ty1lYL6WATcuFI/4J7n0USCezVZf/7gH6E8Bkm1RlY=
+github.com/pion/ice/v2 v2.2.5/go.mod h1:SWuHiOGP17lGromHTFadUe1EuPgFh/oCU6FCMZHooVE=
 github.com/pion/interceptor v0.1.10 h1:DJ2GjMGm4XGIQgMJxuEpdaExdY/6RdngT7Uh4oVmquU=
 github.com/pion/interceptor v0.1.10/go.mod h1:Lh3JSl/cbJ2wP8I3ccrjh1K/deRGRn3UlSPuOTiHb6U=
 github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY=
diff --git a/icegatherer.go b/icegatherer.go
index c3a05408..f8fe6353 100644
--- a/icegatherer.go
+++ b/icegatherer.go
@@ -90,30 +90,31 @@ func (g *ICEGatherer) createAgent() error {
 	}
 
 	config := &ice.AgentConfig{
-		Lite:                   g.api.settingEngine.candidates.ICELite,
-		Urls:                   g.validatedServers,
-		PortMin:                g.api.settingEngine.ephemeralUDP.PortMin,
-		PortMax:                g.api.settingEngine.ephemeralUDP.PortMax,
-		DisconnectedTimeout:    g.api.settingEngine.timeout.ICEDisconnectedTimeout,
-		FailedTimeout:          g.api.settingEngine.timeout.ICEFailedTimeout,
-		KeepaliveInterval:      g.api.settingEngine.timeout.ICEKeepaliveInterval,
-		LoggerFactory:          g.api.settingEngine.LoggerFactory,
-		CandidateTypes:         candidateTypes,
-		HostAcceptanceMinWait:  g.api.settingEngine.timeout.ICEHostAcceptanceMinWait,
-		SrflxAcceptanceMinWait: g.api.settingEngine.timeout.ICESrflxAcceptanceMinWait,
-		PrflxAcceptanceMinWait: g.api.settingEngine.timeout.ICEPrflxAcceptanceMinWait,
-		RelayAcceptanceMinWait: g.api.settingEngine.timeout.ICERelayAcceptanceMinWait,
-		InterfaceFilter:        g.api.settingEngine.candidates.InterfaceFilter,
-		NAT1To1IPs:             g.api.settingEngine.candidates.NAT1To1IPs,
-		NAT1To1IPCandidateType: nat1To1CandiTyp,
-		Net:                    g.api.settingEngine.vnet,
-		MulticastDNSMode:       mDNSMode,
-		MulticastDNSHostName:   g.api.settingEngine.candidates.MulticastDNSHostName,
-		LocalUfrag:             g.api.settingEngine.candidates.UsernameFragment,
-		LocalPwd:               g.api.settingEngine.candidates.Password,
-		TCPMux:                 g.api.settingEngine.iceTCPMux,
-		UDPMux:                 g.api.settingEngine.iceUDPMux,
-		ProxyDialer:            g.api.settingEngine.iceProxyDialer,
+		Lite:                       g.api.settingEngine.candidates.ICELite,
+		Urls:                       g.validatedServers,
+		PortMin:                    g.api.settingEngine.ephemeralUDP.PortMin,
+		PortMax:                    g.api.settingEngine.ephemeralUDP.PortMax,
+		DisconnectedTimeout:        g.api.settingEngine.timeout.ICEDisconnectedTimeout,
+		FailedTimeout:              g.api.settingEngine.timeout.ICEFailedTimeout,
+		KeepaliveInterval:          g.api.settingEngine.timeout.ICEKeepaliveInterval,
+		LoggerFactory:              g.api.settingEngine.LoggerFactory,
+		CandidateTypes:             candidateTypes,
+		HostAcceptanceMinWait:      g.api.settingEngine.timeout.ICEHostAcceptanceMinWait,
+		SrflxAcceptanceMinWait:     g.api.settingEngine.timeout.ICESrflxAcceptanceMinWait,
+		PrflxAcceptanceMinWait:     g.api.settingEngine.timeout.ICEPrflxAcceptanceMinWait,
+		RelayAcceptanceMinWait:     g.api.settingEngine.timeout.ICERelayAcceptanceMinWait,
+		InterfaceFilter:            g.api.settingEngine.candidates.InterfaceFilter,
+		NAT1To1IPs:                 g.api.settingEngine.candidates.NAT1To1IPs,
+		NAT1To1IPCandidateType:     nat1To1CandiTyp,
+		Net:                        g.api.settingEngine.vnet,
+		MulticastDNSMode:           mDNSMode,
+		MulticastDNSHostName:       g.api.settingEngine.candidates.MulticastDNSHostName,
+		LocalUfrag:                 g.api.settingEngine.candidates.UsernameFragment,
+		LocalPwd:                   g.api.settingEngine.candidates.Password,
+		TCPMux:                     g.api.settingEngine.iceTCPMux,
+		UDPMux:                     g.api.settingEngine.iceUDPMux,
+		ProxyDialer:                g.api.settingEngine.iceProxyDialer,
+		AcceptAggressiveNomination: g.api.settingEngine.candidates.AcceptAggressiveNomination,
 	}
 
 	requestedNetworkTypes := g.api.settingEngine.candidates.ICENetworkTypes
diff --git a/settingengine.go b/settingengine.go
index a2f5ef41..f52324d8 100644
--- a/settingengine.go
+++ b/settingengine.go
@@ -36,15 +36,16 @@ type SettingEngine struct {
 		ICERelayAcceptanceMinWait *time.Duration
 	}
 	candidates struct {
-		ICELite                bool
-		ICENetworkTypes        []NetworkType
-		InterfaceFilter        func(string) bool
-		NAT1To1IPs             []string
-		NAT1To1IPCandidateType ICECandidateType
-		MulticastDNSMode       ice.MulticastDNSMode
-		MulticastDNSHostName   string
-		UsernameFragment       string
-		Password               string
+		ICELite                    bool
+		ICENetworkTypes            []NetworkType
+		InterfaceFilter            func(string) bool
+		NAT1To1IPs                 []string
+		NAT1To1IPCandidateType     ICECandidateType
+		MulticastDNSMode           ice.MulticastDNSMode
+		MulticastDNSHostName       string
+		UsernameFragment           string
+		Password                   string
+		AcceptAggressiveNomination bool
 	}
 	replayProtection struct {
 		DTLS  *uint
@@ -229,6 +230,13 @@ func (e *SettingEngine) SetICECredentials(usernameFragment, password string) {
 	e.candidates.Password = password
 }
 
+// SetICEAcceptAggressiveNomination sets the Ice agent to accept aggressive nomination
+//
+// This is useful for compatible with chrome and other browser use aggressive nomination to update nominate candidate pairs
+func (e *SettingEngine) SetICEAcceptAggressiveNomination(acceptAggressiveNomination bool) {
+	e.candidates.AcceptAggressiveNomination = acceptAggressiveNomination
+}
+
 // DisableCertificateFingerprintVerification disables fingerprint verification after DTLS Handshake has finished
 func (e *SettingEngine) DisableCertificateFingerprintVerification(isDisabled bool) {
 	e.disableCertificateFingerprintVerification = isDisabled


Test patch:
diff --git a/settingengine_test.go b/settingengine_test.go
index 80817ca3..dc69ddb5 100644
--- a/settingengine_test.go
+++ b/settingengine_test.go
@@ -233,3 +233,21 @@ func TestSetDTLSRetransmissionInterval(t *testing.T) {
 		t.Errorf("Failed to set DTLS retransmission interval")
 	}
 }
+
+func TestSetICEAcceptAggressiveNomination(t *testing.T) {
+	s := SettingEngine{}
+
+	if s.candidates.AcceptAggressiveNomination != false {
+		t.Fatalf("SettingEngine AcceptAggressiveNomination defaults aren't as expected.")
+	}
+
+	s.SetICEAcceptAggressiveNomination(true)
+	if s.candidates.AcceptAggressiveNomination != true {
+		t.Errorf("Failed to set ICE accept aggressive nomination")
+	}
+
+	s.SetICEAcceptAggressiveNomination(false)
+	if s.candidates.AcceptAggressiveNomination != false {
+		t.Errorf("Failed to set ICE accept aggressive nomination")
+	}
+}