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

Function ResolveAuthDir

internal/util/util.go:77–95  ·  view source on GitHub ↗

ResolveAuthDir normalizes the auth directory path for consistent reuse throughout the app. It expands a leading tilde (~) to the user's home directory and returns a cleaned path. If authDir is empty, it defaults to ~/.cli-proxy-api.

(authDir string)

Source from the content-addressed store, hash-verified

75// It expands a leading tilde (~) to the user's home directory and returns a cleaned path.
76// If authDir is empty, it defaults to ~/.cli-proxy-api.
77func ResolveAuthDir(authDir string) (string, error) {
78 if authDir == "" {
79 authDir = config.DefaultAuthDir
80 }
81 if strings.HasPrefix(authDir, "~") {
82 home, err := os.UserHomeDir()
83 if err != nil {
84 return "", fmt.Errorf("resolve auth dir: %w", err)
85 }
86 remainder := strings.TrimPrefix(authDir, "~")
87 remainder = strings.TrimLeft(remainder, "/\\")
88 if remainder == "" {
89 return filepath.Clean(home), nil
90 }
91 normalized := strings.ReplaceAll(remainder, "\\", "/")
92 return filepath.Clean(filepath.Join(home, filepath.FromSlash(normalized))), nil
93 }
94 return filepath.Clean(authDir), nil
95}
96
97// CountAuthFiles returns the number of auth records available through the provided Store.
98// For filesystem-backed stores, this reflects the number of JSON auth files under the configured directory.

Callers 10

ResolveLogDirectoryFunction · 0.92
DoVertexImportFunction · 0.92
reloadClientsMethod · 0.92
loadFileClientsMethod · 0.92
reloadConfigMethod · 0.92
authIDForPathMethod · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected