24#ifndef GCS_XCOM_NETWORKING_H
25#define GCS_XCOM_NETWORKING_H
104 std::map<std::string, int> &out,
105 bool filter_out_inactive =
false);
116 bool filter_out_inactive =
false);
127 std::string
name,
std::vector<std::pair<sa_family_t, std::string>> &ips);
138 std::vector<std::string> &ip);
151 std::pair<std::vector<unsigned char>,
152 std::vector<unsigned char>> &out_pair);
196 std::pair<std::vector<unsigned char>, std::vector<unsigned char>>>
232 std::vector<std::pair<std::vector<unsigned char>, std::vector<unsigned char>>>
236 std::pair<std::vector<unsigned char>, std::vector<unsigned char>>
m_value;
251 std::vector<std::pair<std::vector<unsigned char>, std::vector<unsigned char>>>
270 while (
m_guard.test_and_set()) {
271 std::this_thread::yield();
286 std::set<Gcs_ip_allowlist_entry *, Gcs_ip_allowlist_entry_pointer_comparator>
309 bool configure(
const std::string &the_list);
321 bool is_valid(
const std::string &the_list);
333 site_def const *xcom_config =
nullptr);
368 std::vector<unsigned char>
const &incoming_octets)
const;
Definition: gcs_xcom_networking.h:260
Atomic_lock_guard(std::atomic_flag &guard)
Definition: gcs_xcom_networking.h:268
std::atomic_flag & m_guard
When true, it is locked.
Definition: gcs_xcom_networking.h:265
~Atomic_lock_guard()
Definition: gcs_xcom_networking.h:275
Implementation of Gcs_ip_allowlist_entry to use with hostnames.
Definition: gcs_xcom_networking.h:244
Gcs_ip_allowlist_entry_hostname(std::string addr, std::string mask)
Definition: gcs_xcom_networking.cc:512
std::vector< std::pair< std::vector< unsigned char >, std::vector< unsigned char > > > * get_value() override
Virtual Method that implements value retrieval for this entry.
Definition: gcs_xcom_networking.cc:523
bool init_value() override
Entry initialization.
Definition: gcs_xcom_networking.cc:520
Implementation of Gcs_ip_allowlist_entry to use with raw IP addresses in format X....
Definition: gcs_xcom_networking.h:226
bool init_value() override
Entry initialization.
Definition: gcs_xcom_networking.cc:499
Gcs_ip_allowlist_entry_ip(std::string addr, std::string mask)
Definition: gcs_xcom_networking.cc:495
std::vector< std::pair< std::vector< unsigned char >, std::vector< unsigned char > > > * get_value() override
Virtual Method that implements value retrieval for this entry.
Definition: gcs_xcom_networking.cc:506
std::pair< std::vector< unsigned char >, std::vector< unsigned char > > m_value
Definition: gcs_xcom_networking.h:236
Base abstract class for the allowlist entries.
Definition: gcs_xcom_networking.h:163
virtual ~Gcs_ip_allowlist_entry()=default
std::string m_mask
Definition: gcs_xcom_networking.h:205
std::string m_addr
Definition: gcs_xcom_networking.h:204
virtual bool init_value()=0
Entry initialization.
std::string get_mask() const
Definition: gcs_xcom_networking.h:201
virtual std::vector< std::pair< std::vector< unsigned char >, std::vector< unsigned char > > > * get_value()=0
Virtual Method that implements value retrieval for this entry.
std::string get_addr() const
Getters.
Definition: gcs_xcom_networking.h:200
Gcs_ip_allowlist_entry(std::string addr, std::string mask)
Constructor.
Definition: gcs_xcom_networking.cc:491
Definition: gcs_xcom_networking.h:255
bool do_check_block_xcom(std::vector< unsigned char > const &incoming_octets, site_def const *xcom_config) const
Definition: gcs_xcom_networking.cc:832
std::set< Gcs_ip_allowlist_entry *, Gcs_ip_allowlist_entry_pointer_comparator > m_ip_allowlist
Definition: gcs_xcom_networking.h:287
std::string to_string() const
A string representation of the internal list of IP addresses.
Definition: gcs_xcom_networking.cc:573
Gcs_ip_allowlist(Gcs_ip_allowlist const &)
const std::string get_configured_ip_allowlist()
This member function gets the textual representation of the list as provided to the configure member ...
Definition: gcs_xcom_networking.h:350
bool do_check_block(struct sockaddr_storage *sa, site_def const *xcom_config) const
Definition: gcs_xcom_networking.cc:900
Gcs_ip_allowlist & operator=(Gcs_ip_allowlist const &)
Gcs_ip_allowlist()
Definition: gcs_xcom_networking.h:296
bool shall_block(const std::string &ip_addr, site_def const *xcom_config=nullptr)
This member function SHALL return true if the given IP is to be blocked, false otherwise.
Definition: gcs_xcom_networking.cc:986
static const std::string DEFAULT_ALLOWLIST
Definition: gcs_xcom_networking.h:257
bool do_check_block_allowlist(std::vector< unsigned char > const &incoming_octets) const
Definition: gcs_xcom_networking.cc:795
virtual ~Gcs_ip_allowlist()
Definition: gcs_xcom_networking.cc:770
void clear()
Clears the contents of this Allowlist object.
Definition: gcs_xcom_networking.cc:761
bool configure(const std::string &the_list)
This member function shall be used to configure the allowlist.
Definition: gcs_xcom_networking.cc:641
std::string m_original_list
This is the list that originally submitted to be parsed and to configure the allowlist.
Definition: gcs_xcom_networking.h:293
bool add_address(std::string addr, std::string mask)
Definition: gcs_xcom_networking.cc:772
std::atomic_flag m_atomic_guard
An atomic lock to guard the ip allowlist.
Definition: gcs_xcom_networking.h:383
bool is_valid(const std::string &the_list)
This member function shall be used to validate the list that is used as input to the configure member...
Definition: gcs_xcom_networking.cc:587
Definition: gcs_xcom_networking.h:69
Gcs_sock_probe_interface_impl()
Definition: gcs_xcom_networking.h:71
Gcs_sock_probe_interface_impl & operator=(Gcs_sock_probe_interface_impl &&)=default
void close_sock_probe(sock_probe *s) override
Definition: gcs_xcom_networking.cc:474
Gcs_sock_probe_interface_impl(Gcs_sock_probe_interface_impl &)=default
void get_sockaddr_netmask(sock_probe *s, int count, struct sockaddr **out) override
Definition: gcs_xcom_networking.cc:466
void get_sockaddr_address(sock_probe *s, int count, struct sockaddr **out) override
Definition: gcs_xcom_networking.cc:461
~Gcs_sock_probe_interface_impl() override=default
int number_of_interfaces(sock_probe *s) override
Definition: gcs_xcom_networking.cc:457
Gcs_sock_probe_interface_impl & operator=(const Gcs_sock_probe_interface_impl &)=default
char * get_if_name(sock_probe *s, int count) override
Definition: gcs_xcom_networking.cc:470
Gcs_sock_probe_interface_impl(Gcs_sock_probe_interface_impl &&)=default
bool_t is_if_running(sock_probe *s, int count) override
Definition: gcs_xcom_networking.cc:478
int init_sock_probe(sock_probe *s) override
Definition: gcs_xcom_networking.cc:453
Interface to decouple XCom sock_probe implementation to allow unit testing.
Definition: gcs_xcom_networking.h:42
Gcs_sock_probe_interface(Gcs_sock_probe_interface &)=default
virtual int init_sock_probe(sock_probe *s)=0
virtual char * get_if_name(sock_probe *s, int count)=0
Gcs_sock_probe_interface & operator=(const Gcs_sock_probe_interface &)=default
Gcs_sock_probe_interface & operator=(Gcs_sock_probe_interface &&)=default
virtual int number_of_interfaces(sock_probe *s)=0
virtual void close_sock_probe(sock_probe *s)=0
Gcs_sock_probe_interface(Gcs_sock_probe_interface &&)=default
virtual ~Gcs_sock_probe_interface()=default
virtual void get_sockaddr_address(sock_probe *s, int count, struct sockaddr **out)=0
virtual bool_t is_if_running(sock_probe *s, int count)=0
Gcs_sock_probe_interface()=default
virtual void get_sockaddr_netmask(sock_probe *s, int count, struct sockaddr **out)=0
bool resolve_ip_addr_from_hostname(std::string name, std::vector< std::string > &ip)
This function translates hostname to all possible IP addresses.
Definition: gcs_xcom_networking.cc:258
bool get_local_addresses(Gcs_sock_probe_interface &sock_probe, std::map< std::string, int > &out, bool filter_out_inactive=false)
This function gets all network addresses on this host and their subnet masks as a string.
Definition: gcs_xcom_networking.cc:93
bool get_local_private_addresses(std::map< std::string, int > &out, bool filter_out_inactive=false)
This function gets all private network addresses and their subnet masks as a string.
Definition: gcs_xcom_networking.cc:209
bool get_address_for_allowlist(std::string addr, std::string mask, std::pair< std::vector< unsigned char >, std::vector< unsigned char > > &out_pair)
Converts an address in string format (X.X.X.X/XX) into network octet format.
Definition: gcs_xcom_networking.cc:708
bool resolve_all_ip_addr_from_hostname(std::string name, std::vector< std::pair< sa_family_t, std::string > > &ips)
This function translates hostnames to all possible IP addresses.
Definition: gcs_xcom_networking.cc:300
static mi_bit_type mask[]
Definition: mi_packrec.cc:141
static int count
Definition: myisam_ftdump.cc:45
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2876
struct sockaddr sockaddr
Definition: sock_probe_win32.h:63
case opt name
Definition: sslopt-case.h:29
Definition: gcs_xcom_networking.h:208
bool operator()(const Gcs_ip_allowlist_entry *lhs, const Gcs_ip_allowlist_entry *rhs) const
Definition: gcs_xcom_networking.h:209
Definition: site_struct.h:43
Definition: sock_probe_ix.h:54
__u_short u_short
Definition: types.h:72
int bool_t
Definition: types.h:35