Skip to content

Commit

Permalink
Fix parsing of inet[/127.0.0.1:9200] (#49)
Browse files Browse the repository at this point in the history
* sniffer: fix parsing of inet[hostname/ip:port]

Prior to commit 53f37cb,
publish_address of the format `inet[hostname/ip:port]` worked correctly.

When the sniffer code was refactored, this format broke, and is an easy
fix to restore.

Fixes: #48
Signed-off-by: Robin H. Johnson <[email protected]>

* sniffer: fix empty hostname like inet[/127.0.0.1:9200]

Fixes: #48
Signed-off-by: Robin H. Johnson <[email protected]>

---------

Signed-off-by: Robin H. Johnson <[email protected]>
  • Loading branch information
robbat2 authored and picandocodigo committed Jul 5, 2023
1 parent 56a974d commit 387ebad
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/elastic/transport/transport/sniffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ def perform_sniff_request
end

def parse_publish_address(publish_address)
# publish_address is in the format hostname/ip:port
# publish_address is in the format:
# - hostname/ip:port
# - inet[hostname/ip:port]
publish_address = publish_address[5..-2] if publish_address =~ /^inet\[.*\]$/
# If hostname is empty.
publish_address = publish_address[1..] if publish_address =~ /^\//
if publish_address =~ /\//
parts = publish_address.partition('/')
[ parts[0], parse_address_port(parts[2])[1] ]
Expand Down

0 comments on commit 387ebad

Please sign in to comment.