@@ -23,56 +23,26 @@ Common scenarios:
2323
2424Usage steps:
25251 . Create ` CoreWebView2EnvironmentOptions ` .
26- 2 . Call ` SetAllowedPortRange ` for ` COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_RTC ` and ` COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP ` .
26+ 2 . Call ` SetAllowedPortRange ` for ` COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_ALL ` and ` COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP ` .
27273 . Pass the options when creating the WebView2 environment.
2828
29- API Rules and Precedence
30-
31- 1 . Network Scope param in SetAllowedPortRange
32- - A network component-specific scope (e.g. _ WEB_RTC) always takes precedence over _ ALL for that component in ` SetAllowedPortRange ` .
33- - ` _ALL ` defines the port range restrictions for all components without specific overrides.
34- - Passing ` (0, 0) ` for a network component scope removes its restriction.
35- - If ` _ALL ` is set and a specific scope is reset, that component becomes unrestricted while ` _ALL ` still applies to others.
36-
37- | Network Scope State | Behaviour |
38- | ------------------------------------------ | ------------------------------------------------------------------------------ |
39- | Only ` _ALL ` is set | ` _ALL ` applies port range restrictions to all network components |
40- | ` _ALL ` and ` _WEB_RTC ` are both set | ` _WEB_RTC ` port range restrictions applies to WebRTC; ` _ALL ` applies to others |
41- | ` _WEB_RTC ` only is set | ` _WEB_RTC ` applies port range restrictions only to WebRTC; others unrestricted |
42- | ` _ALL ` set and ` _WEB_RTC ` reset to ` (0,0) ` | ` _ALL ` applies port range restrictions to all except WebRTC (unrestricted) |
43-
44- 2 . Network Scope param in GetAllowedPortRange
45- - ` GetAllowedPortRange ` returns the range explicitly set for the queried scope.
46- - If a specific scope is unset, it inherits ` _ALL ` .
47- - Querying ` _ALL ` only returns ` _ALL ` ; it does not aggregate component-specific settings.
48- - If neither ` _ALL ` nor a component-specific scope is set, the default ` (0,0) ` (unrestricted) is returned.
49-
50- | ` GetAllowedPortRange ` Network Scope query | Returned Range |
51- | --------------------------------------------------------------- | ----------------------------- |
52- | Pass ` _WEB_RTC ` when only ` _ALL ` is set | Returns ` _ALL ` range |
53- | Pass ` _WEB_RTC ` when ` _WEB_RTC ` explicitly set | Returns ` _WEB_RTC ` range |
54- | Pass ` _WEB_RTC ` when ` _ALL ` unset and ` _WEB_RTC ` unset | Returns ` (0, 0) ` |
55- | Pass ` _WEB_RTC ` when ` _ALL ` set and ` _WEB_RTC ` reset to ` (0, 0) ` | Returns ` (0, 0) ` |
56- | Pass ` _ALL ` when only ` _WEB_RTC ` set | Returns ` (0,0) ` |
57-
58-
5929# Examples
6030### C++ Configure UDP Port Range
6131``` cpp
6232Microsoft::WRL::ComPtr<ICoreWebView2StagingEnvironmentOptions10> optionsStaging10;
6333if (options.As(&optionsStaging10) == S_OK)
6434{
65- // Configure port ranges for WebRTC UDP traffic to work within enterprise firewalls
35+ // Configure port ranges for UDP traffic to work within enterprise firewalls
6636 // Set UDP port range (example: 50000-55000 for enterprise environments)
6737 const INT32 udpMin = 50000, udpMax = 55000;
6838
6939 CHECK_FAILURE (optionsStaging10->SetAllowedPortRange(
70- COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_RTC ,
40+ COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_ALL ,
7141 COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, udpMin, udpMax));
7242
7343 // Get the configured port range
7444 CHECK_FAILURE (optionsStaging10->GetAllowedPortRange(
75- COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_RTC ,
45+ COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_ALL ,
7646 COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, &m_udpPortRange.minPort,
7747 &m_udpPortRange.maxPort));
7848}
@@ -90,17 +60,17 @@ var options = CoreWebView2Environment.CreateCoreWebView2EnvironmentOptions();
9060var optionsStaging10 = options as ICoreWebView2StagingEnvironmentOptions10 ;
9161if (optionsStaging10 != null )
9262{
93- // Configure port ranges for WebRTC UDP traffic to work within enterprise firewalls
63+ // Configure port ranges for UDP traffic to work within enterprise firewalls
9464 // Set UDP port range (example: 50000-55000 for enterprise environments)
9565 const int udpMin = 50000 , udpMax = 55000 ;
9666
9767 optionsStaging10 .SetAllowedPortRange (
98- COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_RTC ,
68+ COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_ALL ,
9969 COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP , udpMin , udpMax );
10070
10171 // Get the configured port range
10272 optionsStaging10 .GetAllowedPortRange (
103- COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_RTC ,
73+ COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_ALL ,
10474 COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP , out m_udpPortRange .minPort ,
10575 out m_udpPortRange .maxPort );
10676}
@@ -110,6 +80,35 @@ var environment = await CoreWebView2Environment.CreateAsync(
11080OnCreateEnvironmentCompleted (environment );
11181```
11282
83+ API Rules and Precedence
84+
85+ 1 . Network Scope param in SetAllowedPortRange
86+ - A network component-specific scope (e.g. _ WEB_RTC) always takes precedence over _ ALL for that component in ` SetAllowedPortRange ` .
87+ - ` _ALL ` defines the port range restrictions for all components without specific overrides.
88+ - Passing ` (0, 0) ` for a network component scope removes its restriction.
89+ - If ` _ALL ` is set and a specific scope is reset, that component becomes unrestricted while ` _ALL ` still applies to others.
90+
91+ | Network Scope State | Behaviour |
92+ | ------------------------------------------ | ------------------------------------------------------------------------------ |
93+ | Only ` _ALL ` is set | ` _ALL ` applies port range restrictions to all network components |
94+ | ` _ALL ` and ` _WEB_RTC ` are both set | ` _WEB_RTC ` port range restrictions applies to WebRTC; ` _ALL ` applies to others |
95+ | ` _WEB_RTC ` only is set | ` _WEB_RTC ` applies port range restrictions only to WebRTC; others unrestricted |
96+ | ` _ALL ` set and ` _WEB_RTC ` reset to ` (0,0) ` | ` _ALL ` applies port range restrictions to all except WebRTC (unrestricted) |
97+
98+ 2 . Network Scope param in GetAllowedPortRange
99+ - ` GetAllowedPortRange ` returns the range explicitly set for the queried scope.
100+ - If a specific scope is unset, it inherits ` _ALL ` .
101+ - Querying ` _ALL ` only returns ` _ALL ` ; it does not aggregate component-specific settings.
102+ - If neither ` _ALL ` nor a component-specific scope is set, the default ` (0,0) ` (unrestricted) is returned.
103+
104+ | ` GetAllowedPortRange ` Network Scope query | Returned Range |
105+ | ---------------------------------------------------------------- | ----------------------------- |
106+ | Pass ` _WEB_RTC ` when only ` _ALL ` is set | Returns ` _ALL ` range |
107+ | Pass ` _WEB_RTC ` when ` _WEB_RTC ` explicitly set | Returns ` _WEB_RTC ` range |
108+ | Pass ` _WEB_RTC ` when ` _ALL ` unset and ` _WEB_RTC ` unset | Returns ` (0, 0) ` |
109+ | Pass ` _WEB_RTC ` when ` _ALL ` set and ` _WEB_RTC ` reset to ` (0, 0) ` | Returns ` (0, 0) ` |
110+ | Pass ` _ALL ` when only ` _WEB_RTC ` set | Returns ` (0,0) ` |
111+
113112# API Details
114113### C++
115114```
@@ -142,8 +141,8 @@ interface ICoreWebView2StagingEnvironmentOptions10 : IUnknown {
142141 ///
143142 /// Currently, only WebRTC UDP Port Range restriction is supported.
144143 ///
145- /// `minPort` and `maxPort` must be within the range 1025– 65535 (inclusive),
146- /// and `minPort` must be less than or equal to `maxPort`.
144+ /// `minPort` and `maxPort` must be within the range 1025- 65535 (inclusive).
145+ /// `minPort` must be less than or equal to `maxPort`.
147146 /// If `minPort` equals `maxPort`, the range represents a single port.
148147 ///
149148 /// Passing `(0, 0)` resets to the default behavior, meaning no restrictions
@@ -180,20 +179,20 @@ interface ICoreWebView2StagingEnvironmentOptions10 : IUnknown {
180179 /// `SetAllowedPortRange`.
181180 ///
182181 /// By default, `(0, 0)` is returned, which indicates no restrictions are applied
183- /// and ports are allocated from the system’ s ephemeral range (1025– 65535 inclusive).
182+ /// and ports are allocated from the system' s ephemeral range (1025- 65535 inclusive).
184183 ///
185184 /// `GetAllowedPortRange` returns the range explicitly set for the queried scope.
186185 /// If a specific scope is unset, it inherits `_ALL`.
187186 /// Querying `_ALL` only returns `_ALL`; it does not aggregate component-specific settings.
188187 /// If neither `_ALL` nor a component-specific scope is set, the default `(0,0)` (unrestricted) is returned.
189188
190- /// | `GetAllowedPortRange` Network Scope query | Returned Range |
191- /// | --------------------------------------------------------------- | ----------------------------- |
192- /// | Pass `_WEB_RTC` when only `_ALL` is set | Returns `_ALL` range |
193- /// | Pass `_WEB_RTC` when `_WEB_RTC` explicitly set | Returns `_WEB_RTC` range |
194- /// | Pass `_WEB_RTC` when `_ALL` unset and `_WEB_RTC` unset | Returns `(0, 0)` |
195- /// | Pass `_WEB_RTC` when `_ALL` set and `_WEB_RTC` reset to `(0, 0)` | Returns `(0, 0)` |
196- /// | Pass `_ALL` when only `_WEB_RTC` set | Returns `(0,0)` |
189+ /// | `GetAllowedPortRange` Network Scope query | Returned Range |
190+ /// | ---------------------------------------------------------------- | ----------------------------- |
191+ /// | Pass `_WEB_RTC` when only `_ALL` is set | Returns `_ALL` range |
192+ /// | Pass `_WEB_RTC` when `_WEB_RTC` explicitly set | Returns `_WEB_RTC` range |
193+ /// | Pass `_WEB_RTC` when `_ALL` unset and `_WEB_RTC` unset | Returns `(0, 0)` |
194+ /// | Pass `_WEB_RTC` when `_ALL` set and `_WEB_RTC` reset to `(0, 0)` | Returns `(0, 0)` |
195+ /// | Pass `_ALL` when only `_WEB_RTC` set | Returns `(0,0)` |
197196
198197 /// `scope` Network scope on which restrictions is applied.
199198 /// `protocol` Transport protocol on which restrictions is applied.
0 commit comments