コード例 #1
0
        public SyslogTcpSink(SyslogTcpConfig config, BatchConfig batchConfig)
            : base(batchConfig.BatchSizeLimit, batchConfig.Period, batchConfig.QueueSizeLimit)
        {
            this.formatter       = config.Formatter;
            this.framer          = config.Framer;
            this.Host            = config.Host;
            this.Port            = config.Port;
            this.enableKeepAlive = config.KeepAlive;

            this.secureProtocols        = config.SecureProtocols;
            this.useTls                 = config.SecureProtocols != SslProtocols.None;
            this.certValidationCallback = config.CertValidationCallback;

            if (config.CertProvider?.Certificate != null)
            {
                this.clientCert = new X509Certificate2Collection(new [] { config.CertProvider.Certificate });
            }

            // You can't set socket options *and* connect to an endpoint using a hostname - if
            // keep-alive is enabled, resolve the hostname to an IP
            // See https://github.com/dotnet/corefx/issues/26840
            if (config.KeepAlive && RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                if (!IPAddress.TryParse(config.Host, out var addr))
                {
                    addr      = Dns.GetHostAddresses(config.Host).First(x => x.AddressFamily == AddressFamily.InterNetwork);
                    this.Host = addr.ToString();
                }
            }
        }
コード例 #2
0
        public SyslogTcpSink(SyslogTcpConfig config)
        {
            this.formatter          = config.Formatter;
            this.framer             = config.Framer;
            this.Host               = config.Host;
            this.checkHostIPAddress = config.CheckHostIPAddress;
            this.Port               = config.Port;
            this.enableKeepAlive    = config.KeepAlive;
            this.disableDualMode    = config.DisableDualMode;

            this.secureProtocols            = config.SecureProtocols;
            this.useTls                     = config.SecureProtocols != SslProtocols.None;
            this.acceptAllCertifications    = config.AcceptAllCertifications;
            this.certValidationCallback     = config.AcceptAllCertifications ? new RemoteCertificateValidationCallback(AcceptAllCertifications) : config.CertValidationCallback;
            this.checkCertificateRevocation = config.CheckCertificateRevocation;
            this.tlsAuthenticationTimeout   = config.TlsAuthenticationTimeout;

            if (config.CertProvider?.Certificate != null)
            {
                this.clientCert = new X509Certificate2Collection(new [] { config.CertProvider.Certificate });
            }

            // You can't set socket options *and* connect to an endpoint using a hostname - if
            // keep-alive is enabled, resolve the hostname to an IP
            // See https://github.com/dotnet/corefx/issues/26840
            if (config.KeepAlive && RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                if (!IPAddress.TryParse(config.Host, out var addr))
                {
                    addr      = Dns.GetHostAddresses(config.Host).First(x => x.AddressFamily == AddressFamily.InterNetwork);
                    this.Host = addr.ToString();
                }
            }
        }