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
bb55bc37
Commit
bb55bc37
authored
Dec 26, 2014
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tracker + captive portal fixes
parent
8a396a64
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
5 deletions
+75
-5
CPClient.php
src/opnsense/mvc/app/models/Captiveportal/CPClient.php
+73
-1
diag_logs_filter.php
src/www/diag_logs_filter.php
+1
-0
firewall_rules_edit.php
src/www/firewall_rules_edit.php
+0
-3
log.widget.php
src/www/widgets/widgets/log.widget.php
+1
-1
No files found.
src/opnsense/mvc/app/models/Captiveportal/CPClient.php
View file @
bb55bc37
...
...
@@ -99,7 +99,7 @@ class CPClient {
$ipfw_tables
=
$this
->
rules
->
getAuthUsersTables
(
$zoneid
);
if
(
sizeof
(
$db_clients
)
>
0
){
if
(
$db_clients
->
ip
!=
null
)
{
if
(
$db_clients
[
0
]
->
ip
!=
null
)
{
// only handle disconnect if we can find a client in our database
$exec_commands
[]
=
"/sbin/ipfw table "
.
$ipfw_tables
[
"in"
]
.
" delete "
.
$db_clients
[
0
]
->
ip
;
$exec_commands
[]
=
"/sbin/ipfw table "
.
$ipfw_tables
[
"out"
]
.
" delete "
.
$db_clients
[
0
]
->
ip
;
...
...
@@ -153,6 +153,36 @@ class CPClient {
}
}
/**
* list (ipfw) accounting information
* @return array (key = hosts ip)
*/
public
function
list_accounting
(
$ipaddr
=
null
){
$filter_cmd
=
""
;
$result
=
array
();
$shell_output
=
array
();
if
(
$ipaddr
!=
null
)
$filter_cmd
=
" | /usr/bin/grep ' "
.
$ipaddr
.
" '"
;
if
(
$this
->
shell
->
exec
(
"/sbin/ipfw -aT list "
.
$filter_cmd
,
false
,
false
,
$shell_output
)
==
0
){
foreach
(
$shell_output
as
$line
)
{
if
(
strpos
(
$line
,
' count ip from'
)
!==
false
)
{
$parts
=
preg_split
(
'/\s+/'
,
$line
);
if
(
count
(
$parts
)
>
8
&&
$parts
[
7
]
!=
'any'
and
strlen
(
$parts
[
7
])
>
5
)
{
$result
[
$parts
[
7
]]
=
array
(
"last_accessed"
=>
(
int
)
$parts
[
3
],
"idle_time"
=>
time
()
-
(
int
)
$parts
[
3
],
"out_packets"
=>
(
int
)
$parts
[
1
],
"in_packets"
=>
(
int
)
$parts
[
2
]
);
}
}
}
}
return
$result
;
}
/**
* Constructor
*/
...
...
@@ -383,6 +413,8 @@ class CPClient {
}
/**
* unlock host for captiveportal use
*
* @param string $cpzonename
* @param string $clientip
* @param string $clientmac
...
...
@@ -541,6 +573,46 @@ class CPClient {
}
}
/**
* cleanup portal sessions
*/
function
portal_cleanup_sessions
(){
$acc_list
=
$this
->
list_accounting
();
foreach
(
$this
->
config
->
object
()
->
captiveportal
->
children
()
as
$cpzonename
=>
$zoneobj
){
$db
=
new
DB
(
$cpzonename
);
$clients
=
$db
->
listClients
(
array
(),
null
,
null
);
foreach
(
$clients
as
$client
){
$idle_time
=
0
;
if
(
array_key_exists
(
$client
->
ip
,
$acc_list
)
){
$idle_time
=
$acc_list
[
$client
->
ip
];
}
// if session timeout is reached, disconnect
if
(
$client
->
session_timeout
!=
""
){
if
(
((
time
()
-
$client
->
allow_time
)
/
60
)
>
$client
->
session_timeout
){
$this
->
disconnect
(
$cpzonename
,
$client
->
sessionid
);
continue
;
}
}
// disconnect session if idle timeout is reached
if
(
$client
->
idle_timeout
!=
""
&&
$idle_time
>
0
){
if
(
$idle_time
>
$client
->
idle_timeout
){
$this
->
disconnect
(
$cpzonename
,
$client
->
sessionid
);
continue
;
}
}
}
unset
(
$db
);
}
unset
(
$acc_list
);
}
}
src/www/diag_logs_filter.php
View file @
bb55bc37
...
...
@@ -296,6 +296,7 @@ include("head.inc");
$filterlog
=
conv_log_filter
(
$filter_logfile
,
$nentries
,
$nentries
+
100
,
$filterfieldsarray
);
else
$filterlog
=
conv_log_filter
(
$filter_logfile
,
$nentries
,
$nentries
+
100
,
$filtertext
,
$interfacefilter
);
?>
<tr>
<td
colspan=
"
<?=
$config
[
'syslog'
][
'filterdescriptions'
]
===
"1"
?
7
:
6
?>
"
class=
"listtopic"
>
...
...
src/www/firewall_rules_edit.php
View file @
bb55bc37
...
...
@@ -232,7 +232,6 @@ if (isset($id) && $a_filter[$id]) {
if
(
!
isset
(
$_GET
[
'dup'
])
||
!
is_numericint
(
$_GET
[
'dup'
]))
$pconfig
[
'associated-rule-id'
]
=
$a_filter
[
$id
][
'associated-rule-id'
];
$pconfig
[
'tracker'
]
=
$a_filter
[
$id
][
'tracker'
];
}
else
{
/* defaults */
...
...
@@ -608,7 +607,6 @@ if ($_POST) {
$filterent
=
array
();
$filterent
[
'id'
]
=
$_POST
[
'ruleid'
]
>
0
?
$_POST
[
'ruleid'
]
:
''
;
$filterent
[
'tracker'
]
=
empty
(
$_POST
[
'tracker'
])
?
(
int
)
microtime
(
true
)
:
$_POST
[
'tracker'
];
$filterent
[
'type'
]
=
$_POST
[
'type'
];
if
(
isset
(
$_POST
[
'interface'
]
))
...
...
@@ -1747,7 +1745,6 @@ include("head.inc");
<input
type=
"button"
class=
"btn btn-default"
value=
"
<?=
gettext
(
"Cancel"
);
?>
"
onclick=
"window.location.href='
<?=
$referer
;
?>
'"
/>
<?php
if
(
isset
(
$id
)
&&
$a_filter
[
$id
])
:
?>
<input
name=
"id"
type=
"hidden"
value=
"
<?=
htmlspecialchars
(
$id
);
?>
"
/>
<input
name=
"tracker"
type=
"hidden"
value=
"
<?=
htmlspecialchars
(
$pconfig
[
'tracker'
]);
?>
"
>
<?php
endif
;
?>
<input
name=
"after"
type=
"hidden"
value=
"
<?=
htmlspecialchars
(
$after
);
?>
"
/>
</td>
...
...
src/www/widgets/widgets/log.widget.php
View file @
bb55bc37
...
...
@@ -189,7 +189,7 @@ function format_log_line(row) {
?>
<tr
class=
"
<?=
$evenRowClass
?>
"
>
<td
class=
"listMRlr nowrap"
align=
"center"
>
<a
href=
"#"
onclick=
"javascript:getURL('diag_logs_filter.php?getrulenum=
<?php
echo
"
{
$filterent
[
'rulenum'
]
}
,
{
$filterent
[
'
tracker'
]
}
,
{
$filterent
[
'
act'
]
}
"
;
?>
', outputrule);"
>
<a
href=
"#"
onclick=
"javascript:getURL('diag_logs_filter.php?getrulenum=
<?php
echo
"
{
$filterent
[
'rulenum'
]
}
,
{
$filterent
[
'act'
]
}
"
;
?>
', outputrule);"
>
<img
border=
"0"
src=
"
<?php
echo
find_action_image
(
$filterent
[
'act'
]);
?>
"
width=
"11"
height=
"11"
alt=
"
<?php
echo
$filterent
[
'act'
];
?>
"
title=
"
<?php
echo
$filterent
[
'act'
];
?>
"
/>
</a>
</td>
...
...
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