|
1 |
| -using System.Net.NetworkInformation; |
| 1 | +using System; |
| 2 | +using System.Net.NetworkInformation; |
2 | 3 | using System.Threading.Tasks;
|
3 | 4 | using System.Windows.Forms;
|
4 | 5 |
|
@@ -35,21 +36,30 @@ public async void Notify()
|
35 | 36 | locationRegion = locationRegion.ReplaceLineEndings("");
|
36 | 37 | locationCountry = locationCountry.ReplaceLineEndings("");
|
37 | 38 |
|
38 |
| - if (locationCity == locationRegion) |
| 39 | + if (String.IsNullOrEmpty(locationCountry)) |
| 40 | + message = "Location: N/A"; |
| 41 | + else if (locationCity == locationRegion) |
39 | 42 | message = $"Location: {locationRegion}, {locationCountry}\n";
|
40 | 43 | else
|
41 | 44 | message = $"Location: {locationCity}, {locationRegion}, {locationCountry}\n";
|
42 | 45 |
|
43 |
| - PingReply ping = await new Ping().SendPingAsync(machineAddress); |
44 |
| - |
45 |
| - // UDMUX protected servers reject ICMP packets and so the ping fails |
46 |
| - // we could get around this by doing a UDP ping but ehhhhhhhhhhhhh |
47 |
| - if (ping.Status == IPStatus.Success) |
48 |
| - message += $"Latency: ~{ping.RoundtripTime}ms"; |
| 46 | + // UDMUX protected servers don't respond to ICMP packets and so the ping fails |
| 47 | + // we could probably get around this by doing a UDP latency test but ehhhhhhhh |
| 48 | + if (_activityWatcher.ActivityMachineUDMUX) |
| 49 | + { |
| 50 | + message += "Latency: N/A (Server is UDMUX protected)"; |
| 51 | + } |
49 | 52 | else
|
50 |
| - message += "Latency: N/A (server may be UDMUX protected)"; |
| 53 | + { |
| 54 | + PingReply ping = await new Ping().SendPingAsync(machineAddress); |
| 55 | + |
| 56 | + if (ping.Status == IPStatus.Success) |
| 57 | + message += $"Latency: ~{ping.RoundtripTime}ms"; |
| 58 | + else |
| 59 | + message += $"Latency: N/A (Code {ping.Status})"; |
| 60 | + } |
51 | 61 |
|
52 |
| - App.Logger.WriteLine($"[ServerNotifier::Notify] {message}"); |
| 62 | + App.Logger.WriteLine($"[ServerNotifier::Notify] {message.ReplaceLineEndings("\\n")}"); |
53 | 63 |
|
54 | 64 | NotifyIcon notification = new()
|
55 | 65 | {
|
|
0 commit comments