mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-05-19 18:58:03 +02:00
e48f35cfd3
* refactor: Refactor logging to use structured slog package. - Remove `gookit` dependencies from `go.sum` - Improve error logging in multiple packages by replacing `log` with `log/slog` - Update dependencies in `go.mod` - Add new `logger` package with test cases - Refactor logging statements in multiple packages to use `slog` instead of `log` - Change logging format and level in multiple packages for better structured logging * refactor: Refactor logger package and add handler interface - Refactor logger package - Rename `defaultHandler` to `DefaultLogger` - Move `ReplaceAttr` function to `Logger` struct - Implement `LogHandler` struct with `slog.Handler` interface - Add new `Logger` methods for configuration - Add `SetMaxLevel`, `SetJSONHandler`, `SetTextHandler`, `SetOutput`, `SetVerbose`, `SetReplaceAttrFunc` - Add verbose flag to `cmd/hack-browser-data/main.go` to increase logging * refactor: Refactor logger package to use simplified handler initialization. - Refactor logger package to use Default instead of DefaultLogger - Update `NewHandler` method to correctly reference `Default` logger and simplify handler initialization - Update tests for logger to reflect changes in Default usage - Rename `DefaultLogger` to `Default` and update comments to better reflect its purpose - Update function calls in hack-browser-data main.go to reflect logger package updates * refactor: Refactor logging in Chromium implementation Refactor logging and simplify decryption in chromium files - Replace logger package import with shared slog package - Change logging messages to use slog instead of logger - Simplify decryption process by removing first 5 characters of encrypted key - Refactor error logging in linux file to use shared slog package - Replace string concatenation with formatted string in linux error message
59 lines
1.2 KiB
Go
59 lines
1.2 KiB
Go
package typeutil
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// Keys returns a slice of the keys of the map. based with go 1.18 generics
|
|
func Keys[K comparable, V any](m map[K]V) []K {
|
|
r := make([]K, 0, len(m))
|
|
for k := range m {
|
|
r = append(r, k)
|
|
}
|
|
return r
|
|
}
|
|
|
|
// Signed is a constraint that permits any signed integer type.
|
|
// If future releases of Go add new predeclared signed integer types,
|
|
// this constraint will be modified to include them.
|
|
type Signed interface {
|
|
~int | ~int8 | ~int16 | ~int32 | ~int64
|
|
}
|
|
|
|
func IntToBool[T Signed](a T) bool {
|
|
switch a {
|
|
case 0, -1:
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
func Reverse[T any](s []T) []T {
|
|
h := make([]T, len(s))
|
|
for i := 0; i < len(s); i++ {
|
|
h[i] = s[len(s)-i-1]
|
|
}
|
|
return h
|
|
}
|
|
|
|
func TimeStamp(stamp int64) time.Time {
|
|
s := time.Unix(stamp, 0)
|
|
if s.Local().Year() > 9999 {
|
|
return time.Date(9999, 12, 13, 23, 59, 59, 0, time.Local)
|
|
}
|
|
return s
|
|
}
|
|
|
|
func TimeEpoch(epoch int64) time.Time {
|
|
maxTime := int64(99633311740000000)
|
|
if epoch > maxTime {
|
|
return time.Date(2049, 1, 1, 1, 1, 1, 1, time.Local)
|
|
}
|
|
t := time.Date(1601, 1, 1, 0, 0, 0, 0, time.Local)
|
|
d := time.Duration(epoch)
|
|
for i := 0; i < 1000; i++ {
|
|
t = t.Add(d)
|
|
}
|
|
return t
|
|
}
|