Skip to content
Permalink
Browse files
[OpenWrt] Added macfilter to wireless access points
  • Loading branch information
nemesisdesign committed Mar 22, 2016
1 parent a226e90 commit e008ef6511cfcba43b96b2eb60afabac2d49b565
@@ -19,8 +19,8 @@ def cleanup(self, output):
"""
# correct indentation
output = output.replace(' ', '')\
.replace('option', '\toption')\
.replace('list', '\tlist')
.replace('\noption', '\n\toption')\
.replace('\nlist', '\n\tlist')
# convert True to 1 and False to 0
output = output.replace('True', '1')\
.replace('False', '0')
@@ -93,8 +93,37 @@
}
}
},
"macfilter_wireless": {
"properties": {
"macfilter": {
"type": "string",
"title": "MAC Filter",
"enum": [
"disable",
"allow",
"deny",
],
"default": "disable",
"propertyOrder": 15,
},
"maclist": {
"type": "array",
"title": "MAC List",
"propertyOrder": 16,
"items": {
"type": "string",
"title": "MAC address",
"maxLength": 17,
"minLength": 17,
}
}
}
},
"ap_wireless_settings": {
"allOf": [{"$ref": "#/definitions/wmm_wireless_property"}]
"allOf": [
{"$ref": "#/definitions/wmm_wireless_property"},
{"$ref": "#/definitions/macfilter_wireless"},
]
},
},
"properties": {
@@ -14,7 +14,13 @@
config wifi-iface
{% for key, value in wifi_interface.items() %}
{% if value not in ['', None] %}
option {{ key }} '{{ value }}'
{% if value is not string and value is iterable %}
{% for list_value in value %}
list {{ key }} '{{ list_value }}'
{% endfor %}
{% else %}
option {{ key }} '{{ value }}'
{% endif %}
{% endif %}
{% endfor %}

@@ -958,5 +958,44 @@ def test_wifi_options_zero(self):
option network 'wlan0'
option ssid 'MyWifiAP'
option wmm '1'
""")
self.assertEqual(o.render(), expected)

def test_wifi_macfilter(self):
o = OpenWrt({
"interfaces": [
{
"name": "wlan0",
"type": "wireless",
"wireless": {
"radio": "radio0",
"mode": "access_point",
"ssid": "MyWifiAP",
"macfilter": "deny",
"maclist": [
"E8:94:F6:33:8C:1D",
"42:6c:8f:95:0f:00"
]
}
}
]
})
expected = self._tabs("""package network
config interface 'wlan0'
option ifname 'wlan0'
option proto 'none'
package wireless
config wifi-iface
option device 'radio0'
option ifname 'wlan0'
option macfilter 'deny'
list maclist 'E8:94:F6:33:8C:1D'
list maclist '42:6c:8f:95:0f:00'
option mode 'ap'
option network 'wlan0'
option ssid 'MyWifiAP'
""")
self.assertEqual(o.render(), expected)

0 comments on commit e008ef6

Please sign in to comment.