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
21e9b5cc
Commit
21e9b5cc
authored
Jun 29, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(captive portal) cleanup unused code
parent
fc7a7d0e
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
391 deletions
+40
-391
CPClient.php
...nsense/mvc/app/models/OPNsense/CaptivePortal/CPClient.php
+40
-19
Rules.php
src/opnsense/mvc/app/models/OPNsense/CaptivePortal/Rules.php
+0
-372
No files found.
src/opnsense/mvc/app/models/OPNsense/CaptivePortal/CPClient.php
View file @
21e9b5cc
...
...
@@ -48,18 +48,42 @@ class CPClient
*/
private
$config
=
null
;
/**
* ipfw rule object
* @var \CaptivePortal\Rules
*/
private
$rules
=
null
;
/**
* link to shell object
* @var Core\Shell
*/
private
$shell
=
null
;
/**
* get ipfw tables for authenticated users ( in/out )
* @param int $zoneid zoneid (number)
* @return array
*/
public
function
getAuthUsersTables
(
$zoneid
)
{
return
array
(
"in"
=>
(
6
*
(
$zoneid
-
1
)
)
+
1
,
"out"
=>
(
6
*
(
$zoneid
-
1
)
)
+
2
);
}
/**
* get ipfw tables for authenticated hosts ( in/out )
* @param int $zoneid zoneid (number)
* @return array
*/
public
function
getAuthIPTables
(
$zoneid
)
{
return
array
(
"in"
=>
(
6
*
(
$zoneid
-
1
)
)
+
3
,
"out"
=>
(
6
*
(
$zoneid
-
1
)
)
+
4
);
}
/**
* get ipfw tables used for authenticated physical addresses
* @param int $zoneid zoneid (number)
* @return array
*/
public
function
getAuthMACTables
(
$zoneid
)
{
return
array
(
"in"
=>
(
6
*
(
$zoneid
-
1
)
)
+
5
,
"out"
=>
(
6
*
(
$zoneid
-
1
)
)
+
6
);
}
/**
* Constructor
*/
...
...
@@ -67,8 +91,6 @@ class CPClient
{
// Request handle to configuration
$this
->
config
=
Core\Config
::
getInstance
();
// generate new ruleset
$this
->
rules
=
new
Rules
();
// keep a link to the shell object
$this
->
shell
=
new
Core\Shell
();
}
...
...
@@ -95,7 +117,6 @@ class CPClient
{
$backend
=
new
Backend
();
if
(
$this
->
isEnabled
())
{
$ruleset_filename
=
FactoryDefault
::
getDefault
()
->
get
(
'config'
)
->
globals
->
temp_path
.
"/ipfw.rules"
;
$response
=
$backend
->
configdRun
(
"template reload OPNsense.IPFW"
);
if
(
trim
(
$response
)
==
"OK"
)
{
...
...
@@ -162,7 +183,7 @@ class CPClient
$db_iplist
=
$db
->
listFixedIPs
();
// calculate table numbers for this zone
$ipfw_tables
=
$this
->
rules
->
getAuthIPTables
(
$zone
->
zoneid
);
$ipfw_tables
=
$this
->
getAuthIPTables
(
$zone
->
zoneid
);
foreach
(
$zone
->
children
()
as
$tagname
=>
$tagcontent
)
{
$ip
=
$tagcontent
->
ip
->
__toString
();
...
...
@@ -276,7 +297,7 @@ class CPClient
// open administrative database for this zone
$db
=
new
DB
(
$cpzonename
);
$db_maclist
=
$db
->
listPassthruMacs
();
$ipfw_tables
=
$this
->
rules
->
getAuthMACTables
(
$zone
->
zoneid
);
$ipfw_tables
=
$this
->
getAuthMACTables
(
$zone
->
zoneid
);
foreach
(
$zone
->
children
()
as
$tagname
=>
$tagcontent
)
{
$mac
=
trim
(
strtolower
(
$tagcontent
->
mac
));
...
...
@@ -497,7 +518,7 @@ class CPClient
// grap needed data to generate our rules
$ipfw_tables
=
$this
->
rules
->
getAuthUsersTables
(
$zoneid
);
$ipfw_tables
=
$this
->
getAuthUsersTables
(
$zoneid
);
$cp_table
=
$db
->
listClients
(
array
(
"mac"
=>
$clientmac
,
"ip"
=>
$clientip
),
"or"
);
if
(
sizeof
(
$cp_table
)
>
0
&&
(
$cp_table
[
0
]
->
ip
==
$clientip
&&
$cp_table
[
0
]
->
mac
==
$clientmac
))
{
// nothing (important) changed here... move on
...
...
@@ -627,12 +648,12 @@ class CPClient
if
(
$zoneid
!=
-
1
)
{
$exec_commands
=
array
(
"/sbin/ipfw -f table "
.
$this
->
rules
->
getAuthUsersTables
(
$zoneid
)[
"in"
]
.
" flush"
,
"/sbin/ipfw -f table "
.
$this
->
rules
->
getAuthUsersTables
(
$zoneid
)[
"out"
]
.
" flush"
,
"/sbin/ipfw -f table "
.
$this
->
rules
->
getAuthIPTables
(
$zoneid
)[
"in"
]
.
" flush"
,
"/sbin/ipfw -f table "
.
$this
->
rules
->
getAuthIPTables
(
$zoneid
)[
"out"
]
.
" flush"
,
"/sbin/ipfw -f table "
.
$this
->
rules
->
getAuthMACTables
(
$zoneid
)[
"in"
]
.
" flush"
,
"/sbin/ipfw -f table "
.
$this
->
rules
->
getAuthMACTables
(
$zoneid
)[
"out"
]
.
" flush"
,
"/sbin/ipfw -f table "
.
$this
->
getAuthUsersTables
(
$zoneid
)[
"in"
]
.
" flush"
,
"/sbin/ipfw -f table "
.
$this
->
getAuthUsersTables
(
$zoneid
)[
"out"
]
.
" flush"
,
"/sbin/ipfw -f table "
.
$this
->
getAuthIPTables
(
$zoneid
)[
"in"
]
.
" flush"
,
"/sbin/ipfw -f table "
.
$this
->
getAuthIPTables
(
$zoneid
)[
"out"
]
.
" flush"
,
"/sbin/ipfw -f table "
.
$this
->
getAuthMACTables
(
$zoneid
)[
"in"
]
.
" flush"
,
"/sbin/ipfw -f table "
.
$this
->
getAuthMACTables
(
$zoneid
)[
"out"
]
.
" flush"
,
"/sbin/ipfw delete set "
.
$zoneid
,
);
$this
->
shell
->
exec
(
$exec_commands
);
...
...
@@ -786,7 +807,7 @@ class CPClient
$db
=
new
DB
(
$cpzonename
);
$db_clients
=
$db
->
listClients
(
array
(
"sessionid"
=>
$sessionid
));
$ipfw_tables
=
$this
->
rules
->
getAuthUsersTables
(
$zoneid
);
$ipfw_tables
=
$this
->
getAuthUsersTables
(
$zoneid
);
if
(
sizeof
(
$db_clients
)
>
0
)
{
if
(
$db_clients
[
0
]
->
ip
!=
null
)
{
// only handle disconnect if we can find a client in our database
...
...
src/opnsense/mvc/app/models/OPNsense/CaptivePortal/Rules.php
deleted
100644 → 0
View file @
fc7a7d0e
This diff is collapsed.
Click to expand it.
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