コード例 #1
0
        private void ValidateUsingNetworkTime()
        {
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                return;
            }

            var  sntpDisable = Environment.GetEnvironmentVariable("RAVENDB_SNTP_DISABLE");
            bool result;

            if (bool.TryParse(sntpDisable, out result) && result)
            {
                return;
            }

            sntpClient.GetDateAsync()
            .ContinueWith(task =>
            {
                if (task.IsFaulted)
                {
                    Logger.WarnException("Failed to get network time, can't tell if the OS time is accurate", task.Exception);
                    return;
                }
                if (task.Result > ExpirationDate)
                {
                    RaiseLicenseInvalidated();     // will explicitly crash the system if event is not subscribed
                }
            });
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: jjchiw/ravendb
		private static void Main()
		{
			//Repro();

			var sntpClient = new SntpClient(new[]
			{
				"time.nist.gov",
				"time-nw.nist.gov",
				"time-a.nist.gov",
				"time-b.nist.gov",
				"time-a.timefreq.bldrdoc.gov",
				"time-b.timefreq.bldrdoc.gov",
				"time-c.timefreq.bldrdoc.gov",
				"utcnist.colorado.edu",
				"nist1.datum.com",
				"nist1.dc.certifiedtime.com",
				"nist1.nyc.certifiedtime.com",
			});

			Console.WriteLine(sntpClient.GetDateAsync().Result);
			Console.ReadLine();
		}
コード例 #3
0
        private void ValidateUsingNetworkTime()
        {
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                return;
            }

            var sntp = new SntpClient(TimeServers);

            sntp.GetDateAsync()
            .ContinueWith(task =>
            {
                if (task.IsFaulted)
                {
                    Logger.WarnException("Failed to get network time, can't tell if the OS time is accurate", task.Exception);
                    return;
                }
                if (task.Result > ExpirationDate)
                {
                    RaiseLicenseInvalidated();                             // will explicitly crash the system if event is not subscribed
                }
            });
        }
コード例 #4
0
        private void ValidateUsingNetworkTime()
        {
            if (!NetworkInterface.GetIsNetworkAvailable())
                return;

            var sntp = new SntpClient(TimeServers);
            sntp.GetDateAsync()
                .ContinueWith(task =>
                {
                    if (task.IsFaulted)
                    {
                        Logger.WarnException("Failed to get network time, can't tell if the OS time is accurate", task.Exception);
                        return;
                    }
                    if (task.Result > ExpirationDate)
                        RaiseLicenseInvalidated(); // will explicitly crash the system if event is not subscribed
                });
        }