1
#pragma once
2

            
3
#include "envoy/network/address.h"
4

            
5
namespace Envoy {
6
namespace Network {
7

            
8
/**
9
 * IP Address Object that can be used to store the IP address in the filter state
10
 */
11
class IPAddressObject : public Address::InstanceAccessor {
12
public:
13
  IPAddressObject(Network::Address::InstanceConstSharedPtr address)
14
1
      : Address::InstanceAccessor(address) {}
15

            
16
1
  absl::optional<std::string> serializeAsString() const override {
17
1
    const auto ip = getIp();
18
1
    return ip ? absl::make_optional(ip->asString()) : absl::nullopt;
19
1
  }
20
};
21

            
22
} // namespace Network
23
} // namespace Envoy