File tree Expand file tree Collapse file tree 4 files changed +78
-4
lines changed Expand file tree Collapse file tree 4 files changed +78
-4
lines changed Original file line number Diff line number Diff line change @@ -19,8 +19,8 @@ def cleanup(self, output):
19
19
"""
20
20
# correct indentation
21
21
output = output .replace (' ' , '' )\
22
- .replace ('option ' , '\t option' )\
23
- .replace ('list ' , '\t list' )
22
+ .replace ('\n option ' , '\n \t option' )\
23
+ .replace ('\n list ' , '\n \t list' )
24
24
# convert True to 1 and False to 0
25
25
output = output .replace ('True' , '1' )\
26
26
.replace ('False' , '0' )
Original file line number Diff line number Diff line change 93
93
}
94
94
}
95
95
},
96
+ "macfilter_wireless" : {
97
+ "properties" : {
98
+ "macfilter" : {
99
+ "type" : "string" ,
100
+ "title" : "MAC Filter" ,
101
+ "enum" : [
102
+ "disable" ,
103
+ "allow" ,
104
+ "deny" ,
105
+ ],
106
+ "default" : "disable" ,
107
+ "propertyOrder" : 15 ,
108
+ },
109
+ "maclist" : {
110
+ "type" : "array" ,
111
+ "title" : "MAC List" ,
112
+ "propertyOrder" : 16 ,
113
+ "items" : {
114
+ "type" : "string" ,
115
+ "title" : "MAC address" ,
116
+ "maxLength" : 17 ,
117
+ "minLength" : 17 ,
118
+ }
119
+ }
120
+ }
121
+ },
96
122
"ap_wireless_settings" : {
97
- "allOf" : [{"$ref" : "#/definitions/wmm_wireless_property" }]
123
+ "allOf" : [
124
+ {"$ref" : "#/definitions/wmm_wireless_property" },
125
+ {"$ref" : "#/definitions/macfilter_wireless" },
126
+ ]
98
127
},
99
128
},
100
129
"properties" : {
Original file line number Diff line number Diff line change 14
14
config wifi-iface
15
15
{% for key, value in wifi_interface.items() %}
16
16
{% if value not in ['', None] %}
17
- option {{ key }} '{{ value }}'
17
+ {% if value is not string and value is iterable %}
18
+ {% for list_value in value %}
19
+ list {{ key }} '{{ list_value }}'
20
+ {% endfor %}
21
+ {% else %}
22
+ option {{ key }} '{{ value }}'
23
+ {% endif %}
18
24
{% endif %}
19
25
{% endfor %}
20
26
Original file line number Diff line number Diff line change @@ -958,5 +958,44 @@ def test_wifi_options_zero(self):
958
958
option network 'wlan0'
959
959
option ssid 'MyWifiAP'
960
960
option wmm '1'
961
+ """ )
962
+ self .assertEqual (o .render (), expected )
963
+
964
+ def test_wifi_macfilter (self ):
965
+ o = OpenWrt ({
966
+ "interfaces" : [
967
+ {
968
+ "name" : "wlan0" ,
969
+ "type" : "wireless" ,
970
+ "wireless" : {
971
+ "radio" : "radio0" ,
972
+ "mode" : "access_point" ,
973
+ "ssid" : "MyWifiAP" ,
974
+ "macfilter" : "deny" ,
975
+ "maclist" : [
976
+ "E8:94:F6:33:8C:1D" ,
977
+ "42:6c:8f:95:0f:00"
978
+ ]
979
+ }
980
+ }
981
+ ]
982
+ })
983
+ expected = self ._tabs ("""package network
984
+
985
+ config interface 'wlan0'
986
+ option ifname 'wlan0'
987
+ option proto 'none'
988
+
989
+ package wireless
990
+
991
+ config wifi-iface
992
+ option device 'radio0'
993
+ option ifname 'wlan0'
994
+ option macfilter 'deny'
995
+ list maclist 'E8:94:F6:33:8C:1D'
996
+ list maclist '42:6c:8f:95:0f:00'
997
+ option mode 'ap'
998
+ option network 'wlan0'
999
+ option ssid 'MyWifiAP'
961
1000
""" )
962
1001
self .assertEqual (o .render (), expected )
You can’t perform that action at this time.
0 commit comments