-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (35 loc) · 889 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"bufio"
"fmt"
"os"
"strings"
"github.com/rclone/rclone/fs/config/obscure"
)
func main() {
configPath := os.ExpandEnv("$HOME/.config/rclone/rclone.conf")
file, err := os.Open(configPath)
if err != nil {
fmt.Printf("Error opening rclone.conf: %v\n", err)
return
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
line := scanner.Text()
if strings.HasPrefix(line, "password = ") || strings.HasPrefix(line, "secret = ") {
parts := strings.SplitN(line, "=", 2)
if len(parts) == 2 {
key := strings.TrimSpace(parts[0])
obscuredValue := strings.TrimSpace(parts[1])
revealedValue := obscure.MustReveal(obscuredValue)
fmt.Printf("%s = %s\n", key, revealedValue)
}
} else {
fmt.Println(line)
}
}
if err := scanner.Err(); err != nil {
fmt.Printf("Error reading rclone.conf: %v\n", err)
}
}