Skip to content

Commit

Permalink
[#1411] support designated IPV4/IPV6 type configuration for register …
Browse files Browse the repository at this point in the history
…endpoint (#1414)
  • Loading branch information
chengyouling authored Jan 13, 2025
1 parent b35b66b commit d5419d6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public class DiscoveryBootstrapProperties {
// enabled: true
private boolean enableServicePolling = false;

private boolean preferIpv6Address = false;

public String getPublishAddress() {
return publishAddress;
}
Expand Down Expand Up @@ -228,19 +230,37 @@ public void setOrder(int order) {
this.order = order;
}

public boolean isPreferIpv6Address() {
return preferIpv6Address;
}

public void setPreferIpv6Address(boolean preferIpv6Address) {
this.preferIpv6Address = preferIpv6Address;
}

@Override
public String toString() {
return "ServiceCombDiscoveryProperties{" +
"enabled=" + enabled +
", watch=" + watch +
", address='" + address + '\'' +
", hostname='" + hostname + '\'' +
", preferIpAddress=" + preferIpAddress +
", healthCheck=" + healthCheck +
", healthCheckInterval=" + healthCheckInterval +
", autoDiscovery=" + autoDiscovery +
", allowCrossApp=" + allowCrossApp +
", dataCenter=" + datacenter +
'}';
return "DiscoveryBootstrapProperties{" +
"enabled=" + enabled +
", order=" + order +
", watch=" + watch +
", enableZoneAware=" + enableZoneAware +
", address='" + address + '\'' +
", hostname='" + hostname + '\'' +
", preferIpAddress=" + preferIpAddress +
", healthCheck=" + healthCheck +
", healthCheckInterval=" + healthCheckInterval +
", healthCheckRequestTimeout=" + healthCheckRequestTimeout +
", pollInterval=" + pollInterval +
", autoDiscovery=" + autoDiscovery +
", waitTimeForShutDownInMillis=" + waitTimeForShutDownInMillis +
", allowCrossApp=" + allowCrossApp +
", publishAddress='" + publishAddress + '\'' +
", ignoreSwaggerDifferent=" + ignoreSwaggerDifferent +
", canOverwriteSwagger=" + canOverwriteSwagger +
", datacenter=" + datacenter +
", enableServicePolling=" + enableServicePolling +
", preferIpv6Address='" + preferIpv6Address + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ public static MicroserviceInstance createMicroserviceInstance(
List<String> endPoints = new ArrayList<>();
String address;
if (StringUtils.isEmpty(discoveryBootstrapProperties.getPublishAddress())) {
address = NetUtils.getHostAddress();
address = discoveryBootstrapProperties.isPreferIpv6Address() ?
NetUtils.getIpv6HostAddress() : NetUtils.getHostAddress();
} else {
address = discoveryBootstrapProperties.getPublishAddress();
}
Expand Down

0 comments on commit d5419d6

Please sign in to comment.