From ead15cb0924108286b27b6d4bdd344df18259e4e Mon Sep 17 00:00:00 2001 From: Ashutosh Kumar Ray <156680761+ashuray007@users.noreply.github.com> Date: Mon, 13 Oct 2025 19:55:43 +0530 Subject: [PATCH 1/7] Adding CoreWebView2NetworkComponentScope This change extends the existing WebView2 environment options API for port configuration (SetAllowedPortRange and GetAllowedPortRange) by introducing a new parameter: CoreWebView2NetworkComponentScope. This addition gives developers more granular control over port restrictions, allowing them to target specific network components rather than applying restrictions globally across all network traffic. --- specs/WebRtcPortConfiguration.md | 41 ++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/specs/WebRtcPortConfiguration.md b/specs/WebRtcPortConfiguration.md index fc7f025a..d18f77d7 100644 --- a/specs/WebRtcPortConfiguration.md +++ b/specs/WebRtcPortConfiguration.md @@ -23,7 +23,7 @@ Common scenarios: Usage steps: 1. Create `CoreWebView2EnvironmentOptions`. -2. Call `SetAllowedPortRange` for `COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP`. +2. Call `SetAllowedPortRange` for `COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_R_T_C` and `COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP`. 3. Pass the options when creating the WebView2 environment. @@ -38,10 +38,12 @@ if (options.As(&optionsStaging10) == S_OK) const INT32 udpMin = 50000, udpMax = 55000; CHECK_FAILURE(optionsStaging10->SetAllowedPortRange( + COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_R_T_C, COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, udpMin, udpMax)); // Get the configured port range CHECK_FAILURE(optionsStaging10->GetAllowedPortRange( + COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_R_T_C, COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, &m_udpPortRange.minPort, &m_udpPortRange.maxPort)); } @@ -64,10 +66,12 @@ if (optionsStaging10 != null) const int udpMin = 50000, udpMax = 55000; optionsStaging10.SetAllowedPortRange( + COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_R_T_C, COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, udpMin, udpMax); // Get the configured port range optionsStaging10.GetAllowedPortRange( + COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_R_T_C, COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, out m_udpPortRange.minPort, out m_udpPortRange.maxPort); } @@ -80,6 +84,15 @@ OnCreateEnvironmentCompleted(environment); # API Details ### C++ ``` +/// Specifies the network component scope for port configuration. +[v1_enum] +typedef enum COREWEBVIEW2_NETWORK_COMPONENT_SCOPE { + /// Scope applies to all components. + COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_ALL, + /// Applies only to WebRTC peer-to-peer connection. + COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_R_T_C, +} COREWEBVIEW2_NETWORK_COMPONENT_SCOPE; + /// Specifies the network protocol for port configuration. [v1_enum] typedef enum COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND { @@ -88,11 +101,15 @@ typedef enum COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND { } COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND; /// Additional options used to create WebView2 Environment to manage port range configuration. -[uuid(eaf22436-27a1-5e3d-a4e3-84d7e7a69a1a), object, pointer_default(unique)] +[uuid(6ce30f6b-5dcc-5dc1-9c09-723cf233dbe5), object, pointer_default(unique)] interface ICoreWebView2StagingEnvironmentOptions10 : IUnknown { - /// Sets the allowed port range for the specified transport protocol. + /// Sets the allowed port range restriction for the specified network component + /// scope and transport protocol. + /// /// This API enables WebView2 to operate within enterprise network or firewall /// restrictions by limiting network communication to a defined port range. + /// It provides fine-grained control by allowing port restrictions to be applied + /// per network component scope, such as WebRTC or QUIC. /// /// Currently, only WebRTC UDP Port Range restriction is supported. /// @@ -105,11 +122,13 @@ interface ICoreWebView2StagingEnvironmentOptions10 : IUnknown { /// /// Calls with invalid ranges fail with `E_INVALIDARG`. /// - /// `protocol` The transport protocol (currently only UDP is supported). + /// `scope` Network scope on which restrictions will apply. + /// `protocol` Transport protocol on which restrictions will apply. /// `minPort` The minimum allowed port number (inclusive). /// `maxPort` The maximum allowed port number (inclusive). /// HRESULT SetAllowedPortRange( + [in] COREWEBVIEW2_NETWORK_COMPONENT_SCOPE scope, [in] COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND protocol, [in] INT32 minPort, [in] INT32 maxPort @@ -122,11 +141,13 @@ interface ICoreWebView2StagingEnvironmentOptions10 : IUnknown { /// By default, `(0, 0)` is returned, which indicates no restrictions are applied /// and ports are allocated from the system’s ephemeral range (1025–65535 inclusive). /// - /// `protocol` The transport protocol (currently only UDP is supported). + /// `scope` Network scope on which restrictions is applied. + /// `protocol` Transport protocol on which restrictions is applied. /// `minPort` Receives the minimum allowed port number (inclusive). /// `maxPort` Receives the maximum allowed port number (inclusive). /// HRESULT GetAllowedPortRange( + [in] COREWEBVIEW2_NETWORK_COMPONENT_SCOPE scope, [in] COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND protocol, [out] INT32* minPort, [out] INT32* maxPort @@ -140,6 +161,12 @@ interface ICoreWebView2StagingEnvironmentOptions10 : IUnknown { ```csharp namespace Microsoft.Web.WebView2.Core { + enum CoreWebview2NetworkComponentScope + { + All = 0, + WebRTC = 1, + }; + enum CoreWebView2TransportProtocolKind { Udp = 0, @@ -150,8 +177,8 @@ namespace Microsoft.Web.WebView2.Core [interface_name("Microsoft.Web.WebView2.Core.ICoreWebView2StagingEnvironmentOptions10")] { // ICoreWebView2StagingEnvironmentOptions10 members - void SetAllowedPortRange(CoreWebView2TransportProtocolKind protocol, Int32 minPort, Int32 maxPort); - void GetAllowedPortRange(CoreWebView2TransportProtocolKind protocol, out Int32 minPort, out Int32 maxPort); + void SetAllowedPortRange(CoreWebview2NetworkComponentScope scope, CoreWebView2TransportProtocolKind protocol, Int32 minPort, Int32 maxPort); + void GetAllowedPortRange(CoreWebview2NetworkComponentScope scope, CoreWebView2TransportProtocolKind protocol, out Int32 minPort, out Int32 maxPort); } } } From 71cc9586c0214a8e60ee1a9fc84437990410c4f9 Mon Sep 17 00:00:00 2001 From: Ashutosh Kumar Ray <156680761+ashuray007@users.noreply.github.com> Date: Wed, 15 Oct 2025 16:33:43 +0530 Subject: [PATCH 2/7] Resolving Comments --- specs/WebRtcPortConfiguration.md | 76 +++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 11 deletions(-) diff --git a/specs/WebRtcPortConfiguration.md b/specs/WebRtcPortConfiguration.md index d18f77d7..753e212a 100644 --- a/specs/WebRtcPortConfiguration.md +++ b/specs/WebRtcPortConfiguration.md @@ -23,8 +23,37 @@ Common scenarios: Usage steps: 1. Create `CoreWebView2EnvironmentOptions`. -2. Call `SetAllowedPortRange` for `COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_R_T_C` and `COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP`. -3. Pass the options when creating the WebView2 environment. +2. Call `SetAllowedPortRange` for `COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_RTC` and `COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP`. +3. Pass the options when creating the WebView2 environment. + +API Rules and Precedence + +1. Network Scope param in SetAllowedPortRange +- A network component-specific scope (e.g. _WEB_RTC) always takes precedence over _ALL for that component in `SetAllowedPortRange`. +- `_ALL` defines the port range restrictions for all components without specific overrides. +- Passing `(0, 0)` for a network component scope removes its restriction. +- If `_ALL` is set and a specific scope is reset, that component becomes unrestricted while `_ALL` still applies to others. + +| Network Scope State | Behaviour | +| ------------------------------------------ | ------------------------------------------------------------------------------ | +| Only `_ALL` is set | `_ALL` applies port range restrictions to all network components | +| `_ALL` and `_WEB_RTC` are both set | `_WEB_RTC` port range restrictions applies to WebRTC; `_ALL` applies to others | +| `_WEB_RTC` only is set | `_WEB_RTC` applies port range restrictions only to WebRTC; others unrestricted | +| `_ALL` set and `_WEB_RTC` reset to `(0,0)` | `_ALL` applies port range restrictions to all except WebRTC (unrestricted) | + +2. Network Scope param in GetAllowedPortRange +- `GetAllowedPortRange` returns the range explicitly set for the queried scope. +- If a specific scope is unset, it inherits `_ALL`. +- Querying `_ALL` only returns `_ALL`; it does not aggregate component-specific settings. +- If neither `_ALL` nor a component-specific scope is set, the default `(0,0)` (unrestricted) is returned. + +| `GetAllowedPortRange` Network Scope query | Returned Range | +| --------------------------------------------------------------- | ----------------------------- | +| Pass `_WEB_RTC` when only `_ALL` is set | Returns `_ALL` range | +| Pass `_WEB_RTC` when `_WEB_RTC` explicitly set | Returns `_WEB_RTC` range | +| Pass `_WEB_RTC` when `_ALL` unset and `_WEB_RTC` unset | Returns `(0, 0)` | +| Pass `_WEB_RTC` when `_ALL` set and `_WEB_RTC` reset to `(0, 0)` | Returns `(0, 0)` | +| Pass `_ALL` when only `_WEB_RTC` set | Returns `(0,0)` | # Examples @@ -38,12 +67,12 @@ if (options.As(&optionsStaging10) == S_OK) const INT32 udpMin = 50000, udpMax = 55000; CHECK_FAILURE(optionsStaging10->SetAllowedPortRange( - COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_R_T_C, + COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_RTC, COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, udpMin, udpMax)); // Get the configured port range CHECK_FAILURE(optionsStaging10->GetAllowedPortRange( - COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_R_T_C, + COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_RTC, COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, &m_udpPortRange.minPort, &m_udpPortRange.maxPort)); } @@ -66,12 +95,12 @@ if (optionsStaging10 != null) const int udpMin = 50000, udpMax = 55000; optionsStaging10.SetAllowedPortRange( - COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_R_T_C, + COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_RTC, COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, udpMin, udpMax); // Get the configured port range optionsStaging10.GetAllowedPortRange( - COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_R_T_C, + COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_RTC, COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, out m_udpPortRange.minPort, out m_udpPortRange.maxPort); } @@ -90,7 +119,7 @@ typedef enum COREWEBVIEW2_NETWORK_COMPONENT_SCOPE { /// Scope applies to all components. COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_ALL, /// Applies only to WebRTC peer-to-peer connection. - COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_R_T_C, + COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_RTC, } COREWEBVIEW2_NETWORK_COMPONENT_SCOPE; /// Specifies the network protocol for port configuration. @@ -109,7 +138,7 @@ interface ICoreWebView2StagingEnvironmentOptions10 : IUnknown { /// This API enables WebView2 to operate within enterprise network or firewall /// restrictions by limiting network communication to a defined port range. /// It provides fine-grained control by allowing port restrictions to be applied - /// per network component scope, such as WebRTC or QUIC. + /// per network component scope, such as WebRTC. /// /// Currently, only WebRTC UDP Port Range restriction is supported. /// @@ -121,7 +150,19 @@ interface ICoreWebView2StagingEnvironmentOptions10 : IUnknown { /// are applied and the system assigns ports from the full ephemeral range. /// /// Calls with invalid ranges fail with `E_INVALIDARG`. - /// + /// + /// A network component-specific scope (e.g. _WEB_RTC) always takes precedence over _ALL for that component in `SetAllowedPortRange`. + /// `_ALL` defines the port range restrictions for all components without specific overrides. + /// Passing `(0, 0)` for a network component scope removes its restriction. + /// If `_ALL` is set and a specific scope is reset, that component becomes unrestricted while `_ALL` still applies to others. + + /// | Network Scope State | Behaviour | + /// | ------------------------------------------ | ------------------------------------------------------------------------------ | + /// | Only `_ALL` is set | `_ALL` applies port range restrictions to all network components | + /// | `_ALL` and `_WEB_RTC` are both set | `_WEB_RTC` port range restrictions applies to WebRTC; `_ALL` applies to others | + /// | `_WEB_RTC` only is set | `_WEB_RTC` applies port range restrictions only to WebRTC; others unrestricted | + /// | `_ALL` set and `_WEB_RTC` reset to `(0,0)` | `_ALL` applies port range restrictions to all except WebRTC (unrestricted) | + /// `scope` Network scope on which restrictions will apply. /// `protocol` Transport protocol on which restrictions will apply. /// `minPort` The minimum allowed port number (inclusive). @@ -140,7 +181,20 @@ interface ICoreWebView2StagingEnvironmentOptions10 : IUnknown { /// /// By default, `(0, 0)` is returned, which indicates no restrictions are applied /// and ports are allocated from the system’s ephemeral range (1025–65535 inclusive). - /// + /// + /// `GetAllowedPortRange` returns the range explicitly set for the queried scope. + /// If a specific scope is unset, it inherits `_ALL`. + /// Querying `_ALL` only returns `_ALL`; it does not aggregate component-specific settings. + /// If neither `_ALL` nor a component-specific scope is set, the default `(0,0)` (unrestricted) is returned. + + /// | `GetAllowedPortRange` Network Scope query | Returned Range | + /// | --------------------------------------------------------------- | ----------------------------- | + /// | Pass `_WEB_RTC` when only `_ALL` is set | Returns `_ALL` range | + /// | Pass `_WEB_RTC` when `_WEB_RTC` explicitly set | Returns `_WEB_RTC` range | + /// | Pass `_WEB_RTC` when `_ALL` unset and `_WEB_RTC` unset | Returns `(0, 0)` | + /// | Pass `_WEB_RTC` when `_ALL` set and `_WEB_RTC` reset to `(0, 0)` | Returns `(0, 0)` | + /// | Pass `_ALL` when only `_WEB_RTC` set | Returns `(0,0)` | + /// `scope` Network scope on which restrictions is applied. /// `protocol` Transport protocol on which restrictions is applied. /// `minPort` Receives the minimum allowed port number (inclusive). @@ -164,7 +218,7 @@ namespace Microsoft.Web.WebView2.Core enum CoreWebview2NetworkComponentScope { All = 0, - WebRTC = 1, + WebRtc = 1, }; enum CoreWebView2TransportProtocolKind From 3eb89234a72dbfe8114422a968bf3367d8edb872 Mon Sep 17 00:00:00 2001 From: Ashutosh Kumar Ray <156680761+ashuray007@users.noreply.github.com> Date: Wed, 15 Oct 2025 17:40:40 +0530 Subject: [PATCH 3/7] Resolving Comments --- specs/WebRtcPortConfiguration.md | 93 ++++++++++++++++---------------- 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/specs/WebRtcPortConfiguration.md b/specs/WebRtcPortConfiguration.md index 753e212a..c1ea98d5 100644 --- a/specs/WebRtcPortConfiguration.md +++ b/specs/WebRtcPortConfiguration.md @@ -23,56 +23,26 @@ Common scenarios: Usage steps: 1. Create `CoreWebView2EnvironmentOptions`. -2. Call `SetAllowedPortRange` for `COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_RTC` and `COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP`. +2. Call `SetAllowedPortRange` for `COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_ALL` and `COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP`. 3. Pass the options when creating the WebView2 environment. -API Rules and Precedence - -1. Network Scope param in SetAllowedPortRange -- A network component-specific scope (e.g. _WEB_RTC) always takes precedence over _ALL for that component in `SetAllowedPortRange`. -- `_ALL` defines the port range restrictions for all components without specific overrides. -- Passing `(0, 0)` for a network component scope removes its restriction. -- If `_ALL` is set and a specific scope is reset, that component becomes unrestricted while `_ALL` still applies to others. - -| Network Scope State | Behaviour | -| ------------------------------------------ | ------------------------------------------------------------------------------ | -| Only `_ALL` is set | `_ALL` applies port range restrictions to all network components | -| `_ALL` and `_WEB_RTC` are both set | `_WEB_RTC` port range restrictions applies to WebRTC; `_ALL` applies to others | -| `_WEB_RTC` only is set | `_WEB_RTC` applies port range restrictions only to WebRTC; others unrestricted | -| `_ALL` set and `_WEB_RTC` reset to `(0,0)` | `_ALL` applies port range restrictions to all except WebRTC (unrestricted) | - -2. Network Scope param in GetAllowedPortRange -- `GetAllowedPortRange` returns the range explicitly set for the queried scope. -- If a specific scope is unset, it inherits `_ALL`. -- Querying `_ALL` only returns `_ALL`; it does not aggregate component-specific settings. -- If neither `_ALL` nor a component-specific scope is set, the default `(0,0)` (unrestricted) is returned. - -| `GetAllowedPortRange` Network Scope query | Returned Range | -| --------------------------------------------------------------- | ----------------------------- | -| Pass `_WEB_RTC` when only `_ALL` is set | Returns `_ALL` range | -| Pass `_WEB_RTC` when `_WEB_RTC` explicitly set | Returns `_WEB_RTC` range | -| Pass `_WEB_RTC` when `_ALL` unset and `_WEB_RTC` unset | Returns `(0, 0)` | -| Pass `_WEB_RTC` when `_ALL` set and `_WEB_RTC` reset to `(0, 0)` | Returns `(0, 0)` | -| Pass `_ALL` when only `_WEB_RTC` set | Returns `(0,0)` | - - # Examples ### C++ Configure UDP Port Range ```cpp Microsoft::WRL::ComPtr optionsStaging10; if (options.As(&optionsStaging10) == S_OK) { - // Configure port ranges for WebRTC UDP traffic to work within enterprise firewalls + // Configure port ranges for UDP traffic to work within enterprise firewalls // Set UDP port range (example: 50000-55000 for enterprise environments) const INT32 udpMin = 50000, udpMax = 55000; CHECK_FAILURE(optionsStaging10->SetAllowedPortRange( - COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_RTC, + COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_ALL, COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, udpMin, udpMax)); // Get the configured port range CHECK_FAILURE(optionsStaging10->GetAllowedPortRange( - COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_RTC, + COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_ALL, COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, &m_udpPortRange.minPort, &m_udpPortRange.maxPort)); } @@ -90,17 +60,17 @@ var options = CoreWebView2Environment.CreateCoreWebView2EnvironmentOptions(); var optionsStaging10 = options as ICoreWebView2StagingEnvironmentOptions10; if (optionsStaging10 != null) { - // Configure port ranges for WebRTC UDP traffic to work within enterprise firewalls + // Configure port ranges for UDP traffic to work within enterprise firewalls // Set UDP port range (example: 50000-55000 for enterprise environments) const int udpMin = 50000, udpMax = 55000; optionsStaging10.SetAllowedPortRange( - COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_RTC, + COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_ALL, COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, udpMin, udpMax); // Get the configured port range optionsStaging10.GetAllowedPortRange( - COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_RTC, + COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_ALL, COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, out m_udpPortRange.minPort, out m_udpPortRange.maxPort); } @@ -110,6 +80,35 @@ var environment = await CoreWebView2Environment.CreateAsync( OnCreateEnvironmentCompleted(environment); ``` +API Rules and Precedence + +1. Network Scope param in SetAllowedPortRange +- A network component-specific scope (e.g. _WEB_RTC) always takes precedence over _ALL for that component in `SetAllowedPortRange`. +- `_ALL` defines the port range restrictions for all components without specific overrides. +- Passing `(0, 0)` for a network component scope removes its restriction. +- If `_ALL` is set and a specific scope is reset, that component becomes unrestricted while `_ALL` still applies to others. + +| Network Scope State | Behaviour | +| ------------------------------------------ | ------------------------------------------------------------------------------ | +| Only `_ALL` is set | `_ALL` applies port range restrictions to all network components | +| `_ALL` and `_WEB_RTC` are both set | `_WEB_RTC` port range restrictions applies to WebRTC; `_ALL` applies to others | +| `_WEB_RTC` only is set | `_WEB_RTC` applies port range restrictions only to WebRTC; others unrestricted | +| `_ALL` set and `_WEB_RTC` reset to `(0,0)` | `_ALL` applies port range restrictions to all except WebRTC (unrestricted) | + +2. Network Scope param in GetAllowedPortRange +- `GetAllowedPortRange` returns the range explicitly set for the queried scope. +- If a specific scope is unset, it inherits `_ALL`. +- Querying `_ALL` only returns `_ALL`; it does not aggregate component-specific settings. +- If neither `_ALL` nor a component-specific scope is set, the default `(0,0)` (unrestricted) is returned. + +| `GetAllowedPortRange` Network Scope query | Returned Range | +| ---------------------------------------------------------------- | ----------------------------- | +| Pass `_WEB_RTC` when only `_ALL` is set | Returns `_ALL` range | +| Pass `_WEB_RTC` when `_WEB_RTC` explicitly set | Returns `_WEB_RTC` range | +| Pass `_WEB_RTC` when `_ALL` unset and `_WEB_RTC` unset | Returns `(0, 0)` | +| Pass `_WEB_RTC` when `_ALL` set and `_WEB_RTC` reset to `(0, 0)` | Returns `(0, 0)` | +| Pass `_ALL` when only `_WEB_RTC` set | Returns `(0,0)` | + # API Details ### C++ ``` @@ -142,8 +141,8 @@ interface ICoreWebView2StagingEnvironmentOptions10 : IUnknown { /// /// Currently, only WebRTC UDP Port Range restriction is supported. /// - /// `minPort` and `maxPort` must be within the range 1025–65535 (inclusive), - /// and `minPort` must be less than or equal to `maxPort`. + /// `minPort` and `maxPort` must be within the range 1025-65535 (inclusive). + /// `minPort` must be less than or equal to `maxPort`. /// If `minPort` equals `maxPort`, the range represents a single port. /// /// Passing `(0, 0)` resets to the default behavior, meaning no restrictions @@ -180,20 +179,20 @@ interface ICoreWebView2StagingEnvironmentOptions10 : IUnknown { /// `SetAllowedPortRange`. /// /// By default, `(0, 0)` is returned, which indicates no restrictions are applied - /// and ports are allocated from the system’s ephemeral range (1025–65535 inclusive). + /// and ports are allocated from the system's ephemeral range (1025-65535 inclusive). /// /// `GetAllowedPortRange` returns the range explicitly set for the queried scope. /// If a specific scope is unset, it inherits `_ALL`. /// Querying `_ALL` only returns `_ALL`; it does not aggregate component-specific settings. /// If neither `_ALL` nor a component-specific scope is set, the default `(0,0)` (unrestricted) is returned. - /// | `GetAllowedPortRange` Network Scope query | Returned Range | - /// | --------------------------------------------------------------- | ----------------------------- | - /// | Pass `_WEB_RTC` when only `_ALL` is set | Returns `_ALL` range | - /// | Pass `_WEB_RTC` when `_WEB_RTC` explicitly set | Returns `_WEB_RTC` range | - /// | Pass `_WEB_RTC` when `_ALL` unset and `_WEB_RTC` unset | Returns `(0, 0)` | - /// | Pass `_WEB_RTC` when `_ALL` set and `_WEB_RTC` reset to `(0, 0)` | Returns `(0, 0)` | - /// | Pass `_ALL` when only `_WEB_RTC` set | Returns `(0,0)` | + /// | `GetAllowedPortRange` Network Scope query | Returned Range | + /// | ---------------------------------------------------------------- | ----------------------------- | + /// | Pass `_WEB_RTC` when only `_ALL` is set | Returns `_ALL` range | + /// | Pass `_WEB_RTC` when `_WEB_RTC` explicitly set | Returns `_WEB_RTC` range | + /// | Pass `_WEB_RTC` when `_ALL` unset and `_WEB_RTC` unset | Returns `(0, 0)` | + /// | Pass `_WEB_RTC` when `_ALL` set and `_WEB_RTC` reset to `(0, 0)` | Returns `(0, 0)` | + /// | Pass `_ALL` when only `_WEB_RTC` set | Returns `(0,0)` | /// `scope` Network scope on which restrictions is applied. /// `protocol` Transport protocol on which restrictions is applied. From 3ebe61dc3a5347896ab03995a23309b32588fa6d Mon Sep 17 00:00:00 2001 From: Ashutosh Kumar Ray <156680761+ashuray007@users.noreply.github.com> Date: Tue, 28 Oct 2025 18:30:42 +0530 Subject: [PATCH 4/7] Resolving Comments --- specs/WebRtcPortConfiguration.md | 160 +++++++++++++++---------------- 1 file changed, 79 insertions(+), 81 deletions(-) diff --git a/specs/WebRtcPortConfiguration.md b/specs/WebRtcPortConfiguration.md index c1ea98d5..f183e66a 100644 --- a/specs/WebRtcPortConfiguration.md +++ b/specs/WebRtcPortConfiguration.md @@ -23,7 +23,7 @@ Common scenarios: Usage steps: 1. Create `CoreWebView2EnvironmentOptions`. -2. Call `SetAllowedPortRange` for `COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_ALL` and `COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP`. +2. Call `SetAllowedPortRange` for `COREWEBVIEW2_PORT_RANGE_RESTRICTION_SCOPE_DEFAULT` and `COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP`. 3. Pass the options when creating the WebView2 environment. # Examples @@ -37,12 +37,12 @@ if (options.As(&optionsStaging10) == S_OK) const INT32 udpMin = 50000, udpMax = 55000; CHECK_FAILURE(optionsStaging10->SetAllowedPortRange( - COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_ALL, + COREWEBVIEW2_PORT_RANGE_RESTRICTION_SCOPE_DEFAULT, COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, udpMin, udpMax)); // Get the configured port range - CHECK_FAILURE(optionsStaging10->GetAllowedPortRange( - COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_ALL, + CHECK_FAILURE(optionsStaging10->GetEffectiveAllowedPortRange( + COREWEBVIEW2_PORT_RANGE_RESTRICTION_SCOPE_DEFAULT, COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, &m_udpPortRange.minPort, &m_udpPortRange.maxPort)); } @@ -65,12 +65,12 @@ if (optionsStaging10 != null) const int udpMin = 50000, udpMax = 55000; optionsStaging10.SetAllowedPortRange( - COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_ALL, + COREWEBVIEW2_PORT_RANGE_RESTRICTION_SCOPE_DEFAULT, COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, udpMin, udpMax); // Get the configured port range - optionsStaging10.GetAllowedPortRange( - COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_ALL, + optionsStaging10.GetEffectiveAllowedPortRange( + COREWEBVIEW2_PORT_RANGE_RESTRICTION_SCOPE_DEFAULT, COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, out m_udpPortRange.minPort, out m_udpPortRange.maxPort); } @@ -82,44 +82,46 @@ OnCreateEnvironmentCompleted(environment); API Rules and Precedence -1. Network Scope param in SetAllowedPortRange -- A network component-specific scope (e.g. _WEB_RTC) always takes precedence over _ALL for that component in `SetAllowedPortRange`. -- `_ALL` defines the port range restrictions for all components without specific overrides. -- Passing `(0, 0)` for a network component scope removes its restriction. -- If `_ALL` is set and a specific scope is reset, that component becomes unrestricted while `_ALL` still applies to others. - -| Network Scope State | Behaviour | -| ------------------------------------------ | ------------------------------------------------------------------------------ | -| Only `_ALL` is set | `_ALL` applies port range restrictions to all network components | -| `_ALL` and `_WEB_RTC` are both set | `_WEB_RTC` port range restrictions applies to WebRTC; `_ALL` applies to others | -| `_WEB_RTC` only is set | `_WEB_RTC` applies port range restrictions only to WebRTC; others unrestricted | -| `_ALL` set and `_WEB_RTC` reset to `(0,0)` | `_ALL` applies port range restrictions to all except WebRTC (unrestricted) | - -2. Network Scope param in GetAllowedPortRange -- `GetAllowedPortRange` returns the range explicitly set for the queried scope. -- If a specific scope is unset, it inherits `_ALL`. -- Querying `_ALL` only returns `_ALL`; it does not aggregate component-specific settings. -- If neither `_ALL` nor a component-specific scope is set, the default `(0,0)` (unrestricted) is returned. - -| `GetAllowedPortRange` Network Scope query | Returned Range | -| ---------------------------------------------------------------- | ----------------------------- | -| Pass `_WEB_RTC` when only `_ALL` is set | Returns `_ALL` range | -| Pass `_WEB_RTC` when `_WEB_RTC` explicitly set | Returns `_WEB_RTC` range | -| Pass `_WEB_RTC` when `_ALL` unset and `_WEB_RTC` unset | Returns `(0, 0)` | -| Pass `_WEB_RTC` when `_ALL` set and `_WEB_RTC` reset to `(0, 0)` | Returns `(0, 0)` | -| Pass `_ALL` when only `_WEB_RTC` set | Returns `(0,0)` | +1. Port Range Restriction Scope param in SetAllowedPortRange +- A component specific scope (e.g. _WEB_RTC) always takes precedence over _DEFAULT for that component in `SetAllowedPortRange`. +- `_DEFAULT` defines the base port range restrictions for all components without specific overrides. +- Passing `(0, 0)` for a component scope unset its specific range restriction and inherit range restriction from `_DEFAULT` +- If `_DEFAULT` is set and a specific scope is unset, that component inherits `_DEFAULT`. +- Passing `(0,65535)` for a component scope make port range unrestricted for that component. + +| Scope State | Behaviour | +| ------------------------------------------ | --------------------------------------------------------------------------------------------- | +| Only `_DEFAULT` is set | `_DEFAULT` applies port range restrictions to all components | +| `_DEFAULT` and `_WEB_RTC` are both set | `_WEB_RTC` port range restrictions applies to WebRTC; `_DEFAULT` applies to others | +| `_WEB_RTC` only is set | `_WEB_RTC` applies port range restrictions only to WebRTC; others unrestricted | +| `_DEFAULT` set and `_WEB_RTC` reset to `(0,0)` | `_DEFAULT` applies port range restrictions to all and WebRTC inherits `_DEFAULT` | +| `_DEFAULT` set and `_WEB_RTC` set to `(0,65535)` | `_DEFAULT` applies port range restrictions to all except WebRTC which is unrestricted | + +2. Port Range Restriction Scope param in GetEffectiveAllowedPortRange +- `GetEffectiveAllowedPortRange` returns the range explicitly set for the queried scope. +- If a specific scope is unset, it inherits `_DEFAULT`. +- Querying `_DEFAULT` only returns `_DEFAULT`; it does not aggregate component-specific settings. +- If neither `_DEFAULT` nor a component-specific scope is set, the default `(0,0)` (unset) is returned. + +| `GetEffectiveAllowedPortRange` Scope query | Returned Range | +| -------------------------------------------------------------------- | ----------------------------- | +| Pass `_WEB_RTC` when only `_DEFAULT` is set | Returns `_DEFAULT` range | +| Pass `_WEB_RTC` when `_WEB_RTC` explicitly set | Returns `_WEB_RTC` range | +| Pass `_WEB_RTC` when `_DEFAULT` unset and `_WEB_RTC` unset | Returns `(0, 0)` | +| Pass `_WEB_RTC` when `_DEFAULT` set and `_WEB_RTC` reset to `(0, 0)` | Returns `_DEFAULT` | +| Pass `_DEFAULT` when only `_WEB_RTC` set | Returns `(0,0)` | # API Details ### C++ ``` -/// Specifies the network component scope for port configuration. +/// Specifies the scope for port configuration. [v1_enum] -typedef enum COREWEBVIEW2_NETWORK_COMPONENT_SCOPE { +typedef enum COREWEBVIEW2_PORT_RANGE_RESTRICTION_SCOPE { /// Scope applies to all components. - COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_ALL, + COREWEBVIEW2_PORT_RANGE_RESTRICTION_SCOPE_DEFAULT, /// Applies only to WebRTC peer-to-peer connection. - COREWEBVIEW2_NETWORK_COMPONENT_SCOPE_WEB_RTC, -} COREWEBVIEW2_NETWORK_COMPONENT_SCOPE; + COREWEBVIEW2_PORT_RANGE_RESTRICTION_SCOPE_WEB_RTC, +} COREWEBVIEW2_PORT_RANGE_RESTRICTION_SCOPE; /// Specifies the network protocol for port configuration. [v1_enum] @@ -131,7 +133,7 @@ typedef enum COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND { /// Additional options used to create WebView2 Environment to manage port range configuration. [uuid(6ce30f6b-5dcc-5dc1-9c09-723cf233dbe5), object, pointer_default(unique)] interface ICoreWebView2StagingEnvironmentOptions10 : IUnknown { - /// Sets the allowed port range restriction for the specified network component + /// Sets the allowed port range restriction for the specified /// scope and transport protocol. /// /// This API enables WebView2 to operate within enterprise network or firewall @@ -145,62 +147,58 @@ interface ICoreWebView2StagingEnvironmentOptions10 : IUnknown { /// `minPort` must be less than or equal to `maxPort`. /// If `minPort` equals `maxPort`, the range represents a single port. /// - /// Passing `(0, 0)` resets to the default behavior, meaning no restrictions - /// are applied and the system assigns ports from the full ephemeral range. - /// /// Calls with invalid ranges fail with `E_INVALIDARG`. /// - /// A network component-specific scope (e.g. _WEB_RTC) always takes precedence over _ALL for that component in `SetAllowedPortRange`. - /// `_ALL` defines the port range restrictions for all components without specific overrides. - /// Passing `(0, 0)` for a network component scope removes its restriction. - /// If `_ALL` is set and a specific scope is reset, that component becomes unrestricted while `_ALL` still applies to others. - - /// | Network Scope State | Behaviour | - /// | ------------------------------------------ | ------------------------------------------------------------------------------ | - /// | Only `_ALL` is set | `_ALL` applies port range restrictions to all network components | - /// | `_ALL` and `_WEB_RTC` are both set | `_WEB_RTC` port range restrictions applies to WebRTC; `_ALL` applies to others | - /// | `_WEB_RTC` only is set | `_WEB_RTC` applies port range restrictions only to WebRTC; others unrestricted | - /// | `_ALL` set and `_WEB_RTC` reset to `(0,0)` | `_ALL` applies port range restrictions to all except WebRTC (unrestricted) | - - /// `scope` Network scope on which restrictions will apply. + /// A component specific scope (e.g. _WEB_RTC) always takes precedence over _DEFAULT for that component in `SetAllowedPortRange`. + /// `_DEFAULT` defines the port range restrictions for all components without specific overrides. + /// Passing `(0, 0)` for a component scope unset its specific range restriction and inherit range restriction from `_DEFAULT` + /// If `_DEFAULT` is set and a specific scope is unset, that component inherits `_DEFAULT`. + /// Passing `(1025,65535)` for a component scope make port range unrestricted for that component. + + /// | Scope State | Behaviour | + /// | --------------------------------------------------- | ----------------------------------------------------------------------------------------| + /// | Only `_DEFAULT` is set | `_DEFAULT` applies port range restrictions to all components | + /// | `_DEFAULT` and `_WEB_RTC` are both set | `_WEB_RTC` port range restrictions applies to WebRTC; `_DEFAULT` applies to others | + /// | `_WEB_RTC` only is set | `_WEB_RTC` applies port range restrictions only to WebRTC; others unrestricted | + /// | `_DEFAULT` set and `_WEB_RTC` reset to `(0,0)` | `_DEFAULT` applies port range restrictions to all and WebRTC inherits `_DEFAULT` | + /// | `_DEFAULT` set and `_WEB_RTC` set to `(1025,65535)` | `_DEFAULT` applies port range restrictions to all except WebRTC which is unrestricted | + + /// `scope` scope on which restrictions will apply. /// `protocol` Transport protocol on which restrictions will apply. /// `minPort` The minimum allowed port number (inclusive). /// `maxPort` The maximum allowed port number (inclusive). /// HRESULT SetAllowedPortRange( - [in] COREWEBVIEW2_NETWORK_COMPONENT_SCOPE scope, + [in] COREWEBVIEW2_PORT_RANGE_RESTRICTION_SCOPE scope, [in] COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND protocol, [in] INT32 minPort, [in] INT32 maxPort ); - /// Retrieves the allowed port range for the specified transport protocol. - /// Returns the currently configured port range previously set via + /// Retrieves the effective allowed port range for the specified transport protocol. + /// Returns the effective port range previously set via /// `SetAllowedPortRange`. - /// - /// By default, `(0, 0)` is returned, which indicates no restrictions are applied - /// and ports are allocated from the system's ephemeral range (1025-65535 inclusive). /// - /// `GetAllowedPortRange` returns the range explicitly set for the queried scope. - /// If a specific scope is unset, it inherits `_ALL`. - /// Querying `_ALL` only returns `_ALL`; it does not aggregate component-specific settings. - /// If neither `_ALL` nor a component-specific scope is set, the default `(0,0)` (unrestricted) is returned. - - /// | `GetAllowedPortRange` Network Scope query | Returned Range | - /// | ---------------------------------------------------------------- | ----------------------------- | - /// | Pass `_WEB_RTC` when only `_ALL` is set | Returns `_ALL` range | - /// | Pass `_WEB_RTC` when `_WEB_RTC` explicitly set | Returns `_WEB_RTC` range | - /// | Pass `_WEB_RTC` when `_ALL` unset and `_WEB_RTC` unset | Returns `(0, 0)` | - /// | Pass `_WEB_RTC` when `_ALL` set and `_WEB_RTC` reset to `(0, 0)` | Returns `(0, 0)` | - /// | Pass `_ALL` when only `_WEB_RTC` set | Returns `(0,0)` | - - /// `scope` Network scope on which restrictions is applied. + /// `GetEffectiveAllowedPortRange` returns the range explicitly set for the queried scope. + /// If a specific scope is unset, it inherits `_DEFAULT`. + /// Querying `_DEFAULT` only returns `_DEFAULT`; it does not aggregate component-specific settings. + /// If neither `_DEFAULT` nor a component-specific scope is set, the default `(0,0)` (unset) is returned. + + /// | `GetEffectiveAllowedPortRange` Scope query | Returned Range | + /// | -------------------------------------------------------------------- | ----------------------------- | + /// | Pass `_WEB_RTC` when only `_DEFAULT` is set | Returns `_DEFAULT` range | + /// | Pass `_WEB_RTC` when `_WEB_RTC` explicitly set | Returns `_WEB_RTC` range | + /// | Pass `_WEB_RTC` when `_DEFAULT` unset and `_WEB_RTC` unset | Returns `(0, 0)` | + /// | Pass `_WEB_RTC` when `_DEFAULT` set and `_WEB_RTC` reset to `(0, 0)` | Returns `_DEFAULT` | + /// | Pass `_DEFAULT` when only `_WEB_RTC` set | Returns `(0,0)` | + + /// `scope` scope on which restrictions is applied. /// `protocol` Transport protocol on which restrictions is applied. /// `minPort` Receives the minimum allowed port number (inclusive). /// `maxPort` Receives the maximum allowed port number (inclusive). /// - HRESULT GetAllowedPortRange( - [in] COREWEBVIEW2_NETWORK_COMPONENT_SCOPE scope, + HRESULT GetEffectiveAllowedPortRange ( + [in] COREWEBVIEW2_PORT_RANGE_RESTRICTION_SCOPE scope, [in] COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND protocol, [out] INT32* minPort, [out] INT32* maxPort @@ -214,9 +212,9 @@ interface ICoreWebView2StagingEnvironmentOptions10 : IUnknown { ```csharp namespace Microsoft.Web.WebView2.Core { - enum CoreWebview2NetworkComponentScope + enum CoreWebview2PortRangeRestrictionScope { - All = 0, + Default = 0, WebRtc = 1, }; @@ -230,8 +228,8 @@ namespace Microsoft.Web.WebView2.Core [interface_name("Microsoft.Web.WebView2.Core.ICoreWebView2StagingEnvironmentOptions10")] { // ICoreWebView2StagingEnvironmentOptions10 members - void SetAllowedPortRange(CoreWebview2NetworkComponentScope scope, CoreWebView2TransportProtocolKind protocol, Int32 minPort, Int32 maxPort); - void GetAllowedPortRange(CoreWebview2NetworkComponentScope scope, CoreWebView2TransportProtocolKind protocol, out Int32 minPort, out Int32 maxPort); + void SetAllowedPortRange(CoreWebview2PortRangeRestrictionScope scope, CoreWebView2TransportProtocolKind protocol, Int32 minPort, Int32 maxPort); + void GetEffectiveAllowedPortRange(CoreWebview2PortRangeRestrictionScope scope, CoreWebView2TransportProtocolKind protocol, out Int32 minPort, out Int32 maxPort); } } } From 1f4504a32e501797df3fe3b0f9fa0ed6688f3f68 Mon Sep 17 00:00:00 2001 From: Ashutosh Kumar Ray <156680761+ashuray007@users.noreply.github.com> Date: Tue, 28 Oct 2025 19:04:28 +0530 Subject: [PATCH 5/7] Renaming to CoreWebview2AllowedPortRangeScope --- specs/WebRtcPortConfiguration.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/specs/WebRtcPortConfiguration.md b/specs/WebRtcPortConfiguration.md index f183e66a..abcc4305 100644 --- a/specs/WebRtcPortConfiguration.md +++ b/specs/WebRtcPortConfiguration.md @@ -23,7 +23,7 @@ Common scenarios: Usage steps: 1. Create `CoreWebView2EnvironmentOptions`. -2. Call `SetAllowedPortRange` for `COREWEBVIEW2_PORT_RANGE_RESTRICTION_SCOPE_DEFAULT` and `COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP`. +2. Call `SetAllowedPortRange` for `COREWEBVIEW2_ALLOWED_PORT_RANGE_SCOPE_DEFAULT` and `COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP`. 3. Pass the options when creating the WebView2 environment. # Examples @@ -37,12 +37,12 @@ if (options.As(&optionsStaging10) == S_OK) const INT32 udpMin = 50000, udpMax = 55000; CHECK_FAILURE(optionsStaging10->SetAllowedPortRange( - COREWEBVIEW2_PORT_RANGE_RESTRICTION_SCOPE_DEFAULT, + COREWEBVIEW2_ALLOWED_PORT_RANGE_SCOPE_DEFAULT, COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, udpMin, udpMax)); // Get the configured port range CHECK_FAILURE(optionsStaging10->GetEffectiveAllowedPortRange( - COREWEBVIEW2_PORT_RANGE_RESTRICTION_SCOPE_DEFAULT, + COREWEBVIEW2_ALLOWED_PORT_RANGE_SCOPE_DEFAULT, COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, &m_udpPortRange.minPort, &m_udpPortRange.maxPort)); } @@ -65,12 +65,12 @@ if (optionsStaging10 != null) const int udpMin = 50000, udpMax = 55000; optionsStaging10.SetAllowedPortRange( - COREWEBVIEW2_PORT_RANGE_RESTRICTION_SCOPE_DEFAULT, + COREWEBVIEW2_ALLOWED_PORT_RANGE_SCOPE_DEFAULT, COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, udpMin, udpMax); // Get the configured port range optionsStaging10.GetEffectiveAllowedPortRange( - COREWEBVIEW2_PORT_RANGE_RESTRICTION_SCOPE_DEFAULT, + COREWEBVIEW2_ALLOWED_PORT_RANGE_SCOPE_DEFAULT, COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND_UDP, out m_udpPortRange.minPort, out m_udpPortRange.maxPort); } @@ -116,12 +116,12 @@ API Rules and Precedence ``` /// Specifies the scope for port configuration. [v1_enum] -typedef enum COREWEBVIEW2_PORT_RANGE_RESTRICTION_SCOPE { +typedef enum COREWEBVIEW2_ALLOWED_PORT_RANGE_SCOPE { /// Scope applies to all components. - COREWEBVIEW2_PORT_RANGE_RESTRICTION_SCOPE_DEFAULT, + COREWEBVIEW2_ALLOWED_PORT_RANGE_SCOPE_DEFAULT, /// Applies only to WebRTC peer-to-peer connection. - COREWEBVIEW2_PORT_RANGE_RESTRICTION_SCOPE_WEB_RTC, -} COREWEBVIEW2_PORT_RANGE_RESTRICTION_SCOPE; + COREWEBVIEW2_ALLOWED_PORT_RANGE_SCOPE_WEB_RTC, +} COREWEBVIEW2_ALLOWED_PORT_RANGE_SCOPE; /// Specifies the network protocol for port configuration. [v1_enum] @@ -169,7 +169,7 @@ interface ICoreWebView2StagingEnvironmentOptions10 : IUnknown { /// `maxPort` The maximum allowed port number (inclusive). /// HRESULT SetAllowedPortRange( - [in] COREWEBVIEW2_PORT_RANGE_RESTRICTION_SCOPE scope, + [in] COREWEBVIEW2_ALLOWED_PORT_RANGE_SCOPE scope, [in] COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND protocol, [in] INT32 minPort, [in] INT32 maxPort @@ -198,7 +198,7 @@ interface ICoreWebView2StagingEnvironmentOptions10 : IUnknown { /// `maxPort` Receives the maximum allowed port number (inclusive). /// HRESULT GetEffectiveAllowedPortRange ( - [in] COREWEBVIEW2_PORT_RANGE_RESTRICTION_SCOPE scope, + [in] COREWEBVIEW2_ALLOWED_PORT_RANGE_SCOPE scope, [in] COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND protocol, [out] INT32* minPort, [out] INT32* maxPort @@ -212,7 +212,7 @@ interface ICoreWebView2StagingEnvironmentOptions10 : IUnknown { ```csharp namespace Microsoft.Web.WebView2.Core { - enum CoreWebview2PortRangeRestrictionScope + enum CoreWebview2AllowedPortRangeScope { Default = 0, WebRtc = 1, @@ -228,8 +228,8 @@ namespace Microsoft.Web.WebView2.Core [interface_name("Microsoft.Web.WebView2.Core.ICoreWebView2StagingEnvironmentOptions10")] { // ICoreWebView2StagingEnvironmentOptions10 members - void SetAllowedPortRange(CoreWebview2PortRangeRestrictionScope scope, CoreWebView2TransportProtocolKind protocol, Int32 minPort, Int32 maxPort); - void GetEffectiveAllowedPortRange(CoreWebview2PortRangeRestrictionScope scope, CoreWebView2TransportProtocolKind protocol, out Int32 minPort, out Int32 maxPort); + void SetAllowedPortRange(CoreWebview2AllowedPortRangeScope scope, CoreWebView2TransportProtocolKind protocol, Int32 minPort, Int32 maxPort); + void GetEffectiveAllowedPortRange(CoreWebview2AllowedPortRangeScope scope, CoreWebView2TransportProtocolKind protocol, out Int32 minPort, out Int32 maxPort); } } } From 1f5e8ee267530be3a3fc7cff05d50b58336d9c99 Mon Sep 17 00:00:00 2001 From: Ashutosh Kumar Ray <156680761+ashuray007@users.noreply.github.com> Date: Tue, 28 Oct 2025 20:33:59 +0530 Subject: [PATCH 6/7] Minor Fix --- specs/WebRtcPortConfiguration.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specs/WebRtcPortConfiguration.md b/specs/WebRtcPortConfiguration.md index abcc4305..5028d8ad 100644 --- a/specs/WebRtcPortConfiguration.md +++ b/specs/WebRtcPortConfiguration.md @@ -87,7 +87,7 @@ API Rules and Precedence - `_DEFAULT` defines the base port range restrictions for all components without specific overrides. - Passing `(0, 0)` for a component scope unset its specific range restriction and inherit range restriction from `_DEFAULT` - If `_DEFAULT` is set and a specific scope is unset, that component inherits `_DEFAULT`. -- Passing `(0,65535)` for a component scope make port range unrestricted for that component. +- Passing `(1025,65535)` for a component scope make port range unrestricted for that component. | Scope State | Behaviour | | ------------------------------------------ | --------------------------------------------------------------------------------------------- | @@ -95,7 +95,7 @@ API Rules and Precedence | `_DEFAULT` and `_WEB_RTC` are both set | `_WEB_RTC` port range restrictions applies to WebRTC; `_DEFAULT` applies to others | | `_WEB_RTC` only is set | `_WEB_RTC` applies port range restrictions only to WebRTC; others unrestricted | | `_DEFAULT` set and `_WEB_RTC` reset to `(0,0)` | `_DEFAULT` applies port range restrictions to all and WebRTC inherits `_DEFAULT` | -| `_DEFAULT` set and `_WEB_RTC` set to `(0,65535)` | `_DEFAULT` applies port range restrictions to all except WebRTC which is unrestricted | +| `_DEFAULT` set and `_WEB_RTC` set to `(1025,65535)` | `_DEFAULT` applies port range restrictions to all except WebRTC which is unrestricted | 2. Port Range Restriction Scope param in GetEffectiveAllowedPortRange - `GetEffectiveAllowedPortRange` returns the range explicitly set for the queried scope. From f7c01edaa26d190e9ec40b0c4d3b06a88aa936c8 Mon Sep 17 00:00:00 2001 From: Ashutosh Kumar Ray <156680761+ashuray007@users.noreply.github.com> Date: Wed, 29 Oct 2025 09:01:34 +0530 Subject: [PATCH 7/7] Resolving Comments --- specs/WebRtcPortConfiguration.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/specs/WebRtcPortConfiguration.md b/specs/WebRtcPortConfiguration.md index 5028d8ad..d13879bb 100644 --- a/specs/WebRtcPortConfiguration.md +++ b/specs/WebRtcPortConfiguration.md @@ -98,8 +98,9 @@ API Rules and Precedence | `_DEFAULT` set and `_WEB_RTC` set to `(1025,65535)` | `_DEFAULT` applies port range restrictions to all except WebRTC which is unrestricted | 2. Port Range Restriction Scope param in GetEffectiveAllowedPortRange -- `GetEffectiveAllowedPortRange` returns the range explicitly set for the queried scope. -- If a specific scope is unset, it inherits `_DEFAULT`. +- GetEffectiveAllowedPortRange returns the port range to use for the specified scope. +- If the scope is _DEFAULT or if the specified scope is unset, then the _DEFAULT port range is returned. +- A range of (0, 0) means that no port range has been set. - Querying `_DEFAULT` only returns `_DEFAULT`; it does not aggregate component-specific settings. - If neither `_DEFAULT` nor a component-specific scope is set, the default `(0,0)` (unset) is returned. @@ -131,7 +132,7 @@ typedef enum COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND { } COREWEBVIEW2_TRANSPORT_PROTOCOL_KIND; /// Additional options used to create WebView2 Environment to manage port range configuration. -[uuid(6ce30f6b-5dcc-5dc1-9c09-723cf233dbe5), object, pointer_default(unique)] +[uuid(2c0f597d-2958-5a94-82f9-c750cf86cb88), object, pointer_default(unique)] interface ICoreWebView2StagingEnvironmentOptions10 : IUnknown { /// Sets the allowed port range restriction for the specified /// scope and transport protocol. @@ -143,7 +144,7 @@ interface ICoreWebView2StagingEnvironmentOptions10 : IUnknown { /// /// Currently, only WebRTC UDP Port Range restriction is supported. /// - /// `minPort` and `maxPort` must be within the range 1025-65535 (inclusive). + /// `minPort` and `maxPort` must be within the range 1025-65535 (inclusive), or must both be the sentinel value 0. /// `minPort` must be less than or equal to `maxPort`. /// If `minPort` equals `maxPort`, the range represents a single port. /// @@ -179,8 +180,9 @@ interface ICoreWebView2StagingEnvironmentOptions10 : IUnknown { /// Returns the effective port range previously set via /// `SetAllowedPortRange`. /// - /// `GetEffectiveAllowedPortRange` returns the range explicitly set for the queried scope. - /// If a specific scope is unset, it inherits `_DEFAULT`. + /// GetEffectiveAllowedPortRange returns the port range to use for the specified scope. + /// If the scope is _DEFAULT or if the specified scope is unset, then the _DEFAULT port range is returned. + /// A range of (0, 0) means that no port range has been set. /// Querying `_DEFAULT` only returns `_DEFAULT`; it does not aggregate component-specific settings. /// If neither `_DEFAULT` nor a component-specific scope is set, the default `(0,0)` (unset) is returned.