Skip to content

Commit 3983182

Browse files
committed
Add WebClient support
Haven't tested too much, but seems to work fine. Also edited a few URL's that were still on http instead of https.
1 parent 9070445 commit 3983182

8 files changed

Lines changed: 293 additions & 17 deletions

File tree

‎ConfigGUI/MainForm.Designer.cs‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎fCraft/Commands/CpeCommands.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@ static void CustomBlockHandler(Player p, CommandReader cmd, bool global) {
13691369
case "tex":
13701370
case "texture":
13711371
case "terrain":
1372-
p.Message("Terrain IDs: &9http://123DMWM.com/ID-Overlay.png");
1372+
p.Message("Terrain IDs: &9https://123DMWM.com/ID-Overlay.png");
13731373
p.Message("Current world terrain: &9{0}", p.World.Texture.CaselessEquals("default") ? Server.DefaultTerrain : p.World.Texture);
13741374
break;
13751375
default:

‎fCraft/Commands/MaintenanceCommands.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,14 +1367,14 @@ static void UpdatesHandler(Player player, CommandReader cmd) {
13671367
player.Message(" &7" + latest.ToLongDateString() + " &Sat &7" + latest.ToLongTimeString());
13681368
} catch (Exception ex) {
13691369
Logger.Log(LogType.Error, "Updates.UpdaterHandler:" + ex);
1370-
player.Message("Cannot access http://123DMWM.com/ at the moment.");
1370+
player.Message("Cannot access https://123DMWM.com/ at the moment.");
13711371
}
13721372

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

1377-
player.Message("Download updated Zip here: &9http://123DMWM.com/ProCraft/Builds/Latest.zip");
1377+
player.Message("Download updated Zip here: &9https://123DMWM.com/ProCraft/Builds/Latest.zip");
13781378
}
13791379
#endregion
13801380
#region AutoRankCheck

‎fCraft/Commands/WorldCommands.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ public static bool parseUrl(ref string urlString, Player player) {
11391139
if (urlString.StartsWith("++")) urlString = "http://i.imgur.com/" + urlString.Substring(2) + ".png";
11401140
if (!urlString.CaselessStarts("http://") && !urlString.CaselessStarts("https://")) urlString = "http://" + urlString;
11411141

1142-
if (!urlString.CaselessStarts("http://i.imgur.com/") && !urlString.CaselessStarts("http://123DMWM.com/")) {
1142+
if (!urlString.CaselessStarts("http://i.imgur.com/") && !urlString.CaselessStarts("https://123DMWM.com/")) {
11431143
player.Message("For safety reasons we only accept images uploaded to &9http://imgur.com/ &SSorry for this inconvenience.");
11441144
player.Message(" You cannot use: &9" + urlString);
11451145
return false;

‎fCraft/Network/Heartbeat.cs‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ public sealed class HeartbeatData {
246246
internal HeartbeatData([NotNull] Uri heartbeatUri) {
247247
if (heartbeatUri == null) throw new ArgumentNullException("heartbeatUri");
248248
IsPublic = ConfigKey.IsPublic.Enabled();
249+
IsWeb = ConfigKey.IsWeb.Enabled();
249250
MaxPlayers = ConfigKey.MaxPlayers.GetInt();
250251
PlayerCount = Server.CountPlayers(false);
251252
Port = Server.Port;
@@ -286,6 +287,9 @@ internal HeartbeatData([NotNull] Uri heartbeatUri) {
286287
/// <summary> Whether or not the server should be listed on minecraft.net </summary>
287288
public bool IsPublic { get; set; }
288289

290+
/// <summary> Whether or not the server should allow Web Clients </summary>
291+
public bool IsWeb { get; set; }
292+
289293
/// <summary> Version of the classic minecraft protocol that this server is using. </summary>
290294
public int ProtocolVersion { get; set; }
291295

@@ -298,15 +302,16 @@ internal HeartbeatData([NotNull] Uri heartbeatUri) {
298302
internal Uri CreateUri() {
299303
UriBuilder ub = new UriBuilder(HeartbeatUri);
300304
StringBuilder sb = new StringBuilder();
301-
sb.AppendFormat("public={0}&max={1}&users={2}&port={3}&version={4}&salt={5}&name={6}&software={7}",
305+
sb.AppendFormat("public={0}&max={1}&users={2}&port={3}&version={4}&salt={5}&name={6}&software={7}&web={8}",
302306
IsPublic,
303307
MaxPlayers,
304308
PlayerCount,
305309
Port,
306310
ProtocolVersion,
307311
Uri.EscapeDataString(Salt),
308312
Uri.EscapeDataString(ServerName),
309-
Server.Software.Replace("&", "%26"));
313+
Server.Software.Replace("&", "%26"),
314+
IsWeb);
310315
foreach (var pair in CustomData) {
311316
sb.AppendFormat("&{0}={1}",
312317
Uri.EscapeDataString(pair.Key),

‎fCraft/Network/Player.Handshake.cs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ bool HandleOpcode(byte opcode) {
3030
return false;
3131

3232
case (byte)'G': // WoM GET requests
33-
return false;
33+
stream = new WebSocketStream(stream);
34+
reader = new PacketReader(stream);
35+
writer = new PacketWriter(stream);
36+
return reader.ReadByte() == (byte)OpCode.Handshake;
3437

3538
default:
3639
if (CheckModernSMP(opcode)) return false;
@@ -93,7 +96,7 @@ public string CheckForFavicon() {
9396
string favicon = ImageFromFavicon();
9497
if (favicon != null) return favicon;
9598

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

0 commit comments

Comments
 (0)