|
35 | 35 | limit_peers = None |
36 | 36 |
|
37 | 37 | SEC_TYPES_SELF = (10, ) |
38 | | -SEC_TYPES_PEER = (1, 2, 3, 4) |
39 | | - |
| 38 | +SEC_TYPES_PEER = (1, 2, 4) |
| 39 | +SEC_TYPES_CCCD = (3, ) |
40 | 40 |
|
41 | 41 | # Must call this before stack startup. |
42 | 42 | def load_secrets(path=None): |
@@ -124,7 +124,7 @@ def _log_peers(heading=""): |
124 | 124 | if core.log_level <= 2: |
125 | 125 | return |
126 | 126 | log_info("secrets:", heading) |
127 | | - for sec_type in SEC_TYPES_PEER: |
| 127 | + for sec_type in SEC_TYPES_PEER + SEC_TYPES_CCCD: |
128 | 128 | log_info("-", sec_type) |
129 | 129 |
|
130 | 130 | if sec_type not in _secrets: |
@@ -171,8 +171,12 @@ def _security_irq(event, data): |
171 | 171 | _secrets[sec_type] = [] |
172 | 172 | secrets = _secrets[sec_type] |
173 | 173 |
|
174 | | - # Delete existing secrets matching the type and key. |
175 | | - removed = _remove_entry(sec_type, key) |
| 174 | + # Delete existing secrets matching the type and key as required. |
| 175 | + # There should only every be one SEC_TYPES_PEER per addr, but |
| 176 | + # multiple entries are allowed for SEC_TYPES_CCCD |
| 177 | + removed = False |
| 178 | + if is_deleting or sec_type not in SEC_TYPES_CCCD: |
| 179 | + removed = _remove_entry(sec_type, key) |
176 | 180 |
|
177 | 181 | if is_deleting and not removed: |
178 | 182 | # Delete mode, but no entries were deleted |
@@ -216,6 +220,9 @@ def _security_irq(event, data): |
216 | 220 |
|
217 | 221 | for k, v in secrets: |
218 | 222 | if k == key: |
| 223 | + if index: |
| 224 | + index -= 1 |
| 225 | + continue |
219 | 226 | return v |
220 | 227 | return None |
221 | 228 |
|
|
0 commit comments