我正在使用Microsoft WebView2开发WebRTC应用程序。我希望将edge://flags/#enable-webrtc-hide-local-ips-with-mdns标志的值从“默认”更改为“禁用”。
根据MSDN https://learn.microsoft.com/en-us/microsoft-edge/hosting/webview2/reference/webview2.idl,API CreateWebView2EnvironmentWithDetails有一个参数additionalBrowserArguments,它可以更改铬标志。我尝试过以下几个根本不起作用的值。
WCHAR args[] = TEXT("--enable-webrtc-hide-local-ips-with-mdns=0");
WCHAR args[] = TEXT("--disable-webrtc-hide-local-ips-with-mdns");
WCHAR args[] = TEXT("--edge-webview-switches=\"--enable-webrtc-hide-local-ips-with-mdns=0\"");
WCHAR args[] = TEXT("--edge-webview-switches=--enable-webrtc-hide-local-ips-with-mdns=0");
WCHAR args[] = TEXT("--edge-webview-switches=--disable-webrtc-hide-local-ips-with-mdns");
上面的args不能在API中工作。
CreateWebView2EnvironmentWithDetails(nullptr, nullptr, args, callback_handler);
我在窗口10上使用的是80.0.315.0 (正式构建)金丝雀(64位)版本的Microsoft。
提前感谢
发布于 2019-11-21 05:44:26
根据MSDN https://learn.microsoft.com/en-us/microsoft-edge/hosting/webview2/reference/webview2.idl,API CreateWebView2EnvironmentWithDetails有一个参数additionalBrowserArguments,它可以更改铬标志。我尝试过以下几个根本不起作用的值。
我已经和官方样品和过程资源管理器试过了。这些论点被正确地添加到了过程中:
它不能工作的原因是因为没有这样的开关:
这是开关表在运行带标志的铬找到的。我在列表中搜索,没有找到一个名为--enable-webrtc-hide-local-ips-with-mdns
的开关。
当我通过edge://flags/#enable-webrtc-hide-local-ips-with-mdns
手动启用标志并检查它时,开关如下所示:
所以答案很清楚,您应该将参数从--enable-webrtc-hide-local-ips-with-mdns
更改为--enable-features=WebRtcHideLocalIpsWithMdns
发布于 2019-10-29 10:09:56
我在文档中找到了这个信息。
“除了启动浏览器进程的第一个WebView之外,不能保证应用这些开关。如果指定的交换机解析失败,它们将被忽略。nullptr将运行没有标志的浏览器进程。”
参考资料:
您还可以尝试从Edge (铬)浏览器中提供有关此问题的反馈。
发布于 2022-06-17 08:56:45
此代码演示如何在匿名代理中使用WebView2并防止WebRTC泄漏。
消除WebRTC泄漏的最简单方法是在应用程序第一次启动时更改注册表中的策略。这可以在LocalMachine或CurrentUser级别完成。CurrentUser是最好的。https://admx.help/?Category=EdgeChromium&Policy=Microsoft.Policies.Edge::WebRtcLocalhostIpHandling
将WebRtcLocalhostIpHandling注册表项设置为disable_non_proxied_udp将防止IP泄漏。
Dim RegKey = My.Computer.Registry.CurrentUser.CreateSubKey("Software\Policies\Microsoft\Edge\WebView2")
RegKey.SetValue("WebRtcLocalhostIpHandling", "disable_non_proxied_udp", Microsoft.Win32.RegistryValueKind.String)
我在窗体上运行下面的代码来清理
Dim RegKey = My.Computer.Registry.CurrentUser.CreateSubKey("Software\Policies\Microsoft\Edge")
If RegKey.GetSubKeyNames.Contains("WebView2") Then RegKey.DeleteSubKey("WebView2")
相同的代码完全适用于Edge:
Dim RegKey = My.Computer.Registry.CurrentUser.CreateSubKey("Software\Policies\Microsoft\Edge")
RegKey.SetValue("WebRtcLocalhostIpHandling", "disable_non_proxied_udp", Microsoft.Win32.RegistryValueKind.String)
我在窗体上运行下面的代码来清理
Dim RegKey = My.Computer.Registry.CurrentUser.CreateSubKey("Software\Policies\Microsoft\Edge")
If RegKey.GetValueNames.Contains("WebRtcLocalhostIpHandling") Then RegKey.DeleteValue("WebRtcLocalhostIpHandling")
您还可以使用下面的代码来防止LocalIP泄漏(现在默认情况下应该阻止这种泄漏),并强制WebView2流量通过您选择的代理服务器。
Dim TargetURL As String = "https://proxy6.net/en/privacy"
Dim Proxy As String = "1.1.1.1:8080"
Dim WV As Microsoft.Web.WebView2.WinForms.WebView2 = New Microsoft.Web.WebView2.WinForms.WebView2
WV.Dock = DockStyle.Fill
Form1.Controls.Add(WV)
AddHandler WV.NavigationCompleted, AddressOf WV_NavigationCompleted
Dim Options As CoreWebView2EnvironmentOptions = New CoreWebView2EnvironmentOptions()
' Force the traffic through a proxy server?
If Proxy <> "" Then Options.AdditionalBrowserArguments = "--proxy-server=" & Proxy
' Prevent WebRTC leaks of local IP addresses
Options.AdditionalBrowserArguments &= " --enable-features=WebRtcHideLocalIpsWithMdns"
Dim env As CoreWebView2Environment = Await CoreWebView2Environment.CreateAsync(Nothing, Nothing, Options)
Await WV.EnsureCoreWebView2Async(env)
' Any javascript we want to inject / run for every page?
Await WV.CoreWebView2.AddScriptToExecuteOnDocumentCreatedAsync("//Javascript to add / run each time a page is created ")
WV.Source = New Uri(TargetURL, UriKind.Absolute)
https://stackoverflow.com/questions/58604537
复制相似问题