Skip to content

Commit 12e6e32

Browse files
authored
Merge pull request #2839 from martinhsv/v3/master
Support comments in ipMatchFromFile file via '#' token
2 parents 503804b + 0c0e4a2 commit 12e6e32

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

Diff for: CHANGES

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
v3.x.y - YYYY-MMM-DD (to be released)
22
-------------------------------------
33

4+
- Support comments in ipMatchFromFile file via '#' token
5+
[Issue #2554 - @tomsommer, @martinhsv]
46
- Use name package name libmaxminddb with pkg-config
57
[Issue #2595, #2596 - @frankvanbever, @ffontaine, @arnout]
68
- Fix: FILES_TMP_CONTENT collection key should use part name

Diff for: src/utils/ip_tree.cc

+4
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ IpTree::~IpTree() {
8888
bool IpTree::addFromBuffer(std::istream *ss, std::string *error) {
8989
char *error_msg = NULL;
9090
for (std::string line; std::getline(*ss, line); ) {
91+
size_t comment_start = line.find('#');
92+
if (comment_start != std::string::npos) {
93+
line = line.substr(0, comment_start);
94+
}
9195
int res = add_ip_from_param(line.c_str(), &m_tree, &error_msg);
9296
if (res != 0) {
9397
if (error_msg != NULL) {

Diff for: test/test-cases/data/ipMatchFromFile.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
127.0.0.1
2+
# Comment line
23
10.10.10.1
34
::1
45
200.249.12.31

0 commit comments

Comments
 (0)