Skip to content

Commit

Permalink
fix: internet status check logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Laeng committed Sep 5, 2024
1 parent 93e0f42 commit 9a1f788
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions SCTools/SCTool_Redesigned/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Net.Http;
using System.Net.NetworkInformation;
using System.Reflection;
using System.Windows;
Expand Down Expand Up @@ -153,28 +154,18 @@ private static bool IsOnline()
{
Logger.Info("Check Internet connection.");

var pass = new Ping().Send("168.126.63.1", 1000).Status.Equals(IPStatus.Success); //KT DNS IP

if (!pass)
try
{
Logger.Info("ICMP port is not available, Try different way...");

try
{
pass = HttpNetClient.Client.GetStringAsync("https://api.ipify.org").Result.Length > 0;

}
catch
{
Logger.Warn("FAIL: Internet unavailable.");

pass = false;
}
using var client = new HttpClient();
var content = new StringContent(string.Empty);
var response = client.PostAsync("https://sc.galaxyhub.kr/api/v4/patcher/mode", content).Result;

return response.IsSuccessStatusCode;
}
catch
{
return false;
}

Logger.Info("SUCCESS: Internet available.");
return pass;
}
}
}

0 comments on commit 9a1f788

Please sign in to comment.