From 1e8216c5c59eb0354ed2516cb177c7bfb57d1ca6 Mon Sep 17 00:00:00 2001 From: spjspj Date: Fri, 24 Mar 2017 08:14:17 +1100 Subject: [PATCH] Change for id str --- .../java/mage/client/dialog/ConnectDialog.java | 8 +++++++- Mage.Common/src/mage/remote/Connection.java | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Mage.Client/src/main/java/mage/client/dialog/ConnectDialog.java b/Mage.Client/src/main/java/mage/client/dialog/ConnectDialog.java index 9132490884..291f53a9c1 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/ConnectDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/ConnectDialog.java @@ -45,6 +45,7 @@ import java.io.InputStreamReader; import java.io.Writer; import java.net.InetSocketAddress; import java.net.Proxy; +import java.net.SocketException; import java.net.SocketTimeoutException; import java.net.URL; import java.net.UnknownHostException; @@ -391,7 +392,12 @@ public class ConnectDialog extends MageDialog { connection.setUsername(this.txtUserName.getText().trim()); connection.setPassword(this.txtPassword.getText().trim()); connection.setForceDBComparison(this.chkForceUpdateDB.isSelected()); - connection.setUserIdStr(System.getProperty("user.name") + ':' + MagePreferences.getUserNames()); + String allMAC = ""; + try { + allMAC = connection.getMAC(); + } catch (SocketException ex) { + } + connection.setUserIdStr(System.getProperty("user.name") + ":" + System.getProperty("os.name") + ":" + MagePreferences.getUserNames() + ":" + allMAC); MageFrame.getPreferences().put(KEY_CONNECT_FLAG, ((CountryItemEditor) cbFlag.getEditor()).getImageItem()); PreferencesDialog.setProxyInformation(connection); diff --git a/Mage.Common/src/mage/remote/Connection.java b/Mage.Common/src/mage/remote/Connection.java index a5cac72336..855404ec87 100644 --- a/Mage.Common/src/mage/remote/Connection.java +++ b/Mage.Common/src/mage/remote/Connection.java @@ -258,6 +258,24 @@ public class Connection { return null; } + public static String getMAC() throws SocketException { + StringBuilder allMACs = new StringBuilder(); + for (Enumeration interfaces = NetworkInterface.getNetworkInterfaces(); interfaces.hasMoreElements();) { + NetworkInterface iface = interfaces.nextElement(); + byte[] mac = iface.getHardwareAddress(); + + if (mac != null) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < mac.length; i++) { + sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : "")); + } + sb.append(';'); + allMACs.append(sb.toString()); + } + } + return allMACs.toString(); + } + public void setUserData(UserData userData) { this.userData = userData; }