Files
flexnbd-c/tests/acceptance/fakes/source/connect_from_banned_ip.rb
Patrick J Cherry 9c48da82cc Rubocop
2018-02-02 21:34:14 +00:00

18 lines
435 B
Ruby
Executable File

#!/usr/bin/env ruby
# We connect from a local address which should be blocked, sleep for a
# bit, then try to read from the socket. We should get an instant EOF
# as we've been cut off by the destination.
require 'timeout'
require 'flexnbd/fake_source'
include FlexNBD
addr, port = *ARGV
client = FakeSource.new(addr, port, 'Timed out connecting', '127.0.0.6')
sleep(0.25)
rsp = client.disconnected? ? 0 : 1
client.close
exit(rsp)