Skip to content
Permalink
Browse files

Also make /updates timeout after 10 seconds

  • Loading branch information...
UnknownShadow200 committed Jul 4, 2017
1 parent 3cd6d70 commit 1da2e1c9a9ef77d6bd595a4498c53220d9999286
Showing with 12 additions and 8 deletions.
  1. +12 −8 fCraft/Commands/MaintenanceCommands.cs
@@ -1347,24 +1347,28 @@ static void SaveHandler(Player player, CommandReader cmd)
};

static void UpdatesHandler(Player player, CommandReader cmd) {
DateTime latest = DateTime.UtcNow, current = DateTime.UtcNow;
current = File.GetLastWriteTime(Process.GetCurrentProcess().MainModule.FileName);
TimeSpan zipTime = TimeSpan.Zero, currentTime = (DateTime.Now - current);
DateTime latest = DateTime.UtcNow;
DateTime current = File.GetLastWriteTimeUtc(Process.GetCurrentProcess().MainModule.FileName);

try {
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://123DMWM.tk/ProCraft/Builds/Latest.zip?");
Uri uri = new Uri("https://123DMWM.tk/ProCraft/Builds/Latest.zip?");
HttpWebRequest request = HttpUtil.CreateRequest(uri, TimeSpan.FromSeconds(10));
request.Method = "HEAD";

using (var resp = (HttpWebResponse)request.GetResponse()) {
latest = resp.LastModified;
latest = resp.LastModified.ToUniversalTime();
}
zipTime = (DateTime.Now - latest);
player.Message("ProCraft.zip last update (&7" + zipTime.ToMiniString() + " &Sago):");

TimeSpan zipDelta = DateTime.UtcNow - latest;
player.Message("ProCraft.zip last update (&7" + zipDelta.ToMiniString() + " &Sago):");
player.Message(" &7" + latest.ToLongDateString() + " &Sat &7" + latest.ToLongTimeString());
} catch (Exception ex) {
Logger.Log(LogType.Error, "Updates.UpdaterHandler:" + ex);
player.Message("Cannot access http://123dmwm.tk/ at the moment.");
}
player.Message("Server file last update (&7" + currentTime.ToMiniString() + " &Sago):");

TimeSpan currentDelta = DateTime.UtcNow - current;
player.Message("Server file last update (&7" + currentDelta.ToMiniString() + " &Sago):");
player.Message(" &7" + current.ToLongDateString() + " &Sat &7" + current.ToLongTimeString());

player.Message("Download updated Zip here: &9http://123DMWM.tk/ProCraft/Builds/Latest.zip");

0 comments on commit 1da2e1c

Please sign in to comment.
You can’t perform that action at this time.