Skip to content

Commit

Permalink
Minor adjustments to WSL Dev mode fix
Browse files Browse the repository at this point in the history
The previous commit was actually changing the logic for the default
case.
  • Loading branch information
gsmet committed Jun 6, 2024
1 parent a58ae19 commit 64bf132
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,31 @@

public class VertxConfigBuilder implements ConfigBuilder {
private static final String QUARKUS_HTTP_HOST = "quarkus.http.host";

private static final String LOCALHOST = "localhost";
private static final String ALL_INTERFACES = "0.0.0.0";

@Override
public SmallRyeConfigBuilder configBuilder(final SmallRyeConfigBuilder builder) {
// It may have been recorded, so only set if it not available in the defaults
if (builder.getDefaultValues().get(QUARKUS_HTTP_HOST) == null) {
// Sets the default host config value, depending on the launch mode
if (LaunchMode.isRemoteDev() || (LaunchMode.current().isDevOrTest() && isWSL())) {
// we need to listen on all interfaces otherwise the application would not be accessible
if (LaunchMode.isRemoteDev()) {
// in remote dev mode, we want to listen on all interfaces
// to make sure the application is accessible
builder.withDefaultValue(QUARKUS_HTTP_HOST, ALL_INTERFACES);
} else if (LaunchMode.current().isDevOrTest()) {
if (!isWSL()) {
// in dev mode, we want to listen only on localhost
// to make sure the app is not accessible from the outside
builder.withDefaultValue(QUARKUS_HTTP_HOST, LOCALHOST);
} else {
// except when using WSL, as otherwise the app wouldn't be accessible from the host
builder.withDefaultValue(QUARKUS_HTTP_HOST, ALL_INTERFACES);
}
} else {
// Otherwise, we want to only listen on localhost so others on the network cannot connect to the application.
builder.withDefaultValue(QUARKUS_HTTP_HOST, "localhost");
// in all the other cases, we make sure the app is accessible on all the interfaces by default
builder.withDefaultValue(QUARKUS_HTTP_HOST, ALL_INTERFACES);
}
}
return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ private static void setHttpServerTiming(boolean httpDisabled, HttpServerOptions
* Do not use this during the actual configuration, use options.getHost() there directly instead.
*/
private static String getDeveloperFriendlyHostName(HttpServerOptions options) {
return (isWSL() && LaunchMode.current().isDevOrTest() && options.getHost().equals("0.0.0.0")) ? "localhost"
return (LaunchMode.current().isDevOrTest() && "0.0.0.0".equals(options.getHost()) && isWSL()) ? "localhost"
: options.getHost();
}

Expand Down

0 comments on commit 64bf132

Please sign in to comment.