Commit ec4458d1 authored by Ad Schellevis's avatar Ad Schellevis

(traffic shaper) add flush all and reload action, closes...

(traffic shaper) add flush all and reload action, closes https://github.com/opnsense/core/issues/1297
parent 20df3371
#!/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
<?php <?php
/** /**
* Copyright (C) 2015 Deciso B.V. * Copyright (C) 2015-2016 Deciso B.V.
* *
* All rights reserved. * All rights reserved.
* *
...@@ -61,4 +61,22 @@ class ServiceController extends ApiControllerBase ...@@ -61,4 +61,22 @@ class ServiceController extends ApiControllerBase
return array("status" => "failed"); 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");
}
}
} }
{# {#
OPNsense® is Copyright © 2014 – 2015 by Deciso B.V. OPNsense® is Copyright © 2014 – 2016 by Deciso B.V.
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, Redistribution and use in source and binary forms, with or without modification,
...@@ -93,6 +93,32 @@ POSSIBILITY OF SUCH DAMAGE. ...@@ -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 // update history on tab state and implement navigation
if (window.location.hash != "") { if (window.location.hash != "") {
$('a[href="' + window.location.hash + '"]').click() $('a[href="' + window.location.hash + '"]').click()
...@@ -202,6 +228,7 @@ POSSIBILITY OF SUCH DAMAGE. ...@@ -202,6 +228,7 @@ POSSIBILITY OF SUCH DAMAGE.
<div class="col-md-12"> <div class="col-md-12">
<hr/> <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" 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/> <br/><br/>
</div> </div>
</div> </div>
......
...@@ -3,3 +3,9 @@ command:/etc/rc.d/ipfw onestart; /usr/local/etc/rc.ipfw.postload ...@@ -3,3 +3,9 @@ command:/etc/rc.d/ipfw onestart; /usr/local/etc/rc.ipfw.postload
parameters: parameters:
type:script type:script
message:restarting ipfw message:restarting ipfw
[flush]
command:/usr/local/etc/rc.ipfw.flush_all
parameters:
type:script
message:flush all ipfw rules
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment