mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-17 01:54:49 +00:00
(traffic shaper) add flush all and reload action, closes https://github.com/opnsense/core/issues/1297
This commit is contained in:
parent
20df3371e4
commit
ec4458d181
31
src/etc/rc.ipfw.flush_all
Executable file
31
src/etc/rc.ipfw.flush_all
Executable file
@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
# 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.
|
||||
|
||||
# flush ipfw rules, pipes, queues
|
||||
|
||||
/sbin/ipfw -f flush
|
||||
/sbin/ipfw -f pipe flush
|
||||
/sbin/ipfw -f queue flush
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2015 Deciso B.V.
|
||||
* Copyright (C) 2015-2016 Deciso B.V.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -61,4 +61,22 @@ class ServiceController extends ApiControllerBase
|
||||
return array("status" => "failed");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* flush all ipfw rules
|
||||
*/
|
||||
public function flushreloadAction()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
// close session for long running action
|
||||
$this->sessionClose();
|
||||
|
||||
$backend = new Backend();
|
||||
$status = trim($backend->configdRun("ipfw flush"));
|
||||
$status = trim($backend->configdRun("ipfw reload"));
|
||||
return array("status" => $status);
|
||||
} else {
|
||||
return array("status" => "failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{#
|
||||
|
||||
OPNsense® is Copyright © 2014 – 2015 by Deciso B.V.
|
||||
OPNsense® is Copyright © 2014 – 2016 by Deciso B.V.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
@ -93,6 +93,32 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
});
|
||||
});
|
||||
|
||||
$("#flushAct").click(function(){
|
||||
// Ask user if it's ok to flush all of ipfw
|
||||
BootstrapDialog.show({
|
||||
type:BootstrapDialog.TYPE_WARNING,
|
||||
title: 'Flush',
|
||||
message: "{{ lang._('Are you sure you want to flush and reload all? this might have impact on other services using the same technology underneath (such as Captive portal)') }}",
|
||||
buttons: [{
|
||||
label: 'Yes',
|
||||
action: function(dialogRef){
|
||||
dialogRef.close();
|
||||
$("#flushAct_progress").addClass("fa fa-spinner fa-pulse");
|
||||
ajaxCall(url="/api/trafficshaper/service/flushreload", sendData={}, callback=function(data,status) {
|
||||
// when done, disable progress animation.
|
||||
$("#flushAct_progress").removeClass("fa fa-spinner fa-pulse");
|
||||
});
|
||||
|
||||
}
|
||||
},{
|
||||
label: 'No',
|
||||
action: function(dialogRef){
|
||||
dialogRef.close();
|
||||
}
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
||||
// update history on tab state and implement navigation
|
||||
if (window.location.hash != "") {
|
||||
$('a[href="' + window.location.hash + '"]').click()
|
||||
@ -202,6 +228,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
<div class="col-md-12">
|
||||
<hr/>
|
||||
<button class="btn btn-primary" id="reconfigureAct" type="button"><b>{{ lang._('Apply') }}</b><i id="reconfigureAct_progress" class=""></i></button>
|
||||
<button class="btn btn-primary pull-right" id="flushAct" type="button"><b>{{ lang._('Reset') }}</b><i id="flushAct_progress" class=""></i></button>
|
||||
<br/><br/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -3,3 +3,9 @@ command:/etc/rc.d/ipfw onestart; /usr/local/etc/rc.ipfw.postload
|
||||
parameters:
|
||||
type:script
|
||||
message:restarting ipfw
|
||||
|
||||
[flush]
|
||||
command:/usr/local/etc/rc.ipfw.flush_all
|
||||
parameters:
|
||||
type:script
|
||||
message:flush all ipfw rules
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user