Skip to content

Commit

Permalink
shaper: improve previous, Tinc plugin already uses string sort
Browse files Browse the repository at this point in the history
  • Loading branch information
fichtner committed Jan 21, 2017
1 parent 98333c1 commit 56f7c3f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/opnsense/mvc/app/views/OPNsense/TrafficShaper/index.volt
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ POSSIBILITY OF SUCH DAMAGE.
</div>
<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>
<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>
Expand Down
7 changes: 5 additions & 2 deletions src/opnsense/service/modules/addons/template_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def exists(self, tag):
else:
return False

def toList(self, tag, sortBy=None):
def toList(self, tag, sortBy=None, sortAs=None):
""" if an item should be a list of items (repeating tag), use this method to make sure that we always return
a list. The configuration doesn't know if a non repeating item is supposed to be a list of items, this makes
it explicit.
Expand All @@ -84,7 +84,10 @@ def toList(self, tag, sortBy=None):
return result
else:
# resort list by tag
return sorted(result, key=lambda d: int(d[sortBy]))
if sortAs is 'int':
return sorted(result, key=lambda d: int(d[sortBy]))
else:
return sorted(result, key=lambda d: d[sortBy])

def getUUIDtag(self, uuid):
""" retrieve tag name of registered uuid, returns __not_found__ if none available
Expand Down
2 changes: 1 addition & 1 deletion src/opnsense/service/templates/OPNsense/IPFW/ipfw.conf
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ add 30000 set 0 count ip from any to any
add 60000 return via any

{% if helpers.exists('OPNsense.TrafficShaper.rules.rule') %}
{% for rule in helpers.toList('OPNsense.TrafficShaper.rules.rule', 'sequence') %}
{% for rule in helpers.toList('OPNsense.TrafficShaper.rules.rule', 'sequence', 'int') %}
{% if helpers.getUUIDtag(rule.target) in ['pipe','queue'] %}
{% if physical_interface(rule.interface) %}
{% if helpers.getUUID(rule.target).enabled|default('0') == '1' %}
Expand Down

0 comments on commit 56f7c3f

Please sign in to comment.