Skip to content

Commit

Permalink
Add option to provide a custom networks list for option --local-netwo…
Browse files Browse the repository at this point in the history
…rks.
  • Loading branch information
madpilot78 committed Jul 3, 2017
1 parent c3da76b commit fc2f34f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
18 changes: 18 additions & 0 deletions net/pfSense-pkg-ntopng/files/usr/local/pkg/ntopng.inc
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,17 @@ function ntopng_sync_package() {
$local_networks = "--local-networks " . escapeshellarg(gen_subnet(get_interface_ip('lan'), get_interface_subnet('lan')) . '/' . get_interface_subnet('lan'));
}
break;
case "custom":
$nets = array();
foreach ($ntopng_config['row'] as $net) {
if (is_subnet($net['cidr'])) {
$nets[] = $net['cidr'];
}
}
if (!empty($nets)) {
$local_networks = "--local-networks " . escapeshellarg(implode(",", $nets));
}
break;
case "rfc1918":
default:
$local_networks = "--local-networks '192.168.0.0/16,172.16.0.0/12,10.0.0.0/8'";
Expand Down Expand Up @@ -323,6 +334,13 @@ function ntopng_validate_input($post, &$input_errors) {
if ($post['redis_password'] != $post['redis_passwordagain']) {
$input_errors[] = "The provided passwords did not match.";
}
$idx = 0;
while (isset($_POST["cidr{$idx}"])) {
$cidr = $_POST["cidr" . $idx++];
if (!is_subnet($cidr)) {
$input_errors[] = "Invalid CIDR in custom local networks list at position {$idx}.";
}
}
if ($post['Submit'] == "Update GeoIP Data") {
ntopng_update_geoip();
}
Expand Down
13 changes: 13 additions & 0 deletions net/pfSense-pkg-ntopng/files/usr/local/pkg/ntopng.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,21 @@
<option><value>rfc1918</value><name>Consider all RFC1918 networks local</name></option>
<option><value>selected</value><name>Consider selected interface networks local</name></option>
<option><value>lanonly</value><name>Consider only LAN interface local</name></option>
<option><value>custom</value><name>Use custom list below</name></option>
</options>
</field>
<field>
<fielddescr>Custom Local Networks list</fielddescr>
<fieldname>none</fieldname>
<type>rowhelper</type>
<rowhelper>
<rowhelperfield>
<fielddescr>CIDR</fielddescr>
<fieldname>cidr</fieldname>
<type>input</type>
</rowhelperfield>
</rowhelper>
</field>
<!-- Hide nonfunctional stuff pending rework - see https://redmine.pfsense.org/issues/7000 -->
<!--
<field>
Expand Down

16 comments on commit fc2f34f

@timothyad757
Copy link

@timothyad757 timothyad757 commented on fc2f34f Jul 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no clue what is wrong with your code, but eversince you added this option I get an error saying "Invalid CIDR in custom local networks list at position 1." Even tough I have "consider all..." on. Please fix this as soon as possible. I cant use ntopng at all now for all of my sites.

@madpilot78
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to look at this shortly.

In the while I am reasonably sure you can work it around by inserting a valid CIDR network at position one if it is empty, considering the error message you're getting. It will be ignored in the actual running configuration.

@timothyad757
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did, for our network, a 22. It still gave me the error. Literally after this update I can not access anything in ntopng.

@madpilot78
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm testing it to create a fix, If putting a valid CIDR there does not work, I don't really know what's wrong, I need to perform some testing. I'll ask for further feedback if I need it.

@timothyad757
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you need any logs or anything like that just guide me on how to. Thank you.

@madpilot78
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make sure and correctly try to reproduce this, what have you inserted as CIDR in the custom network fields? Can you send me a screenshot?

@timothyad757
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timothyad757
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@madpilot78
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first screenshot shows you just put "22" in the field, which is not a valid CIDR.

Try using "192.168.0.1/24", which is a valid CIDR, and this should work as a workaround while I try to find a fix.

@timothyad757
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That worked for one router. I have another with the newest version and ntopng is just not loading with the same settings as the other router that is now working. I am in the process of reinstalling ntopng on the non working one.

@timothyad757
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@madpilot78
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what is the difference between the two, but I'd suggest you use "192.168.0.1/24", not "192.168.1.0/24". I think the second version is not a proper CIDR address either.

@dennypage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"192.168.1.0/24" is certainly a correct CIDR. One could argue that "192.168.0.1/24" is not because it contains non zero ignored bits.

@madpilot78
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have anyway just sent pull request #372, which should fix this issue.

@timothyad757
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks man. I tried your suggestion and it didn't work... Anyway to send you logs?

@dennypage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.8.10 has already been pushed out and this addresses the problem.

Please sign in to comment.