diff --git a/GUI/PropertyWindow/PropertyWindow.Relay.cs b/GUI/PropertyWindow/PropertyWindow.Relay.cs
index 683a75a22..33ab73b1a 100644
--- a/GUI/PropertyWindow/PropertyWindow.Relay.cs
+++ b/GUI/PropertyWindow/PropertyWindow.Relay.cs
@@ -134,7 +134,7 @@ namespace MCGalaxy.Gui {
}
void dis_lnkHelp_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
- Program.OpenBrowser("https://github.com/UnknownShadow200/MCGalaxy/wiki/Discord-relay-bot/");
+ Program.OpenBrowser(Updater.SourceURL + "/wiki/Discord-relay-bot/");
}
}
}
diff --git a/MCGalaxy/Commands/Maintenance/CmdPlayerEdit.cs b/MCGalaxy/Commands/Maintenance/CmdPlayerEdit.cs
index 55d1995f2..7e49a326d 100644
--- a/MCGalaxy/Commands/Maintenance/CmdPlayerEdit.cs
+++ b/MCGalaxy/Commands/Maintenance/CmdPlayerEdit.cs
@@ -86,7 +86,7 @@ namespace MCGalaxy.Commands.Maintenance {
p.Message("&W\"{0}\" is not a valid IP address.", args[2]); return;
}
- if (who != null) who.ip = args[2];
+ if (who != null) who.IP = ip;
PlayerDB.Update(args[0], PlayerData.ColumnIP, args[2]);
MessageDataChanged(p, args[0], args[1], args[2]);
} else if (opt == "modified") {
diff --git a/MCGalaxy/Modules/Relay/Discord/DiscordWebsocket.cs b/MCGalaxy/Modules/Relay/Discord/DiscordWebsocket.cs
index 9f2d1fdf0..73b4dbd02 100644
--- a/MCGalaxy/Modules/Relay/Discord/DiscordWebsocket.cs
+++ b/MCGalaxy/Modules/Relay/Discord/DiscordWebsocket.cs
@@ -17,6 +17,7 @@
*/
using System;
using System.IO;
+using System.Net;
using System.Net.Security;
using System.Net.Sockets;
using System.Text;
@@ -69,7 +70,7 @@ namespace MCGalaxy.Modules.Relay.Discord {
const string host = "gateway.discord.gg";
// stubs
public override bool LowLatency { set { } }
- public override string IP { get { return ""; } }
+ public override IPAddress IP { get { return null; } }
public void Connect() {
client = new TcpClient();
diff --git a/MCGalaxy/Network/Sockets.cs b/MCGalaxy/Network/Sockets.cs
index a6d7c316c..fdcb97809 100644
--- a/MCGalaxy/Network/Sockets.cs
+++ b/MCGalaxy/Network/Sockets.cs
@@ -38,7 +38,7 @@ namespace MCGalaxy.Network {
public bool Disconnected;
/// Gets the IP address of the remote end (i.e. client) of the socket.
- public abstract string IP { get; }
+ public abstract IPAddress IP { get; }
/// Sets whether this socket operates in low-latency mode (e.g. for TCP, disabes nagle's algorithm).
public abstract bool LowLatency { set; }
@@ -54,7 +54,7 @@ namespace MCGalaxy.Network {
INetProtocol IdentifyProtocol(byte opcode) {
if (opcode == Opcode.Handshake) {
pending.Remove(this);
- return new Player() { ip = IP, Socket = this };
+ return new Player(this);
} else if (opcode == 'G' && Server.Config.WebClient) {
pending.Remove(this);
return new WebSocket(this);
@@ -142,8 +142,8 @@ namespace MCGalaxy.Network {
ReceiveNextAsync();
}
- public override string IP {
- get { return ((IPEndPoint)socket.RemoteEndPoint).Address.ToString(); }
+ public override IPAddress IP {
+ get { return ((IPEndPoint)socket.RemoteEndPoint).Address; }
}
public override bool LowLatency { set { socket.NoDelay = value; } }
@@ -279,7 +279,7 @@ namespace MCGalaxy.Network {
// Init taken care by underlying socket
public override void Init() { }
- public override string IP { get { return s.IP; } }
+ public override IPAddress IP { get { return s.IP; } }
public override bool LowLatency { set { s.LowLatency = value; } }
protected override void SendRaw(byte[] data, SendFlags flags) {
@@ -321,7 +321,7 @@ namespace MCGalaxy.Network {
// Init taken care by underlying socket
public override void Init() { }
- public override string IP { get { return raw.IP; } }
+ public override IPAddress IP { get { return raw.IP; } }
public override bool LowLatency { set { raw.LowLatency = value; } }
public override void Close() { raw.Close(); }
public void Disconnect() { Close(); }
diff --git a/MCGalaxy/Player/Player.Fields.cs b/MCGalaxy/Player/Player.Fields.cs
index 3a5afea94..67692c31c 100644
--- a/MCGalaxy/Player/Player.Fields.cs
+++ b/MCGalaxy/Player/Player.Fields.cs
@@ -14,6 +14,7 @@ permissions and limitations under the Licenses.
*/
using System;
using System.Collections.Generic;
+using System.Net;
using MCGalaxy.Drawing;
using MCGalaxy.Drawing.Transforms;
using MCGalaxy.Events.PlayerEvents;
@@ -55,7 +56,8 @@ namespace MCGalaxy {
public string DisplayName;
public int warn = 0;
public byte id;
- public string ip;
+ public IPAddress IP;
+ public string ip { get { return IP.ToString(); } }
public string color;
public Group group;
public LevelPermission hideRank = LevelPermission.Banned;
diff --git a/MCGalaxy/Player/Player.cs b/MCGalaxy/Player/Player.cs
index 072340760..8b1ba5473 100644
--- a/MCGalaxy/Player/Player.cs
+++ b/MCGalaxy/Player/Player.cs
@@ -15,6 +15,7 @@ permissions and limitations under the Licenses.
using System;
using System.Collections.Generic;
using System.IO;
+using System.Net;
using System.Net.Sockets;
using System.Threading;
using MCGalaxy.DB;
@@ -54,16 +55,21 @@ namespace MCGalaxy {
//This is so that plugin devs can declare a player without needing a socket..
//They would still have to do p.Dispose()..
public Player(string playername) {
- name = playername;
- truename = playername;
+ name = playername;
+ truename = playername;
DisplayName = playername;
+
+ IP = IPAddress.Loopback;
SessionID = Interlocked.Increment(ref sessionCounter) & SessionIDMask;
- IsSuper = true;
+ IsSuper = true;
}
- internal Player() {
+ internal Player(INetSocket socket) {
+ Socket = socket;
+ IP = socket.IP;
spamChecker = new SpamChecker(this);
- SessionID = Interlocked.Increment(ref sessionCounter) & SessionIDMask;
+ SessionID = Interlocked.Increment(ref sessionCounter) & SessionIDMask;
+
for (int b = 0; b < BlockBindings.Length; b++) {
BlockBindings[b] = (BlockID)b;
}