Skip to content

Commit 71cc958

Browse files
authored
Resolving Comments
1 parent ead15cb commit 71cc958

File tree

1 file changed

+65
-11
lines changed

1 file changed

+65
-11
lines changed

specs/WebRtcPortConfiguration.md

Lines changed: 65 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,37 @@ Common scenarios:
2323

2424
Usage steps:
2525
1. Create `CoreWebView2EnvironmentOptions`.
26-
2. Call `SetAllowedPortRange` for `COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_R_T_C` and `COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP`.
27-
3. Pass the options when creating the WebView2 environment.
26+
2. Call `SetAllowedPortRange` for `COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_RTC` and `COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP`.
27+
3. Pass the options when creating the WebView2 environment.
28+
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)` |
2857

2958

3059
# Examples
@@ -38,12 +67,12 @@ if (options.As(&optionsStaging10) == S_OK)
3867
const INT32 udpMin = 50000, udpMax = 55000;
3968

4069
CHECK_FAILURE(optionsStaging10->SetAllowedPortRange(
41-
COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_R_T_C,
70+
COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_RTC,
4271
COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, udpMin, udpMax));
4372

4473
// Get the configured port range
4574
CHECK_FAILURE(optionsStaging10->GetAllowedPortRange(
46-
COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_R_T_C,
75+
COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_RTC,
4776
COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, &m_udpPortRange.minPort,
4877
&m_udpPortRange.maxPort));
4978
}
@@ -66,12 +95,12 @@ if (optionsStaging10 != null)
6695
const int udpMin = 50000, udpMax = 55000;
6796

6897
optionsStaging10.SetAllowedPortRange(
69-
COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_R_T_C,
98+
COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_RTC,
7099
COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, udpMin, udpMax);
71100

72101
// Get the configured port range
73102
optionsStaging10.GetAllowedPortRange(
74-
COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_R_T_C,
103+
COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_RTC,
75104
COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, out m_udpPortRange.minPort,
76105
out m_udpPortRange.maxPort);
77106
}
@@ -90,7 +119,7 @@ typedef enum COREWEBVIEW2_NETWORK_COMPONENT_SCOPE {
90119
/// Scope applies to all components.
91120
COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_ALL,
92121
/// Applies only to WebRTC peer-to-peer connection.
93-
COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_R_T_C,
122+
COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_RTC,
94123
} COREWEBVIEW2_NETWORK_COMPONENT_SCOPE;
95124
96125
/// Specifies the network protocol for port configuration.
@@ -109,7 +138,7 @@ interface ICoreWebView2StagingEnvironmentOptions10 : IUnknown {
109138
/// This API enables WebView2 to operate within enterprise network or firewall
110139
/// restrictions by limiting network communication to a defined port range.
111140
/// It provides fine-grained control by allowing port restrictions to be applied
112-
/// per network component scope, such as WebRTC or QUIC.
141+
/// per network component scope, such as WebRTC.
113142
///
114143
/// Currently, only WebRTC UDP Port Range restriction is supported.
115144
///
@@ -121,7 +150,19 @@ interface ICoreWebView2StagingEnvironmentOptions10 : IUnknown {
121150
/// are applied and the system assigns ports from the full ephemeral range.
122151
///
123152
/// Calls with invalid ranges fail with `E_INVALIDARG`.
124-
///
153+
///
154+
/// A network component-specific scope (e.g. _WEB_RTC) always takes precedence over _ALL for that component in `SetAllowedPortRange`.
155+
/// `_ALL` defines the port range restrictions for all components without specific overrides.
156+
/// Passing `(0, 0)` for a network component scope removes its restriction.
157+
/// If `_ALL` is set and a specific scope is reset, that component becomes unrestricted while `_ALL` still applies to others.
158+
159+
/// | Network Scope State | Behaviour |
160+
/// | ------------------------------------------ | ------------------------------------------------------------------------------ |
161+
/// | Only `_ALL` is set | `_ALL` applies port range restrictions to all network components |
162+
/// | `_ALL` and `_WEB_RTC` are both set | `_WEB_RTC` port range restrictions applies to WebRTC; `_ALL` applies to others |
163+
/// | `_WEB_RTC` only is set | `_WEB_RTC` applies port range restrictions only to WebRTC; others unrestricted |
164+
/// | `_ALL` set and `_WEB_RTC` reset to `(0,0)` | `_ALL` applies port range restrictions to all except WebRTC (unrestricted) |
165+
125166
/// `scope` Network scope on which restrictions will apply.
126167
/// `protocol` Transport protocol on which restrictions will apply.
127168
/// `minPort` The minimum allowed port number (inclusive).
@@ -140,7 +181,20 @@ interface ICoreWebView2StagingEnvironmentOptions10 : IUnknown {
140181
///
141182
/// By default, `(0, 0)` is returned, which indicates no restrictions are applied
142183
/// and ports are allocated from the system’s ephemeral range (1025–65535 inclusive).
143-
///
184+
///
185+
/// `GetAllowedPortRange` returns the range explicitly set for the queried scope.
186+
/// If a specific scope is unset, it inherits `_ALL`.
187+
/// Querying `_ALL` only returns `_ALL`; it does not aggregate component-specific settings.
188+
/// If neither `_ALL` nor a component-specific scope is set, the default `(0,0)` (unrestricted) is returned.
189+
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)` |
197+
144198
/// `scope` Network scope on which restrictions is applied.
145199
/// `protocol` Transport protocol on which restrictions is applied.
146200
/// `minPort` Receives the minimum allowed port number (inclusive).
@@ -164,7 +218,7 @@ namespace Microsoft.Web.WebView2.Core
164218
enum CoreWebview2NetworkComponentScope
165219
{
166220
All = 0,
167-
WebRTC = 1,
221+
WebRtc = 1,
168222
};
169223

170224
enum CoreWebView2TransportProtocolKind

0 commit comments

Comments
 (0)