-
Notifications
You must be signed in to change notification settings - Fork 675
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
974 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
PLUGIN_NAME= OPNarplog | ||
PLUGIN_VERSION= 0.1 | ||
PLUGIN_REVISION= 1 | ||
PLUGIN_COMMENT= arpwatch alternative for OPNsense | ||
PLUGIN_MAINTAINER= github.com/mr-manuel | ||
|
||
.include "../../Mk/plugins.mk" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
OPNarplog is a versatile network monitoring tool that tracks and logs changes in ARP (Address Resolution Protocol) and NDP (Neighbor Discovery Protocol) tables, capturing key details such as IPv4 and IPv6 addresses, hostnames, MAC addresses, and interface changes. The plugin is configurable, allowing administrators to selectively enable or disable tracking for different modifications based on specific needs, whether it’s for IP address shifts, hostname updates, new MAC detections, or interface changes. This customization and comprehensive logging ensure precise, up-to-date network visibility, ideal for securing networks and managing dynamic device inventories effectively. | ||
|
||
WWW: https://github.com/mr-manuel/opnsense_plugins | ||
|
||
|
||
Plugin Changelog | ||
================ | ||
|
||
0.1 | ||
|
||
* Initial release |
Large diffs are not rendered by default.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
net-mgmt/opnarplog/src/etc/inc/plugins.inc.d/opnarplog.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright (C) 2024 github.com/mr-manuel | ||
* All rights reserved. | ||
* | ||
*/ | ||
|
||
function opnarplog_services() | ||
{ | ||
global $config; | ||
|
||
$services = array(); | ||
|
||
if (isset($config['OPNsense']['opnarplog']['general']['enabled']) && $config['OPNsense']['opnarplog']['general']['enabled'] == 1) { | ||
$services[] = array( | ||
'description' => gettext('OPNarplog Daemon'), | ||
'configd' => array( | ||
'restart' => array('opnarplog restart'), | ||
'start' => array('opnarplog start'), | ||
'stop' => array('opnarplog stop'), | ||
), | ||
'name' => 'opnarplog', | ||
'pidfile' => '/var/run/opnarplog.pid', | ||
); | ||
} | ||
|
||
return $services; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/sh | ||
# | ||
# $FreeBSD$ | ||
# | ||
# PROVIDE: opnarplog | ||
# REQUIRE: SERVERS | ||
# KEYWORD: shutdown | ||
# | ||
|
||
. /etc/rc.subr | ||
|
||
name=opnarplog | ||
|
||
rcvar=opnarplog_enable | ||
pidfile=/var/run/${name}.pid | ||
command=/usr/sbin/daemon | ||
command_args="-f -P ${pidfile} /usr/local/bin/python3 /usr/local/bin/opnarplog.py" | ||
|
||
load_rc_config ${name} | ||
|
||
: ${opnarplog_enable="NO"} | ||
|
||
run_rc_command $1 |
16 changes: 16 additions & 0 deletions
16
...t/opnarplog/src/opnsense/mvc/app/controllers/OPNsense/opnarplog/Api/GeneralController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright (C) 2024 github.com/mr-manuel | ||
* All rights reserved. | ||
*/ | ||
|
||
namespace OPNsense\Opnarplog\Api; | ||
|
||
use OPNsense\Base\ApiMutableModelControllerBase; | ||
|
||
class GeneralController extends ApiMutableModelControllerBase | ||
{ | ||
protected static $internalModelClass = '\OPNsense\Opnarplog\General'; | ||
protected static $internalModelName = 'general'; | ||
} |
32 changes: 32 additions & 0 deletions
32
...t/opnarplog/src/opnsense/mvc/app/controllers/OPNsense/opnarplog/Api/ServiceController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright (C) 2024 github.com/mr-manuel | ||
* All rights reserved. | ||
*/ | ||
|
||
namespace OPNsense\Opnarplog\Api; | ||
|
||
use OPNsense\Base\ApiMutableServiceControllerBase; | ||
use OPNsense\Core\Backend; | ||
use OPNsense\Opnarplog\General; | ||
|
||
class ServiceController extends ApiMutableServiceControllerBase | ||
{ | ||
protected static $internalServiceClass = '\OPNsense\Opnarplog\General'; | ||
protected static $internalServiceTemplate = 'OPNsense/Opnarplog'; | ||
protected static $internalServiceEnabled = 'enabled'; | ||
protected static $internalServiceName = 'opnarplog'; | ||
|
||
/** | ||
* remove database folder | ||
* @return array | ||
*/ | ||
public function resetdbAction() | ||
{ | ||
$backend = new Backend(); | ||
$response = $backend->configdRun("opnarplog resetdb"); | ||
return array("response" => $response); | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
net-mgmt/opnarplog/src/opnsense/mvc/app/controllers/OPNsense/opnarplog/GeneralController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright (C) 2024 github.com/mr-manuel | ||
* All rights reserved. | ||
*/ | ||
|
||
namespace OPNsense\Opnarplog; | ||
|
||
class GeneralController extends \OPNsense\Base\IndexController | ||
{ | ||
public function indexAction() | ||
{ | ||
$this->view->generalForm = $this->getForm('general'); | ||
$this->view->pick('OPNsense/Opnarplog/general'); | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
net-mgmt/opnarplog/src/opnsense/mvc/app/controllers/OPNsense/opnarplog/forms/general.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<form> | ||
<field> | ||
<id>general.enabled</id> | ||
<label>Enable</label> | ||
<type>checkbox</type> | ||
<help>Enable or disable OPNarplog. This will not automatically enable any mail notifications, see notes below</help> | ||
</field> | ||
<field> | ||
<id>general.protocols</id> | ||
<label>Protocols</label> | ||
<type>dropdown</type> | ||
<help>Select the protocols you want to watch</help> | ||
</field> | ||
<field> | ||
<id>general.interfaces</id> | ||
<label>Interfaces</label> | ||
<type>select_multiple</type> | ||
<help>Leave empty to track on all interfaces or add the interfaces you want to track</help> | ||
<hint>All (default)</hint> | ||
</field> | ||
<field> | ||
<id>general.suppress_mac</id> | ||
<label>Suppress MAC address</label> | ||
<type>select_multiple</type> | ||
<style>tokenize</style> | ||
<allownew>true</allownew> | ||
<help> | ||
<![CDATA[Add MAC addresses you want to exclude from the notifications in the following format: xx:xx:xx:xx:xx<br> | ||
The firewall MAC addresses are already excluded]]> | ||
</help> | ||
</field> | ||
<field> | ||
<id>general.log_new_entries</id> | ||
<label>Log new MAC/IP address entries</label> | ||
<type>checkbox</type> | ||
<help>Enable or disable the logging of new entries</help> | ||
</field> | ||
<field> | ||
<id>general.log_mac_changes</id> | ||
<label>Log MAC address changes</label> | ||
<type>checkbox</type> | ||
<help>Enable or disable the logging of MAC address changes (helps to find duplicates or spoofing)</help> | ||
</field> | ||
<field> | ||
<id>general.log_ipv4_changes</id> | ||
<label>Log IPv4 address changes</label> | ||
<type>checkbox</type> | ||
<help>Enable or disable the logging of IPv4 address changes</help> | ||
</field> | ||
<field> | ||
<id>general.log_ipv6_changes</id> | ||
<label>Log IPv6 address changes</label> | ||
<type>checkbox</type> | ||
<help>Enable or disable the logging of IPv6 address changes</help> | ||
</field> | ||
<field> | ||
<id>general.log_hostname_changes</id> | ||
<label>Log hostname changes</label> | ||
<type>checkbox</type> | ||
<help>Enable or disable the logging of hostname changes</help> | ||
</field> | ||
<field> | ||
<id>general.log_interface_changes</id> | ||
<label>Log interface changes</label> | ||
<type>checkbox</type> | ||
<help>Enable or disable the logging of interface changes</help> | ||
</field> | ||
<field> | ||
<id>general.retention_days</id> | ||
<label>Retention</label> | ||
<type>text</type> | ||
<advanced>true</advanced> | ||
<help>After how many days should an inactive MAC address be deleted from the database? After this period the device is recognized as new</help> | ||
</field> | ||
</form> |
9 changes: 9 additions & 0 deletions
9
net-mgmt/opnarplog/src/opnsense/mvc/app/models/OPNsense/opnarplog/ACL/ACL.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<acl> | ||
<page-opnarplog-config> | ||
<name>Services: OPNarplog</name> | ||
<patterns> | ||
<pattern>ui/opnarplog/*</pattern> | ||
<pattern>api/opnarplog/*</pattern> | ||
</patterns> | ||
</page-opnarplog-config> | ||
</acl> |
56 changes: 56 additions & 0 deletions
56
...log/src/opnsense/mvc/app/models/OPNsense/opnarplog/FieldTypes/OpnarplogInterfaceField.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright (C) 2023 Deciso B.V. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY | ||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, | ||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
namespace OPNsense\Opnarplog\FieldTypes; | ||
|
||
use OPNsense\Base\FieldTypes\BaseListField; | ||
use OPNsense\Core\Config; | ||
|
||
/** | ||
* Class OpnarplogDomainField | ||
* @package OPNsense\Opnarplog\FieldTypes | ||
* Created from src\opnsense\mvc\app\models\OPNsense\Unbound\FieldTypes\UnboundInterfaceField.php | ||
*/ | ||
class OpnarplogInterfaceField extends BaseListField | ||
{ | ||
/** | ||
* Iterate over all interfaces in the configuration and only exclude virtual interfaces. | ||
*/ | ||
public function actionPostLoadingEvent() | ||
{ | ||
$config = Config::getInstance()->object(); | ||
|
||
foreach ($config->interfaces->children() as $key => $node) { | ||
if (empty($node->virtual)) { | ||
$this->internalOptionList[str_replace(".", "_", $node->if)] = !empty($node->descr) ? (string)$node->descr : strtoupper($key); | ||
} | ||
} | ||
|
||
natcasesort($this->internalOptionList); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
net-mgmt/opnarplog/src/opnsense/mvc/app/models/OPNsense/opnarplog/General.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright (C) 2024 github.com/mr-manuel | ||
* All rights reserved. | ||
*/ | ||
|
||
namespace OPNsense\Opnarplog; | ||
|
||
use OPNsense\Base\BaseModel; | ||
|
||
class General extends BaseModel | ||
{ | ||
} |
54 changes: 54 additions & 0 deletions
54
net-mgmt/opnarplog/src/opnsense/mvc/app/models/OPNsense/opnarplog/General.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<model> | ||
<mount>//OPNsense/opnarplog/general</mount> | ||
<description>OPNarplog general configuration</description> | ||
<version>0.0.1</version> | ||
<items> | ||
<enabled type="BooleanField"> | ||
<default>0</default> | ||
<Required>Y</Required> | ||
</enabled> | ||
<protocols type="OptionField"> | ||
<Default>IPv4 and IPv6</Default> | ||
<Required>Y</Required> | ||
<OptionValues> | ||
<opt1 value="all">IPv4 and IPv6</opt1> | ||
<opt2 value="ipv4_only">IPv4 only</opt2> | ||
<opt3 value="ipv6_only">IPv6 only</opt3> | ||
</OptionValues> | ||
</protocols> | ||
<interfaces type=".\OpnarplogInterfaceField"> | ||
<Required>N</Required> | ||
<Multiple>Y</Multiple> | ||
</interfaces> | ||
<suppress_mac type="CSVListField"> | ||
<Required>N</Required> | ||
<Multiple>Y</Multiple> | ||
</suppress_mac> | ||
<log_new_entries type="BooleanField"> | ||
<default>1</default> | ||
</log_new_entries> | ||
<log_mac_changes type="BooleanField"> | ||
<default>1</default> | ||
</log_mac_changes> | ||
<log_ipv4_changes type="BooleanField"> | ||
<default>0</default> | ||
</log_ipv4_changes> | ||
<log_ipv6_changes type="BooleanField"> | ||
<default>0</default> | ||
</log_ipv6_changes> | ||
<log_hostname_changes type="BooleanField"> | ||
<default>0</default> | ||
</log_hostname_changes> | ||
<log_interface_changes type="BooleanField"> | ||
<default>0</default> | ||
</log_interface_changes> | ||
<retention_days type="IntegerField"> | ||
<Default>30</Default> | ||
<Required>Y</Required> | ||
<advanced>true</advanced> | ||
<MinimumValue>1</MinimumValue> | ||
<MaximumValue>365</MaximumValue> | ||
<ValidationMessage>Retention needs to be an integer value between 1 and 365</ValidationMessage> | ||
</retention_days> | ||
</items> | ||
</model> |
8 changes: 8 additions & 0 deletions
8
net-mgmt/opnarplog/src/opnsense/mvc/app/models/OPNsense/opnarplog/Menu/Menu.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<menu> | ||
<Services> | ||
<OPNarplog VisibleName="OPNarplog" cssClass="fa fa-eye fa-fw"> | ||
<General VisibleName="General" url="/ui/opnarplog/general/index" /> | ||
<LogFile VisibleName="Log File" url="/ui/diagnostics/log/core/opnarplog" /> | ||
</OPNarplog> | ||
</Services> | ||
</menu> |
Oops, something went wrong.