Navigation Menu

Skip to content

Commit

Permalink
Add WebClient support
Browse files Browse the repository at this point in the history
Haven't tested too much, but seems to work fine.
Also edited a few URL's that were still on http instead of https.
  • Loading branch information
123DMWM committed Dec 2, 2019
1 parent 9070445 commit 3983182
Show file tree
Hide file tree
Showing 8 changed files with 293 additions and 17 deletions.
2 changes: 1 addition & 1 deletion ConfigGUI/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion fCraft/Commands/CpeCommands.cs
Expand Up @@ -1369,7 +1369,7 @@ static class CpeCommands {
case "tex":
case "texture":
case "terrain":
p.Message("Terrain IDs: &9http://123DMWM.com/ID-Overlay.png");
p.Message("Terrain IDs: &9https://123DMWM.com/ID-Overlay.png");
p.Message("Current world terrain: &9{0}", p.World.Texture.CaselessEquals("default") ? Server.DefaultTerrain : p.World.Texture);
break;
default:
Expand Down
4 changes: 2 additions & 2 deletions fCraft/Commands/MaintenanceCommands.cs
Expand Up @@ -1367,14 +1367,14 @@ static void SaveHandler(Player player, CommandReader cmd)
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.com/ at the moment.");
player.Message("Cannot access https://123DMWM.com/ at the moment.");
}

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.com/ProCraft/Builds/Latest.zip");
player.Message("Download updated Zip here: &9https://123DMWM.com/ProCraft/Builds/Latest.zip");
}
#endregion
#region AutoRankCheck
Expand Down
2 changes: 1 addition & 1 deletion fCraft/Commands/WorldCommands.cs
Expand Up @@ -1139,7 +1139,7 @@ class BlockDBCounterProcessor : IBlockDBQueryProcessor {
if (urlString.StartsWith("++")) urlString = "http://i.imgur.com/" + urlString.Substring(2) + ".png";
if (!urlString.CaselessStarts("http://") && !urlString.CaselessStarts("https://")) urlString = "http://" + urlString;

if (!urlString.CaselessStarts("http://i.imgur.com/") && !urlString.CaselessStarts("http://123DMWM.com/")) {
if (!urlString.CaselessStarts("http://i.imgur.com/") && !urlString.CaselessStarts("https://123DMWM.com/")) {
player.Message("For safety reasons we only accept images uploaded to &9http://imgur.com/ &SSorry for this inconvenience.");
player.Message(" You cannot use: &9" + urlString);
return false;
Expand Down
9 changes: 7 additions & 2 deletions fCraft/Network/Heartbeat.cs
Expand Up @@ -246,6 +246,7 @@ public sealed class HeartbeatData {
internal HeartbeatData([NotNull] Uri heartbeatUri) {
if (heartbeatUri == null) throw new ArgumentNullException("heartbeatUri");
IsPublic = ConfigKey.IsPublic.Enabled();
IsWeb = ConfigKey.IsWeb.Enabled();
MaxPlayers = ConfigKey.MaxPlayers.GetInt();
PlayerCount = Server.CountPlayers(false);
Port = Server.Port;
Expand Down Expand Up @@ -286,6 +287,9 @@ public sealed class HeartbeatData {
/// <summary> Whether or not the server should be listed on minecraft.net </summary>
public bool IsPublic { get; set; }

/// <summary> Whether or not the server should allow Web Clients </summary>
public bool IsWeb { get; set; }

/// <summary> Version of the classic minecraft protocol that this server is using. </summary>
public int ProtocolVersion { get; set; }

Expand All @@ -298,15 +302,16 @@ public sealed class HeartbeatData {
internal Uri CreateUri() {
UriBuilder ub = new UriBuilder(HeartbeatUri);
StringBuilder sb = new StringBuilder();
sb.AppendFormat("public={0}&max={1}&users={2}&port={3}&version={4}&salt={5}&name={6}&software={7}",
sb.AppendFormat("public={0}&max={1}&users={2}&port={3}&version={4}&salt={5}&name={6}&software={7}&web={8}",
IsPublic,
MaxPlayers,
PlayerCount,
Port,
ProtocolVersion,
Uri.EscapeDataString(Salt),
Uri.EscapeDataString(ServerName),
Server.Software.Replace("&", "%26"));
Server.Software.Replace("&", "%26"),
IsWeb);
foreach (var pair in CustomData) {
sb.AppendFormat("&{0}={1}",
Uri.EscapeDataString(pair.Key),
Expand Down
7 changes: 5 additions & 2 deletions fCraft/Network/Player.Handshake.cs
Expand Up @@ -30,7 +30,10 @@ public sealed partial class Player {
return false;

case (byte)'G': // WoM GET requests
return false;
stream = new WebSocketStream(stream);
reader = new PacketReader(stream);
writer = new PacketWriter(stream);
return reader.ReadByte() == (byte)OpCode.Handshake;

default:
if (CheckModernSMP(opcode)) return false;
Expand Down Expand Up @@ -93,7 +96,7 @@ public sealed partial class Player {
string favicon = ImageFromFavicon();
if (favicon != null) return favicon;

// Base64 encoding of http://123DMWM.com/I/299.png;
// Base64 encoding of https://123DMWM.com/I/299.png;
return "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsI" +
"BFShKgAAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xMK0KCsAAAAoJSURBVHhe7ZoJcFVXHcYf27CWpZ2OzrS2Tkft1KpTR6u12mrV" +
"Wu02ShdrVSwudFoHqZbF0BSEkLAGSMIOBcK+rwUKlFUoYMAGyjphCWEPi8O+c/x+592TuWYCPW8LCeN/5jdvybnnnO87/7Pc+xIxHhGJRCqdm" +
Expand Down

0 comments on commit 3983182

Please sign in to comment.