NTP Analyzer  0.8.2
Analyze the operation of time servers
ExactlyTimeServer.cs
Go to the documentation of this file.
1 //
2 // Copyright (c) 2013-2017 Carsten Sonne Larsen <cs@innolan.net>
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a copy
5 // of this software and associated documentation files (the "Software"), to deal
6 // in the Software without restriction, including without limitation the rights
7 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 // copies of the Software, and to permit persons to whom the Software is
9 // furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 // THE SOFTWARE.
21 
22 using System;
23 using System.Net;
24 using Newtonsoft.Json;
25 
26 // ReSharper disable UnusedMember.Global
27 // ReSharper disable MemberCanBePrivate.Global
28 // ReSharper disable UnusedAutoPropertyAccessor.Global
29 
30 namespace Ntp.Analyzer.Objects
31 {
33  {
37  [JsonProperty("url")]
38  public string Url { get; set; }
39 
43  [JsonProperty("iso")]
44  public string Iso { get; set; }
45 
46  public override string Country => Iso;
47 
51  [JsonProperty("location")]
52  public string LocationRaw { get; set; }
53 
54  public override string Location => LocationRaw;
55 
56  public override string DisplayLocation => Location.Substring(0, 60);
57 
61  [JsonProperty("sponsor")]
62  public string Sponsor { get; set; }
63 
64  public override string Organization => Sponsor;
65 
71  [JsonProperty("service_area")]
72  public string ServiceAreaRaw { get; set; }
73 
74  public override string ServiceArea => ServiceAreaRaw;
75 
76  [JsonProperty("access")]
77  public string Access { get; set; }
78 
79  public override string AccessPolicy => Access;
80 
86  [JsonProperty("notify")]
87  public string NotifyRaw { get; set; }
88 
89  public override bool ShouldNotify => NotifyRaw.Trim() == "1";
90 
95  [JsonProperty("modified")]
96  public long ModifiedRaw { get; set; }
97 
101  public DateTime Modified => new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(ModifiedRaw);
102 
103  public override DateTime Updated => Modified;
104 
109  [JsonProperty("hostname")]
110  public string Hostname { get; set; }
111 
112  public override string Name => Hostname;
113 
118  [JsonProperty("ipv4")]
119  public string Ipv4 { get; set; }
120 
121  public override IPAddress Address
122  {
123  get
124  {
125  IPAddress ip;
126  return IPAddress.TryParse(Ipv4, out ip) ? ip : null;
127  }
128  }
129 
133  [JsonProperty("ipv6")]
134  public string Ipv6 { get; set; }
135 
136  public override string V6Address => Ipv6;
137 
141  [JsonProperty("usedns")]
142  public string UseDns { get; set; }
143 
144  public override bool ShouldUseDns => UseDns.Trim() == "1";
145 
146  public override bool IsPoolMember => false;
147 
151  [JsonProperty("access_details")]
152  public string AccessDetailsRaw { get; set; }
153 
154  public override string AccessDetails => AccessDetailsRaw;
155 
160  [JsonProperty("contact")]
161  public string ContactRaw { get; set; }
162 
163  public override string Contact => ContactRaw;
164 
170  [JsonProperty("dns_a")]
171  public string[] DnsA { get; set; }
172 
177  [JsonProperty("dns_aaaa")]
178  public string[] DnsAaaa { get; set; }
179 
185  [JsonProperty("status")]
186  public string[] Status { get; set; }
187 
192  [JsonProperty("success")]
193  public ExactlySuccess Success { get; set; }
194 
198  [JsonProperty("id")]
199  public int IdRaw { get; set; }
200 
204  [JsonProperty("successes")]
205  public int Successes { get; set; }
206 
210  [JsonProperty("failures")]
211  public int Failures { get; set; }
212 
216  [JsonProperty("up")]
217  public int UpRaw { get; set; }
218 
222  public bool IsUp => UpRaw == 1;
223 
228  [JsonProperty("contacted")]
229  public long ContactedRaw { get; set; }
230 
234  public DateTime Contacted => new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(ContactedRaw);
235 
236  public override int Stratum => 0;
237 
238  public override string Geo => string.Empty;
239 
240  public override string Server => string.Empty;
241 
242  public override string AutoKey => string.Empty;
243 
244  public override string SymKey => string.Empty;
245 
246  public override string SymUrl => string.Empty;
247 
248  public override string ProviderPage => string.Empty;
249 
250  public override string ProviderUrl => string.Empty;
251 
252  public void SetOrgId(int id)
253  {
254  SetId(id);
255  NewObject = true;
256  }
257  }
258 }