MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / List

Method List

internal/store/objectstore.go:238–268  ·  view source on GitHub ↗

List enumerates auth JSON files from the mirrored workspace.

(_ context.Context)

Source from the content-addressed store, hash-verified

236
237// List enumerates auth JSON files from the mirrored workspace.
238func (s *ObjectTokenStore) List(_ context.Context) ([]*cliproxyauth.Auth, error) {
239 dir := strings.TrimSpace(s.AuthDir())
240 if dir == "" {
241 return nil, fmt.Errorf("object store: auth directory not configured")
242 }
243 entries := make([]*cliproxyauth.Auth, 0, 32)
244 err := filepath.WalkDir(dir, func(path string, d fs.DirEntry, walkErr error) error {
245 if walkErr != nil {
246 return walkErr
247 }
248 if d.IsDir() {
249 return nil
250 }
251 if !strings.HasSuffix(strings.ToLower(d.Name()), ".json") {
252 return nil
253 }
254 auth, err := s.readAuthFile(path, dir)
255 if err != nil {
256 log.WithError(err).Warnf("object store: skip auth %s", path)
257 return nil
258 }
259 if auth != nil {
260 entries = append(entries, auth)
261 }
262 return nil
263 })
264 if err != nil {
265 return nil, fmt.Errorf("object store: walk auth directory: %w", err)
266 }
267 return entries, nil
268}
269
270// Delete removes an auth file locally and remotely.
271func (s *ObjectTokenStore) Delete(ctx context.Context, id string) error {

Callers

nothing calls this directly

Calls 3

AuthDirMethod · 0.95
readAuthFileMethod · 0.95
NameMethod · 0.65

Tested by

no test coverage detected