|
14 | 14 | import com.microsoft.azure.toolkit.intellij.connector.mysql.MySQLConnectionUtils; |
15 | 15 | import com.microsoft.azure.toolkit.lib.Azure; |
16 | 16 | import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation; |
| 17 | +import com.microsoft.azure.toolkit.lib.common.utils.NetUtils; |
17 | 18 | import com.microsoft.azure.toolkit.lib.resource.AzureGroup; |
18 | 19 | import com.microsoft.azuretools.ActionConstants; |
19 | 20 | import com.microsoft.azuretools.authmanage.AuthMethodManager; |
20 | | -import com.microsoft.azuretools.azurecommons.util.GetHashMac; |
21 | 21 | import com.microsoft.azuretools.core.mvp.model.mysql.MySQLMvpModel; |
22 | 22 | 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; |
24 | 28 | import org.apache.commons.lang3.StringUtils; |
25 | 29 |
|
26 | 30 | import java.io.BufferedReader; |
27 | 31 | import java.io.IOException; |
28 | 32 | import java.io.InputStreamReader; |
29 | | -import java.net.InetAddress; |
30 | | -import java.net.UnknownHostException; |
31 | | -import java.net.URL; |
32 | 33 | import java.net.HttpURLConnection; |
| 34 | +import java.net.URL; |
33 | 35 | import java.nio.charset.StandardCharsets; |
34 | 36 | import java.util.Collections; |
35 | 37 | import java.util.List; |
@@ -168,12 +170,8 @@ public boolean disableAllowAccessFromLocalMachine(final String subscriptionId, f |
168 | 170 | } |
169 | 171 |
|
170 | 172 | 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(); |
177 | 175 | final String ruleName = NAME_PREFIX_ALLOW_ACCESS_TO_LOCAL + hostname + "_" + macAddress; |
178 | 176 | return ruleName; |
179 | 177 | } |
|
0 commit comments