Initial scaffold: project structure, .gitignore, go.mod

This commit is contained in:
Axel Meyer
2026-03-03 21:07:31 +01:00
commit 2256df9dd7
15 changed files with 892 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
package syncthing
import (
"encoding/xml"
"os"
"git.davoryn.de/calic/syncwarden/internal/config"
)
type syncthingConfig struct {
GUI struct {
APIKey string `xml:"apikey"`
} `xml:"gui"`
}
// DiscoverAPIKey reads the Syncthing config.xml and extracts the API key.
func DiscoverAPIKey() (string, error) {
data, err := os.ReadFile(config.SyncthingConfigPath())
if err != nil {
return "", err
}
var cfg syncthingConfig
if err := xml.Unmarshal(data, &cfg); err != nil {
return "", err
}
return cfg.GUI.APIKey, nil
}