Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
fd12c668
Commit
fd12c668
authored
Oct 30, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(filter) more refactoring, as discussed with @fichtner move core rules out of plugin scope
parent
2c2192d7
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
20 deletions
+67
-20
filter.inc
src/etc/inc/filter.inc
+3
-1
filter.lib.inc
src/etc/inc/filter.lib.inc
+59
-0
core_fw.inc
src/etc/inc/plugins.inc.d/core_fw.inc
+0
-18
Plugin.php
src/opnsense/mvc/app/library/OPNsense/Firewall/Plugin.php
+5
-1
No files found.
src/etc/inc/filter.inc
View file @
fd12c668
<?php
<?php
/*
/*
Copyright (C) 2004-2007 Scott Ullrich
Copyright (C) 2004-2007 Scott Ullrich
Copyright (C) 2005 Bill Marquette
Copyright (C) 2005 Bill Marquette
...
@@ -30,6 +29,8 @@
...
@@ -30,6 +29,8 @@
POSSIBILITY OF SUCH DAMAGE.
POSSIBILITY OF SUCH DAMAGE.
*/
*/
require_once
(
'filter.lib.inc'
);
/* Create a global array to avoid errors on rulesets. */
/* Create a global array to avoid errors on rulesets. */
$GatewaysList
=
array
();
$GatewaysList
=
array
();
...
@@ -375,6 +376,7 @@ function filter_configure_sync()
...
@@ -375,6 +376,7 @@ function filter_configure_sync()
// initialize fw plugin object
// initialize fw plugin object
$fw
=
new
\OPNsense\Firewall\Plugin
();
$fw
=
new
\OPNsense\Firewall\Plugin
();
$fw
->
setInterfaceMapping
(
$FilterIflist
);
$fw
->
setInterfaceMapping
(
$FilterIflist
);
filter_core_bootstrap
(
$fw
);
if
(
function_exists
(
'plugins_firewall'
))
{
if
(
function_exists
(
'plugins_firewall'
))
{
plugins_firewall
(
$fw
);
plugins_firewall
(
$fw
);
...
...
src/etc/inc/filter.lib.inc
0 → 100644
View file @
fd12c668
<?php
/**
* Copyright (C) 2016 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.
*
*/
function
filter_core_bootstrap
(
$fw
)
{
global
$config
;
// set defaults
$filter_rule_defaults
=
array
();
$filter_rule_defaults
[
'pass'
]
=
array
(
"type"
=>
"pass"
,
"log"
=>
!
isset
(
$config
[
'syslog'
][
'nologdefaultpass'
]));
$filter_rule_defaults
[
'block'
]
=
array
(
"type"
=>
"block"
,
"log"
=>
!
isset
(
$config
[
'syslog'
][
'nologdefaultblock'
]));
// setup system filter rules
filter_core_rules_system
(
$fw
,
$filter_rule_defaults
);
}
/**
* core system rules
*/
function
filter_core_rules_system
(
$fw
,
$defaults
)
{
global
$config
;
// block All IPv6 except loopback traffic
$fw
->
registerFilterRule
(
1
,
array
(
'interface'
=>
'loopback'
,
'ipprotocol'
=>
'inet6'
,
'disabled'
=>
isset
(
$config
[
'system'
][
'ipv6allow'
]),
'label'
=>
'Pass all loopback IPv6'
),
$defaults
[
'pass'
]
);
$fw
->
registerFilterRule
(
1
,
array
(
'ipprotocol'
=>
'inet6'
,
'label'
=>
'Block all IPv6'
,
'disabled'
=>
isset
(
$config
[
'system'
][
'ipv6allow'
])),
$defaults
[
'block'
]
);
}
src/etc/inc/plugins.inc.d/core_fw.inc
deleted
100644 → 0
View file @
2c2192d7
<?php
function
core_fw_firewall
(
$fw
)
{
global
$config
;
$log_block
=
!
isset
(
$config
[
'syslog'
][
'nologdefaultblock'
]);
$log_pass
=
!
isset
(
$config
[
'syslog'
][
'nologdefaultpass'
]);
if
(
!
isset
(
$config
[
'system'
][
'ipv6allow'
]))
{
// block All IPv6 except loopback traffic
$fw
->
registerFilterRule
(
0
,
array
(
'type'
=>
'pass'
,
'log'
=>
$log_pass
,
'interface'
=>
'loopback'
,
'ipprotocol'
=>
'inet6'
)
);
$fw
->
registerFilterRule
(
0
,
array
(
'type'
=>
'block'
,
'log'
=>
$log_block
,
'ipprotocol'
=>
'inet6'
,
'label'
=>
'Block all IPv6'
)
);
}
}
src/opnsense/mvc/app/library/OPNsense/Firewall/Plugin.php
View file @
fd12c668
...
@@ -98,9 +98,13 @@ class Plugin
...
@@ -98,9 +98,13 @@ class Plugin
* register a filter rule
* register a filter rule
* @param int $prio priority
* @param int $prio priority
* @param array $conf configuration
* @param array $conf configuration
* @param array $defaults merge these defaults when provided
*/
*/
public
function
registerFilterRule
(
$prio
,
$conf
)
public
function
registerFilterRule
(
$prio
,
$conf
,
$defaults
=
null
)
{
{
if
(
$defaults
!=
null
)
{
$conf
=
array_merge
(
$defaults
,
$conf
);
}
$rule
=
new
FilterRule
(
$this
->
interfaceMapping
,
$conf
);
$rule
=
new
FilterRule
(
$this
->
interfaceMapping
,
$conf
);
if
(
empty
(
$this
->
filterRules
[
$prio
]))
{
if
(
empty
(
$this
->
filterRules
[
$prio
]))
{
$this
->
filterRules
[
$prio
]
=
array
();
$this
->
filterRules
[
$prio
]
=
array
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment