Skip to content

Commit 68f6277

Browse files
committed
Merge branch 'json-plugin-remove-ip-check' into 'master'
json output: remove IP format checking in Config to allow domain names to be entered See merge request monitoring/ipfixcol2!11
2 parents 4ccdd42 + 72a79a3 commit 68f6277

File tree

5 files changed

+3
-35
lines changed

5 files changed

+3
-35
lines changed

src/plugins/output/json-kafka/src/Config.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -126,21 +126,6 @@ static const struct fds_xml_args args_params[] = {
126126
FDS_OPTS_END
127127
};
128128

129-
/**
130-
* \brief Check if a given string is a valid IPv4/IPv6 address
131-
* \param[in] ip_addr Address to check
132-
* \return True or false
133-
*/
134-
bool
135-
Config::check_ip(const std::string &ip_addr)
136-
{
137-
in_addr ipv4;
138-
in6_addr ipv6;
139-
140-
return (inet_pton(AF_INET, ip_addr.c_str(), &ipv4) == 1
141-
|| inet_pton(AF_INET6, ip_addr.c_str(), &ipv6) == 1);
142-
}
143-
144129
/**
145130
* \brief Check one of 2 expected options
146131
*

src/plugins/output/json-kafka/src/Config.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ struct cfg_kafka : cfg_output {
101101
/** Parsed configuration of an instance */
102102
class Config {
103103
private:
104-
bool check_ip(const std::string &ip_addr);
105104
bool check_or(const std::string &elem, const char *value, const std::string &val_true,
106105
const std::string &val_false);
107106
void check_validity();

src/plugins/output/json/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ with each other.
230230
"``ncat -lk <local ip> <local port>``"
231231

232232
:``name``: Identification name of the output. Used only for readability.
233-
:``ip``: IPv4/IPv6 address of the client
233+
:``ip``: IP address or domain name of the client
234234
:``port``: Remote port number
235235
:``protocol``: Transport protocol: TCP or UDP (this field is case insensitive)
236236
:``blocking``:

src/plugins/output/json/src/Config.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -257,21 +257,6 @@ static const struct fds_xml_args args_params[] = {
257257
FDS_OPTS_END
258258
};
259259

260-
/**
261-
* \brief Check if a given string is a valid IPv4/IPv6 address
262-
* \param[in] ip_addr Address to check
263-
* \return True or false
264-
*/
265-
bool
266-
Config::check_ip(const std::string &ip_addr)
267-
{
268-
in_addr ipv4;
269-
in6_addr ipv6;
270-
271-
return (inet_pton(AF_INET, ip_addr.c_str(), &ipv4) == 1
272-
|| inet_pton(AF_INET6, ip_addr.c_str(), &ipv6) == 1);
273-
}
274-
275260
/**
276261
* \brief Check one of 2 expected options
277262
*
@@ -436,9 +421,9 @@ Config::parse_send(fds_xml_ctx_t *send)
436421
throw std::runtime_error("Name of a <send> output must be defined!");
437422
}
438423

439-
if (output.addr.empty() || !check_ip(output.addr)) {
424+
if (output.addr.empty()) {
440425
throw std::runtime_error("Value of the element <ip> of the output <send> '" + output.name
441-
+ "' is not a valid IPv4/IPv6 address");
426+
+ "' must be defined!");
442427
}
443428

444429
outputs.sends.push_back(output);

src/plugins/output/json/src/Config.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ struct cfg_syslog : cfg_output {
177177
/** Parsed configuration of an instance */
178178
class Config {
179179
private:
180-
bool check_ip(const std::string &ip_addr);
181180
bool check_or(const std::string &elem, const char *value, const std::string &val_true,
182181
const std::string &val_false);
183182
bool is_syslog_ascii(const std::string &str);

0 commit comments

Comments
 (0)