Skip to content

Commit

Permalink
Merge pull request #2 from runtastic/reconnect-on-ip-change
Browse files Browse the repository at this point in the history
Fix UDP connection ip resolution
  • Loading branch information
Goltergaul authored Oct 10, 2023
2 parents 72241c3 + 9378e6d commit f407569
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

[//]: # (comment: Don't forget to update lib/datadog/statsd/version.rb:DogStatsd::Statsd::VERSION when releasing a new version)

## 5.7.1
* [BUGFIX] UPD connection ip tracking

## 5.7.0

* [FEATURE] UDP connection is tracking IP changes of the STATSD_HOST and reconnecting the socket when the ip changes

## 5.6.1 / 2023.09.07

* [IMPROVEMENT] Add support for IPv6 UDP connection. [#280][] by [@kazwolfe][]
Expand Down
2 changes: 1 addition & 1 deletion lib/datadog/statsd/udp_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class UDPConnection < Connection
def self.resolve_host_dns(hostname)
Resolv::DNS.open do |dns|
dns.timeouts = 1
dns.getaddress(@host)
dns.getaddress(hostname)
end
rescue Resolv::ResolvError
nil
Expand Down
2 changes: 1 addition & 1 deletion lib/datadog/statsd/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

module Datadog
class Statsd
VERSION = '5.6.1'
VERSION = '5.7.1'
end
end
3 changes: 2 additions & 1 deletion spec/integrations/connection_edge_case_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
it 'reconnects socket after 60 seconds if the ip changes' do
dns_mock = instance_double(Resolv::DNS, 'timeouts=': nil)
allow(dns_mock).to receive(:getaddress)
.and_return("192.168.0.1", "192.168.0.2")
.with("localhost")
.and_return(Resolv::IPv4.create("192.168.0.1"), Resolv::IPv4.create("192.168.0.2"))
allow(Resolv::DNS).to receive(:open)
.and_yield(dns_mock)

Expand Down

0 comments on commit f407569

Please sign in to comment.