Class: Fluent::Plugin::ForwardOutput::HandshakeProtocol
- Inherits:
-
Object
- Object
- Fluent::Plugin::ForwardOutput::HandshakeProtocol
- Defined in:
- lib/fluent/plugin/out_forward/handshake_protocol.rb
Instance Method Summary collapse
-
#initialize(log:, hostname:, shared_key:, password:, username:) ⇒ HandshakeProtocol
constructor
A new instance of HandshakeProtocol.
- #invoke(sock, ri, data) ⇒ Object
Constructor Details
#initialize(log:, hostname:, shared_key:, password:, username:) ⇒ HandshakeProtocol
Returns a new instance of HandshakeProtocol.
24 25 26 27 28 29 30 31 |
# File 'lib/fluent/plugin/out_forward/handshake_protocol.rb', line 24 def initialize(log:, hostname:, shared_key:, password:, username:) @log = log @hostname = hostname @shared_key = shared_key @password = password @username = username @shared_key_salt = generate_salt end |
Instance Method Details
#invoke(sock, ri, data) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/fluent/plugin/out_forward/handshake_protocol.rb', line 33 def invoke(sock, ri, data) @log.trace __callee__ case ri.state when :helo unless check_helo(ri, data) raise HeloError, 'received invalid helo message' end sock.write(generate_ping(ri).to_msgpack) ri.state = :pingpong when :pingpong succeeded, reason = check_pong(ri, data) unless succeeded raise PingpongError, reason end ri.state = :established else raise "BUG: unknown session state: #{ri.state}" end end |