Skip to content
Newer
Older
100755 28 lines (24 sloc) 576 Bytes
fb42a7b @jedisct1 Add a filter than randomly makes connect() fail with "host unreachable".
authored Jun 20, 2011
1 #! /usr/bin/env ruby
2
3 # Make connect() randomly fail (50%) with "No route to host"
4
5 require "msgpack"
6
7 pac = MessagePack::Unpacker.new
8 loop do
9 begin
10 data = STDIN.readpartial(65536)
11 rescue EOFError
12 break
13 end
14 pac.feed(data)
15 pac.each do |obj|
16 obj =
17 if obj["filter_type"] == "POST" &&
18 obj["function"] == "connect" && rand < 0.5
08961a0 @jedisct1 Add a string filtering example.
authored Jun 20, 2011
19 { version: obj["version"], return_value: -1,
20 errno: Errno::EHOSTUNREACH::Errno }
fb42a7b @jedisct1 Add a filter than randomly makes connect() fail with "host unreachable".
authored Jun 20, 2011
21 else
22 { version: obj["version"] }
23 end
24 STDOUT.write obj.to_msgpack
25 STDOUT.flush
26 end
27 end
Something went wrong with that request. Please try again.