Skip to content

Commit

Permalink
Merge branch 'endgame-s187' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Flanker32 committed May 27, 2021
2 parents 2c5a9f5 + b207b41 commit 4eaa20a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,24 @@
import com.microsoft.azure.toolkit.intellij.connector.mysql.MySQLConnectionUtils;
import com.microsoft.azure.toolkit.lib.Azure;
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation;
import com.microsoft.azure.toolkit.lib.common.utils.NetUtils;
import com.microsoft.azure.toolkit.lib.resource.AzureGroup;
import com.microsoft.azuretools.ActionConstants;
import com.microsoft.azuretools.authmanage.AuthMethodManager;
import com.microsoft.azuretools.azurecommons.util.GetHashMac;
import com.microsoft.azuretools.core.mvp.model.mysql.MySQLMvpModel;
import com.microsoft.azuretools.telemetry.TelemetryConstants;
import com.microsoft.azuretools.telemetrywrapper.*;
import com.microsoft.azuretools.telemetrywrapper.ErrorType;
import com.microsoft.azuretools.telemetrywrapper.EventType;
import com.microsoft.azuretools.telemetrywrapper.EventUtil;
import com.microsoft.azuretools.telemetrywrapper.Operation;
import com.microsoft.azuretools.telemetrywrapper.TelemetryManager;
import org.apache.commons.lang3.StringUtils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.net.URL;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -168,12 +170,8 @@ public boolean disableAllowAccessFromLocalMachine(final String subscriptionId, f
}

private String getAccessFromLocalRuleName() {
String hostname = "UNKNOWN_HOST";
try {
hostname = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
}
final String macAddress = GetHashMac.getMac();
final String hostname = NetUtils.getHostName();
final String macAddress = NetUtils.getMac();
final String ruleName = NAME_PREFIX_ALLOW_ACCESS_TO_LOCAL + hostname + "_" + macAddress;
return ruleName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,6 @@ public static String getHashMac() {
return ret;
}

public static String getMac() {
try {
InetAddress ip = InetAddress.getLocalHost();
NetworkInterface network = NetworkInterface.getByInetAddress(ip);
byte[] mac = network.getHardwareAddress();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < mac.length; i++) {
sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));
}
return sb.toString();
} catch (UnknownHostException | SocketException e) {
return null;
}
}

private static boolean isValidMac(String mac) {
if (StringUtils.isEmpty(mac)) {
return false;
Expand Down

0 comments on commit 4eaa20a

Please sign in to comment.