mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-08-27 20:36:29 -04:00
Add mass entry verification function (should be used after EntryRefresh); disable CGO across the board
This commit is contained in:
+25
-1
@@ -74,7 +74,7 @@ func EntryRefresh(oldRCWPassword, newRCWPassword []byte, removeOldDir bool) erro
|
||||
|
||||
// decrypt, optimize, and re-encrypt each entry
|
||||
for _, vanityPath := range entries {
|
||||
fmt.Println(vanityPath) // useful for CLI clients to track what entry caused a panic if one is corrupt
|
||||
fmt.Println(vanityPath) // TODO handle error in rcw (slice length?) so it can be captured and returned for use by non-CLI clients to track corrupt entries
|
||||
realPath := global.GetRealPath(vanityPath)
|
||||
encBytes, err := os.ReadFile(realPath)
|
||||
if err != nil {
|
||||
@@ -113,6 +113,30 @@ func EntryRefresh(oldRCWPassword, newRCWPassword []byte, removeOldDir bool) erro
|
||||
return nil
|
||||
}
|
||||
|
||||
// VerifyEntries decrypts all entries to memory and returns an error if
|
||||
// any failures are encountered. Failures likely indicate corrupt entries.
|
||||
func VerifyEntries(rcwPassword []byte) error {
|
||||
entries, _, err := synccommon.WalkEntryDir()
|
||||
if err != nil {
|
||||
return errors.New("unable to walk entry directory: " + err.Error())
|
||||
}
|
||||
for _, vanityPath := range entries {
|
||||
realPath := global.GetRealPath(vanityPath)
|
||||
encBytes, err := os.ReadFile(realPath)
|
||||
if err != nil {
|
||||
return errors.New("unable to open \"" + realPath + "\" for decryption: " + err.Error())
|
||||
}
|
||||
decBytes, err := wrappers.Decrypt(encBytes, rcwPassword)
|
||||
if err != nil {
|
||||
return errors.New("unable verify \"" + vanityPath + "\" (decryption failure): " + err.Error())
|
||||
}
|
||||
if len(decBytes) < 1 {
|
||||
return errors.New("unable verify \"" + vanityPath + "\" (contains 0/nil bytes)")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// clampTrailingWhitespace ensures the provided decSlice contains no trailing blank lines.
|
||||
// If decSlice contains a note, it strips trailing newlines, carriage returns, and tabs from
|
||||
// each line in the note. Additionally, it removes single trailing spaces and truncates
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
mkdir -p ./1output
|
||||
cd ..
|
||||
GOOS=linux CGO_ENABLED=0 GOAMD64=v2 go build -o ./packaging/1output/libmuttonserver-linux-x86_64_v2 -ldflags="-s -w" -trimpath ./libmuttonserver.go
|
||||
GOOS=linux GOARCH=arm64 GOARM64=v8.0 CGO_ENABLED=0 go build -o ./packaging/1output/libmuttonserver-linux-arm64v8.0 -ldflags="-s -w" -trimpath ./libmuttonserver.go
|
||||
GOOS=linux GOARCH=arm64 GOARM64=v8.7 CGO_ENABLED=0 go build -o ./packaging/1output/libmuttonserver-linux-arm64v8.7 -ldflags="-s -w" -trimpath ./libmuttonserver.go
|
||||
GOOS=linux CGO_ENABLED=0 GOARCH=arm64 GOARM64=v8.0 CGO_ENABLED=0 go build -o ./packaging/1output/libmuttonserver-linux-arm64v8.0 -ldflags="-s -w" -trimpath ./libmuttonserver.go
|
||||
GOOS=linux CGO_ENABLED=0 GOARCH=arm64 GOARM64=v8.7 CGO_ENABLED=0 go build -o ./packaging/1output/libmuttonserver-linux-arm64v8.7 -ldflags="-s -w" -trimpath ./libmuttonserver.go
|
||||
GOOS=windows CGO_ENABLED=0 GOAMD64=v2 go build -o ./packaging/1output/libmuttonserver-windows-x86_64_v2.exe -ldflags="-s -w" -trimpath ./libmuttonserver.go
|
||||
GOOS=windows GOARCH=arm64 GOARM64=v8.7 CGO_ENABLED=0 go build -o ./packaging/1output/libmuttonserver-windows-arm64v8.7.exe -ldflags="-s -w" -trimpath ./libmuttonserver.go
|
||||
GOOS=windows CGO_ENABLED=0 GOARCH=arm64 GOARM64=v8.7 CGO_ENABLED=0 go build -o ./packaging/1output/libmuttonserver-windows-arm64v8.7.exe -ldflags="-s -w" -trimpath ./libmuttonserver.go
|
||||
|
||||
Reference in New Issue
Block a user