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

IPv6 IP addresses cannot be used with RabbitMQ #37619

Conversation

jonasfugedi
Copy link

Failed to parse ipv6 addresses due to assumption of ipv4 addresses.

I think the regression was introduced in #34657

@pivotal-cla
Copy link

@jonasfugedi Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-cla
Copy link

@jonasfugedi Thank you for signing the Contributor License Agreement!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 28, 2023
@scottfrederick scottfrederick added type: regression A regression from a previous release and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 28, 2023
@scottfrederick scottfrederick added this to the 3.1.x milestone Sep 28, 2023
@philwebb philwebb changed the title Bugfix ipv6 address in rabbit IPv6 IP addresses cannot be used with RabbitMQ Sep 28, 2023
@scottfrederick scottfrederick self-assigned this Sep 28, 2023
@scottfrederick
Copy link
Contributor

@jonasfugedi Thanks very much for your first contribution to Spring Boot. I've merged it along with a polishing commit for style and a small bit of additional testing.

@scottfrederick scottfrederick modified the milestones: 3.1.x, 3.1.5 Sep 28, 2023
@mjustin
Copy link

mjustin commented Nov 10, 2023

public List<Address> getAddresses() {
	List<Address> addresses = new ArrayList<>();
	for (String address : this.properties.determineAddresses().split(",")) {
		int portSeparatorIndex = address.lastIndexOf(':');
		String host = address.substring(0, portSeparatorIndex);
		String port = address.substring(portSeparatorIndex + 1);
		addresses.add(new Address(host, Integer.parseInt(port)));
	}
	return addresses;
}

Is it possible for an IPv6 address to be specified without a port (i.e. use the default port)? Wouldn't this code fail in that scenario, since it'd split on a colon that's part of the IP address, and not related to the port?

@jonasfugedi
Copy link
Author

public List<Address> getAddresses() {
	List<Address> addresses = new ArrayList<>();
	for (String address : this.properties.determineAddresses().split(",")) {
		int portSeparatorIndex = address.lastIndexOf(':');
		String host = address.substring(0, portSeparatorIndex);
		String port = address.substring(portSeparatorIndex + 1);
		addresses.add(new Address(host, Integer.parseInt(port)));
	}
	return addresses;
}

Is it possible for an IPv6 address to be specified without a port (i.e. use the default port)? Wouldn't this code fail in that scenario, since it'd split on a colon that's part of the IP address, and not related to the port?

Not if I read the code correct, the source of the addresses is

https://github.com/jonasfugedi/spring-boot/blob/bebca55a8ffee3b4cd4d099fb6be199655cf8c7d/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java#L207-L225

Which ensures a port is always appended to the host. Previous behavior was retained, i.e. I kept the same assumptions as the code did before except I needed it to work when using ipv6 addresses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants