Skip to content

Commit

Permalink
Fix support for IPv6 address and port
Browse files Browse the repository at this point in the history
  • Loading branch information
bczoma committed Mar 1, 2024
1 parent e17c990 commit 9535183
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Adding extra OAuth JWT claims to the REST consumer is not supported in the curre

* `msg_vpn_name` - REST delivery points are specific to a Message VPN on the broker.
* `rest_delivery_point_name` - The name of the REST delivery point to be created.
* `url` - The REST consumer destination URL including base URL and endpoint path. The path portion of the URL may contain [substitution expressions](https://docs.solace.com/Messaging/Substitution-Expressions-Overview.htm).
* `url` - The REST consumer destination URL including base URL and endpoint path. The path portion of the URL may contain [substitution expressions](https://docs.solace.com/Messaging/Substitution-Expressions-Overview.htm). To specify an IPv6 address with port, the required format is the address to be [enclosed in square brackets](https://www.rfc-editor.org/rfc/rfc3986.html#section-3.2.2).
* `queue_name` - The name of the queue to bind to.

Important: The REST delivery point must have permission to consume messages from the queue — to achieve this, the queue’s owner must be set to `#rdp/<rest_delivery_point_name>` or the queue’s permissions for non-owner clients must be set to at least `consume` level access. Queue ingress and egress must also be enabled.
Expand Down
5 changes: 3 additions & 2 deletions ci/module-test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ module "testrdp" {

msg_vpn_name = "default"
queue_name = solacebroker_msg_vpn_queue.myqueue.queue_name
url = "http://example.com/$${msgId()}"
url = "https://example.com"
rest_delivery_point_name = "my_rdp"
enabled = false
client_profile_name = "default"
request_headers = [
{
header_name = "header1"
Expand Down Expand Up @@ -67,7 +68,7 @@ module "testrdp2" {

msg_vpn_name = "default"
queue_name = solacebroker_msg_vpn_queue.myqueue.queue_name
url = "http://example.com/$${msgId()}"
url = "http://[2001:db8:3333:4444:5555:6666:7777:8888]:12345/$${msgId()}"
rest_delivery_point_name = "my_rdp2"
request_headers = module.testrdp.request_headers
protected_request_headers = module.testrdp.protected_request_headers
Expand Down
2 changes: 1 addition & 1 deletion ci/template-test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module "testrdp2" {

msg_vpn_name = "default"
queue_name = solacebroker_msg_vpn_queue.myqueue.queue_name
url = "http://example.com/$${msgId()}"
url = "http://[2001:db8:3333:4444:5555:6666:7777:8888]:12345/$${msgId()}"
rest_delivery_point_name = "my_rdp2"
request_headers = module.testrdp.request_headers
protected_request_headers = module.testrdp.protected_request_headers
Expand Down
3 changes: 2 additions & 1 deletion internal/gen-template/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
locals {
tls = startswith(lower(var.url), "https:")
slashSplit = split("/", var.url)
hostPortSplit = split(":", local.slashSplit[2])
isIpV6HostPort = length(split("]", local.slashSplit[2])) == 2
hostPortSplit = local.isIpV6HostPort ? split("]:", trimprefix(local.slashSplit[2], "[")) : split(":", local.slashSplit[2])
host = local.hostPortSplit[0]
port = length(local.hostPortSplit) == 2 ? tonumber(local.hostPortSplit[1]) : (local.tls ? 443 : 80)
path = "/${join("/", slice(local.slashSplit, 3, length(local.slashSplit)))}"
Expand Down
3 changes: 2 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
locals {
tls = startswith(lower(var.url), "https:")
slashSplit = split("/", var.url)
hostPortSplit = split(":", local.slashSplit[2])
isIpV6HostPort = length(split("]", local.slashSplit[2])) == 2
hostPortSplit = local.isIpV6HostPort ? split("]:", trimprefix(local.slashSplit[2], "[")) : split(":", local.slashSplit[2])
host = local.hostPortSplit[0]
port = length(local.hostPortSplit) == 2 ? tonumber(local.hostPortSplit[1]) : (local.tls ? 443 : 80)
path = "/${join("/", slice(local.slashSplit, 3, length(local.slashSplit)))}"
Expand Down

0 comments on commit 9535183

Please sign in to comment.