2024-11-02 21:29:32 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"path"
|
|
|
|
|
|
|
|
"git.grassecon.net/urdt/ussd/config"
|
|
|
|
"git.grassecon.net/urdt/ussd/initializers"
|
|
|
|
"git.grassecon.net/urdt/ussd/internal/storage"
|
2024-12-08 23:48:39 +01:00
|
|
|
"git.grassecon.net/urdt/ussd/debug"
|
2024-12-30 20:35:45 +01:00
|
|
|
"git.defalsify.org/vise.git/db"
|
2024-11-02 21:29:32 +01:00
|
|
|
"git.defalsify.org/vise.git/logging"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
logg = logging.NewVanilla()
|
|
|
|
scriptDir = path.Join("services", "registration")
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
initializers.LoadEnvVariables()
|
|
|
|
}
|
|
|
|
|
2024-12-01 18:32:06 +01:00
|
|
|
|
2024-11-02 21:29:32 +01:00
|
|
|
func main() {
|
|
|
|
config.LoadConfig()
|
|
|
|
|
2025-01-04 10:37:12 +01:00
|
|
|
var connStr string
|
2024-11-02 21:29:32 +01:00
|
|
|
var sessionId string
|
|
|
|
var database string
|
|
|
|
var engineDebug bool
|
2025-01-04 10:37:12 +01:00
|
|
|
var err error
|
2024-12-08 23:48:39 +01:00
|
|
|
|
2024-11-02 21:29:32 +01:00
|
|
|
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
|
2025-01-04 10:37:12 +01:00
|
|
|
flag.StringVar(&connStr, "c", ".state", "connection string")
|
2024-11-02 21:29:32 +01:00
|
|
|
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
|
|
|
flag.Parse()
|
|
|
|
|
2025-01-04 21:36:18 +01:00
|
|
|
if connStr != "" {
|
|
|
|
connStr = config.DbConn
|
|
|
|
}
|
|
|
|
connData, err := storage.ToConnData(config.DbConn)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintf(os.Stderr, "connstr err: %v", err)
|
|
|
|
os.Exit(1)
|
2025-01-04 10:37:12 +01:00
|
|
|
}
|
|
|
|
|
2024-11-02 21:29:32 +01:00
|
|
|
ctx := context.Background()
|
2024-12-08 23:48:39 +01:00
|
|
|
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
2024-11-02 21:29:32 +01:00
|
|
|
ctx = context.WithValue(ctx, "Database", database)
|
|
|
|
|
|
|
|
resourceDir := scriptDir
|
2025-01-04 22:02:08 +01:00
|
|
|
menuStorageService := storage.NewMenuStorageService(connData, resourceDir)
|
2024-11-02 21:29:32 +01:00
|
|
|
|
|
|
|
store, err := menuStorageService.GetUserdataDb(ctx)
|
|
|
|
if err != nil {
|
2024-12-30 20:35:45 +01:00
|
|
|
fmt.Fprintf(os.Stderr, "get userdata db: %v\n", err.Error())
|
2024-11-02 21:29:32 +01:00
|
|
|
os.Exit(1)
|
|
|
|
}
|
2024-12-30 20:35:45 +01:00
|
|
|
store.SetPrefix(db.DATATYPE_USERDATA)
|
2024-11-02 21:29:32 +01:00
|
|
|
|
|
|
|
d, err := store.Dump(ctx, []byte(sessionId))
|
|
|
|
if err != nil {
|
2024-12-30 20:35:45 +01:00
|
|
|
fmt.Fprintf(os.Stderr, "store dump fail: %v\n", err.Error())
|
2024-11-02 21:29:32 +01:00
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
for true {
|
|
|
|
k, v := d.Next(ctx)
|
|
|
|
if k == nil {
|
|
|
|
break
|
|
|
|
}
|
2024-12-08 23:48:39 +01:00
|
|
|
o, err := debug.FromKey(k)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintf(os.Stderr, err.Error())
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2024-12-31 09:41:04 +01:00
|
|
|
fmt.Printf("%vValue: %v\n\n", o, string(v))
|
2024-11-02 21:29:32 +01:00
|
|
|
}
|
2024-12-02 15:36:33 +01:00
|
|
|
|
|
|
|
err = store.Close()
|
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintf(os.Stderr, err.Error())
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2024-11-02 21:29:32 +01:00
|
|
|
}
|