1
#pragma once
2

            
3
#include "source/common/network/io_socket_handle_impl.h"
4

            
5
namespace Envoy {
6
namespace Extensions {
7
namespace Bootstrap {
8
namespace ReverseConnection {
9

            
10
class RpingInterceptor : public virtual Network::IoSocketHandleImpl {
11
public:
12
  // Intercept reads to handle reverse connection keep-alive pings.
13
  Api::IoCallUint64Result read(Buffer::Instance& buffer,
14
                               absl::optional<uint64_t> max_length) override;
15

            
16
  virtual void onPingMessage() PURE;
17

            
18
protected:
19
  // Whether to actively echo RPING messages while the connection is idle.
20
  // Disabled permanently after the first non-RPING application byte is observed.
21
  bool ping_echo_active_{true};
22
};
23

            
24
} // namespace ReverseConnection
25
} // namespace Bootstrap
26
} // namespace Extensions
27
} // namespace Envoy