Coverage Report

Created: 2023-11-12 09:30

/proc/self/cwd/source/extensions/filters/common/original_src/original_src_socket_option.h
Line
Count
Source (jump to first uncovered line)
1
#pragma once
2
3
#include "envoy/config/core/v3/base.pb.h"
4
#include "envoy/network/address.h"
5
#include "envoy/network/listen_socket.h"
6
7
namespace Envoy {
8
namespace Extensions {
9
namespace Filters {
10
namespace Common {
11
namespace OriginalSrc {
12
/**
13
 * A socket option implementation which allows a connection to spoof its source IP/port using
14
 * a provided IP address (and maybe port).
15
 */
16
class OriginalSrcSocketOption : public Network::Socket::Option {
17
public:
18
  /**
19
   * Constructs a socket option which will set the socket to use source @c src_address
20
   */
21
  OriginalSrcSocketOption(Network::Address::InstanceConstSharedPtr src_address);
22
746
  ~OriginalSrcSocketOption() override = default;
23
24
  /**
25
   * Updates the source address of the socket to match `src_address_`.
26
   * Adds socket options to the socket to allow this to work.
27
   */
28
  bool setOption(Network::Socket& socket,
29
                 envoy::config::core::v3::SocketOption::SocketState state) const override;
30
31
  /**
32
   * Appends a key which uniquely identifies the address being tracked.
33
   */
34
  void hashKey(std::vector<uint8_t>& key) const override;
35
36
  absl::optional<Details>
37
  getOptionDetails(const Network::Socket& socket,
38
                   envoy::config::core::v3::SocketOption::SocketState state) const override;
39
0
  bool isSupported() const override { return true; }
40
41
private:
42
  Network::Address::InstanceConstSharedPtr src_address_;
43
};
44
45
} // namespace OriginalSrc
46
} // namespace Common
47
} // namespace Filters
48
} // namespace Extensions
49
} // namespace Envoy