Skip to content

Commit e24d06b

Browse files
committed
Merge branch 'release'
2 parents 99d41ba + 4eaa20a commit e24d06b

File tree

2 files changed

+9
-26
lines changed
  • PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/lib/mysql
  • Utils/azuretools-core/src/com/microsoft/azuretools/azurecommons/util

2 files changed

+9
-26
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/lib/mysql/AzureMySQLService.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,24 @@
1414
import com.microsoft.azure.toolkit.intellij.connector.mysql.MySQLConnectionUtils;
1515
import com.microsoft.azure.toolkit.lib.Azure;
1616
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation;
17+
import com.microsoft.azure.toolkit.lib.common.utils.NetUtils;
1718
import com.microsoft.azure.toolkit.lib.resource.AzureGroup;
1819
import com.microsoft.azuretools.ActionConstants;
1920
import com.microsoft.azuretools.authmanage.AuthMethodManager;
20-
import com.microsoft.azuretools.azurecommons.util.GetHashMac;
2121
import com.microsoft.azuretools.core.mvp.model.mysql.MySQLMvpModel;
2222
import com.microsoft.azuretools.telemetry.TelemetryConstants;
23-
import com.microsoft.azuretools.telemetrywrapper.*;
23+
import com.microsoft.azuretools.telemetrywrapper.ErrorType;
24+
import com.microsoft.azuretools.telemetrywrapper.EventType;
25+
import com.microsoft.azuretools.telemetrywrapper.EventUtil;
26+
import com.microsoft.azuretools.telemetrywrapper.Operation;
27+
import com.microsoft.azuretools.telemetrywrapper.TelemetryManager;
2428
import org.apache.commons.lang3.StringUtils;
2529

2630
import java.io.BufferedReader;
2731
import java.io.IOException;
2832
import java.io.InputStreamReader;
29-
import java.net.InetAddress;
30-
import java.net.UnknownHostException;
31-
import java.net.URL;
3233
import java.net.HttpURLConnection;
34+
import java.net.URL;
3335
import java.nio.charset.StandardCharsets;
3436
import java.util.Collections;
3537
import java.util.List;
@@ -168,12 +170,8 @@ public boolean disableAllowAccessFromLocalMachine(final String subscriptionId, f
168170
}
169171

170172
private String getAccessFromLocalRuleName() {
171-
String hostname = "UNKNOWN_HOST";
172-
try {
173-
hostname = InetAddress.getLocalHost().getHostName();
174-
} catch (UnknownHostException e) {
175-
}
176-
final String macAddress = GetHashMac.getMac();
173+
final String hostname = NetUtils.getHostName();
174+
final String macAddress = NetUtils.getMac();
177175
final String ruleName = NAME_PREFIX_ALLOW_ACCESS_TO_LOCAL + hostname + "_" + macAddress;
178176
return ruleName;
179177
}

Utils/azuretools-core/src/com/microsoft/azuretools/azurecommons/util/GetHashMac.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,6 @@ public static String getHashMac() {
6161
return ret;
6262
}
6363

64-
public static String getMac() {
65-
try {
66-
InetAddress ip = InetAddress.getLocalHost();
67-
NetworkInterface network = NetworkInterface.getByInetAddress(ip);
68-
byte[] mac = network.getHardwareAddress();
69-
StringBuilder sb = new StringBuilder();
70-
for (int i = 0; i < mac.length; i++) {
71-
sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));
72-
}
73-
return sb.toString();
74-
} catch (UnknownHostException | SocketException e) {
75-
return null;
76-
}
77-
}
78-
7964
private static boolean isValidMac(String mac) {
8065
if (StringUtils.isEmpty(mac)) {
8166
return false;

0 commit comments

Comments
 (0)