首页 > 解决方案 > 在“dotnet”核心3.0 cli util中禁用遥测?

问题描述

dotnet如何在 linux中完全禁用(或防火墙)cli util 遥测?

设置环境变量:

    echo "export DOTNET_CLI_TELEMETRY_OPTOUT=1"

仅在使用参数开始时有助于禁用遥测dotnet

    dotnet build
    dotnet pack
    dotnet run

但如果是前。使用参数调用dotnet

    dotnet new
    dotnet nuget
    ...

无论如何都会发送遥测数据。(文档:https ://docs.microsoft.com/en-us/dotnet/core/tools/telemetry#collected-options )

任何想法,选项?nftables/proxychains 的白色规则?

标签: .net.net-core

解决方案


我正在阅读和解释https://docs.microsoft.com/en-us/dotnet/core/tools/telemetry#collected-options不同:

某些命令发送附加数据。

在我看来,这意味着“如果启用遥测,这些命令会发送额外的数据。如果禁用遥测,则不会发送任何数据”。

Telemetry的实现似乎符合我的理解:

首先,环境变量用于启用(或实际上禁用)遥测:

        Enabled = !environmentProvider.GetEnvironmentVariableAsBool(TelemetryOptout, false) && PermissionExists(sentinel);

然后,公共 APIEnabled用来决定做任何事情:

    public void TrackEvent(string eventName, IDictionary<string, string> properties,
        IDictionary<string, double> measurements)
    {
        if (!Enabled)
        {
            return;
        }

        //continue the task in different threads
        _trackEventTask = _trackEventTask.ContinueWith(
            x => TrackEventTask(eventName, properties, measurements)
        );
    }

    public void Flush()
    {
        if (!Enabled || _trackEventTask == null)
        {
            return;
        }

        _trackEventTask.Wait();
    }

    public void ThreadBlockingTrackEvent(string eventName, IDictionary<string, string> properties, IDictionary<string, double> measurements)
    {
        if (!Enabled)
        {
            return;
        }
        TrackEventTask(eventName, properties, measurements);
    }

在我看来,一切都应该是无操作的。如果您能找到任何相反的证据,请按照您链接的页面的建议进行操作:

保护您的隐私对我们很重要。如果您怀疑遥测正在收集敏感数据或数据处理不安全或不当,请在 dotnet/cli 存储库中提出问题或发送电子邮件至 dotnet@microsoft.com 进行调查。

我已使用此脚本来检查在以前版本的 .NET Coretdcpdump中没有显示任何发送到的遥测数据:dc.services.visualstduio.com

https://github.com/redhat-developer/dotnet-regular-tests/blob/master/telemetry-is-off-by-default/test-telemetry-tcpdump.sh

我还没有测试过 .NET Core 3.0。


推荐阅读