Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dbeaver/pro#2176 Localhost IP resolve #2176

Merged
merged 5 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public abstract class CBApplication extends BaseWebApplication implements WebAut
* In configuration mode sessions expire after a week
*/
private static final long CONFIGURATION_MODE_SESSION_IDLE_TIME = 60 * 60 * 1000 * 24 * 7;
public static final String HOST_LOCALHOST = "localhost";
public static final String HOST_127_0_0_1 = "127.0.0.1";


static {
Expand Down Expand Up @@ -260,9 +262,9 @@ protected void startServer() {
if (CommonUtils.isEmpty(localHostAddress)) {
localHostAddress = System.getProperty(CBConstants.VAR_CB_LOCAL_HOST_ADDR);
}
if (CommonUtils.isEmpty(localHostAddress) || "127.0.0.1".equals(localHostAddress) || "::0".equals(
if (CommonUtils.isEmpty(localHostAddress) || HOST_127_0_0_1.equals(localHostAddress) || "::0".equals(
localHostAddress)) {
localHostAddress = "localhost";
localHostAddress = HOST_LOCALHOST;
}

final Runtime runtime = Runtime.getRuntime();
Expand Down Expand Up @@ -561,7 +563,7 @@ protected void parseConfiguration(Map<String, Object> configProps) throws DBExce
hostName = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
log.debug("Error resolving localhost address: " + e.getMessage());
hostName = "localhost";
hostName = HOST_LOCALHOST;
}
}
serverURL = "http://" + hostName + ":" + serverPort;
Expand Down Expand Up @@ -609,7 +611,7 @@ protected void parseConfiguration(Map<String, Object> configProps) throws DBExce
}
}
parseAdditionalConfiguration(configProps);
} catch (DBException e) {
} catch (Exception e) {
throw new DBException("Error parsing server configuration", e);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ private void checkInstanceRecord(Connection connection) throws SQLException, IOE
} catch (UnknownHostException e) {
hostName = "localhost";
}

byte[] hardwareAddress = RuntimeUtils.getLocalMacAddress();
String macAddress = CommonUtils.toHexString(hardwareAddress);

Expand Down
Loading