Skip to content

Commit 79db3af

Browse files
committed
fix: Transport data in lc-admin may not update properly
1 parent a8e80cd commit 79db3af

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Log Carver
99
- Updated CEL Go library to 0.9.0
1010
- Implemented CEL Go string extensions and base64 encoder
1111
- Implemented JSON encoder (json_encode and json_decode CEL Go functions)
12+
- Fixed lc-admin status for transports not updating in some cases
1213

1314
## 2.8.1
1415

lc-lib/admin/api/array.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,18 @@ type apiArrayEntry struct {
3030
entry Navigatable
3131
}
3232

33+
// MarshalJSON forwards to the inner array entry
34+
func (a *apiArrayEntry) MarshalJSON() ([]byte, error) {
35+
return json.Marshal(a.entry)
36+
}
37+
3338
// Array represents an array of entries in the API accessible through a
3439
// primary key
3540
// Thread safe
3641
type Array struct {
3742
mutex sync.RWMutex
3843
entryMap map[string]*apiArrayEntry
39-
entries []Navigatable
44+
entries []*apiArrayEntry
4045
}
4146

4247
// AddEntry a new array entry
@@ -59,7 +64,7 @@ func (a *Array) AddEntry(key string, entry Navigatable) {
5964

6065
a.entryMap[key] = arrayEntry
6166

62-
a.entries = append(a.entries, entry)
67+
a.entries = append(a.entries, arrayEntry)
6368
}
6469

6570
// RemoveEntry removes an array entry
@@ -79,6 +84,7 @@ func (a *Array) RemoveEntry(key string) {
7984
delete(a.entryMap, key)
8085
for i := entry.row; i+1 < len(a.entries); i++ {
8186
a.entries[i] = a.entries[i+1]
87+
a.entries[i].row--
8288
}
8389
a.entries = a.entries[:len(a.entries)-1]
8490
}
@@ -106,7 +112,7 @@ func (a *Array) Get(path string) (Navigatable, error) {
106112
return nil, nil
107113
}
108114

109-
return a.entries[entryNum], nil
115+
return a.entries[entryNum].entry, nil
110116
}
111117

112118
// Call an API
@@ -173,7 +179,7 @@ func (a *Array) Update() error {
173179
defer a.mutex.RUnlock()
174180

175181
for _, entry := range a.entries {
176-
if err := entry.Update(); err != nil {
182+
if err := entry.entry.Update(); err != nil {
177183
return err
178184
}
179185
}

0 commit comments

Comments
 (0)