Compare commits
No commits in common. "908a52cda626f16820d9da83695e6d3d941ca4bb" and "ec6b078de3cbbf601bee0a4c04c110455e92a324" have entirely different histories.
908a52cda6
...
ec6b078de3
10
args/lang.go
10
args/lang.go
@ -10,7 +10,7 @@ type LangVar struct {
|
||||
v []lang.Language
|
||||
}
|
||||
|
||||
func (lv *LangVar) Set(s string) error {
|
||||
func(lv *LangVar) Set(s string) error {
|
||||
v, err := lang.LanguageFromCode(s)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -19,14 +19,16 @@ func (lv *LangVar) Set(s string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (lv *LangVar) String() string {
|
||||
func(lv *LangVar) String() string {
|
||||
var s []string
|
||||
for _, v := range lv.v {
|
||||
for _, v := range(lv.v) {
|
||||
s = append(s, v.Code)
|
||||
}
|
||||
return strings.Join(s, ",")
|
||||
}
|
||||
|
||||
func (lv *LangVar) Langs() []lang.Language {
|
||||
func(lv *LangVar) Langs() []lang.Language {
|
||||
return lv.v
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,18 +12,18 @@ import (
|
||||
"syscall"
|
||||
|
||||
"git.defalsify.org/vise.git/engine"
|
||||
"git.defalsify.org/vise.git/lang"
|
||||
"git.defalsify.org/vise.git/logging"
|
||||
"git.defalsify.org/vise.git/lang"
|
||||
"git.defalsify.org/vise.git/resource"
|
||||
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/request"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/request"
|
||||
|
||||
at "git.grassecon.net/grassrootseconomics/visedriver-africastalking/africastalking"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
|
||||
at "git.grassecon.net/grassrootseconomics/visedriver-africastalking/africastalking"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -36,7 +36,8 @@ var (
|
||||
func main() {
|
||||
config.LoadConfig()
|
||||
|
||||
override := config.NewOverride()
|
||||
var connStr string
|
||||
var resourceDir string
|
||||
var size uint
|
||||
var engineDebug bool
|
||||
var host string
|
||||
@ -44,14 +45,11 @@ func main() {
|
||||
var err error
|
||||
var gettextDir string
|
||||
var langs args.LangVar
|
||||
var resourceDir string
|
||||
|
||||
|
||||
flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir")
|
||||
flag.StringVar(&connStr, "c", "", "connection string")
|
||||
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
||||
flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
|
||||
flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string")
|
||||
flag.StringVar(override.ResourceConn, "resource", "?", "resource data directory")
|
||||
flag.StringVar(&resourceDir, "resource-dir", "", "resource data directory. If set, overrides --resource to create a non-binary fsdb for the given path.")
|
||||
flag.StringVar(override.StateConn, "state", "?", "state store connection string")
|
||||
flag.UintVar(&size, "s", 160, "max size of output")
|
||||
flag.StringVar(&host, "h", config.Host(), "http host")
|
||||
flag.UintVar(&port, "p", config.Port(), "http port")
|
||||
@ -59,18 +57,16 @@ func main() {
|
||||
flag.Var(&langs, "language", "add symbol resolution for language")
|
||||
flag.Parse()
|
||||
|
||||
if resourceDir != "" {
|
||||
*override.ResourceConn = resourceDir
|
||||
override.ResourceConnMode = storage.DBMODE_TEXT
|
||||
if connStr == "" {
|
||||
connStr = config.DbConn()
|
||||
}
|
||||
config.Apply(override)
|
||||
conns, err := config.GetConns()
|
||||
connData, err := storage.ToConnData(connStr)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "connstr err: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
logg.Infof("start command", "build", build, "conn", conns, "outputsize", size)
|
||||
logg.Infof("start command", "build", build, "conn", connData, "resourcedir", resourceDir, "outputsize", size)
|
||||
|
||||
ctx := context.Background()
|
||||
ln, err := lang.LanguageFromCode(config.Language())
|
||||
@ -93,7 +89,7 @@ func main() {
|
||||
cfg.EngineDebug = true
|
||||
}
|
||||
|
||||
menuStorageService := storage.NewMenuStorageService(conns)
|
||||
menuStorageService := storage.NewMenuStorageService(connData, resourceDir)
|
||||
rs, err := menuStorageService.GetResource(ctx)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "menustorageservice: %v\n", err)
|
||||
@ -105,6 +101,7 @@ func main() {
|
||||
fmt.Fprintf(os.Stderr, "userdatadb: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
defer userdataStore.Close()
|
||||
|
||||
dbResource, ok := rs.(*resource.DbResource)
|
||||
if !ok {
|
||||
@ -123,8 +120,8 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
accountService := services.New(ctx, menuStorageService)
|
||||
|
||||
accountService := services.New(ctx, menuStorageService, connData)
|
||||
|
||||
hl, err := lhs.GetHandler(accountService)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "httpaccountservice: %v\n", err)
|
||||
@ -136,6 +133,7 @@ func main() {
|
||||
fmt.Fprintf(os.Stderr, "getstatestore: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
defer stateStore.Close()
|
||||
|
||||
rp := &at.ATRequestParser{}
|
||||
bsh := request.NewBaseRequestHandler(cfg, rs, stateStore, userdataStore, rp, hl)
|
||||
@ -148,10 +146,7 @@ func main() {
|
||||
Addr: fmt.Sprintf("%s:%s", host, strconv.Itoa(int(port))),
|
||||
Handler: mux,
|
||||
}
|
||||
shutdownFunc := func() {
|
||||
sh.Shutdown(ctx)
|
||||
}
|
||||
s.RegisterOnShutdown(shutdownFunc)
|
||||
s.RegisterOnShutdown(sh.Shutdown)
|
||||
|
||||
cint := make(chan os.Signal)
|
||||
cterm := make(chan os.Signal)
|
||||
|
@ -14,12 +14,12 @@ import (
|
||||
"git.defalsify.org/vise.git/logging"
|
||||
"git.defalsify.org/vise.git/resource"
|
||||
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/request"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/request"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -44,8 +44,9 @@ func (p *asyncRequestParser) GetInput(r any) ([]byte, error) {
|
||||
func main() {
|
||||
config.LoadConfig()
|
||||
|
||||
override := config.NewOverride()
|
||||
var connStr string
|
||||
var sessionId string
|
||||
var resourceDir string
|
||||
var size uint
|
||||
var engineDebug bool
|
||||
var host string
|
||||
@ -53,15 +54,10 @@ func main() {
|
||||
var err error
|
||||
var gettextDir string
|
||||
var langs args.LangVar
|
||||
var resourceDir string
|
||||
|
||||
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
|
||||
flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
|
||||
flag.StringVar(override.ResourceConn, "resource", "?", "resource data directory")
|
||||
flag.StringVar(&resourceDir, "resource-dir", "", "resource data directory. If set, overrides --resource to create a non-binary fsdb for the given path.")
|
||||
flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string")
|
||||
flag.StringVar(override.StateConn, "state", "?", "state store connection string")
|
||||
|
||||
flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir")
|
||||
flag.StringVar(&connStr, "c", "", "connection string")
|
||||
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
||||
flag.UintVar(&size, "s", 160, "max size of output")
|
||||
flag.StringVar(&host, "h", config.Host(), "http host")
|
||||
@ -70,18 +66,16 @@ func main() {
|
||||
flag.Var(&langs, "language", "add symbol resolution for language")
|
||||
flag.Parse()
|
||||
|
||||
if resourceDir != "" {
|
||||
*override.ResourceConn = resourceDir
|
||||
override.ResourceConnMode = storage.DBMODE_TEXT
|
||||
if connStr == "" {
|
||||
connStr = config.DbConn()
|
||||
}
|
||||
config.Apply(override)
|
||||
conns, err := config.GetConns()
|
||||
connData, err := storage.ToConnData(connStr)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "connstr err: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
logg.Infof("start command", "conn", conns, "outputsize", size, "sessionId", sessionId)
|
||||
logg.Infof("start command", "conn", connData, "resourcedir", resourceDir, "outputsize", size, "sessionId", sessionId)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@ -105,7 +99,7 @@ func main() {
|
||||
cfg.EngineDebug = true
|
||||
}
|
||||
|
||||
menuStorageService := storage.NewMenuStorageService(conns)
|
||||
menuStorageService := storage.NewMenuStorageService(connData, resourceDir)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, err.Error())
|
||||
os.Exit(1)
|
||||
@ -122,7 +116,7 @@ func main() {
|
||||
fmt.Fprintf(os.Stderr, err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
//defer userdataStore.Close(ctx)
|
||||
defer userdataStore.Close()
|
||||
|
||||
dbResource, ok := rs.(*resource.DbResource)
|
||||
if !ok {
|
||||
@ -132,7 +126,7 @@ func main() {
|
||||
lhs, err := handlers.NewLocalHandlerService(ctx, pfp, true, dbResource, cfg, rs)
|
||||
lhs.SetDataStore(&userdataStore)
|
||||
|
||||
accountService := services.New(ctx, menuStorageService)
|
||||
accountService := services.New(ctx, menuStorageService, connData)
|
||||
|
||||
hl, err := lhs.GetHandler(accountService)
|
||||
if err != nil {
|
||||
@ -145,7 +139,7 @@ func main() {
|
||||
fmt.Fprintf(os.Stderr, err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
//defer stateStore.Close(ctx)
|
||||
defer stateStore.Close()
|
||||
|
||||
rp := &asyncRequestParser{
|
||||
sessionId: sessionId,
|
||||
@ -167,7 +161,7 @@ func main() {
|
||||
case _ = <-cint:
|
||||
case _ = <-cterm:
|
||||
}
|
||||
sh.Shutdown(ctx)
|
||||
sh.Shutdown()
|
||||
}()
|
||||
|
||||
for true {
|
||||
@ -183,7 +177,7 @@ func main() {
|
||||
fmt.Errorf("error in output: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
rqs, err = sh.Reset(ctx, rqs)
|
||||
rqs, err = sh.Reset(rqs)
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "error in reset: %v", "err", err)
|
||||
fmt.Errorf("error in reset: %v", err)
|
||||
|
@ -17,13 +17,13 @@ import (
|
||||
"git.defalsify.org/vise.git/resource"
|
||||
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/request"
|
||||
httprequest "git.grassecon.net/grassrootseconomics/visedriver/request/http"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/request"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -35,7 +35,8 @@ var (
|
||||
func main() {
|
||||
config.LoadConfig()
|
||||
|
||||
override := config.NewOverride()
|
||||
var connStr string
|
||||
var resourceDir string
|
||||
var size uint
|
||||
var engineDebug bool
|
||||
var host string
|
||||
@ -43,14 +44,9 @@ func main() {
|
||||
var err error
|
||||
var gettextDir string
|
||||
var langs args.LangVar
|
||||
var resourceDir string
|
||||
|
||||
flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
|
||||
flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string")
|
||||
flag.StringVar(override.ResourceConn, "resource", "?", "resource data directory")
|
||||
flag.StringVar(&resourceDir, "resource-dir", "", "resource data directory. If set, overrides --resource to create a non-binary fsdb for the given path.")
|
||||
flag.StringVar(override.StateConn, "state", "?", "state store connection string")
|
||||
|
||||
flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir")
|
||||
flag.StringVar(&connStr, "c", "", "connection string")
|
||||
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
||||
flag.UintVar(&size, "s", 160, "max size of output")
|
||||
flag.StringVar(&host, "h", config.Host(), "http host")
|
||||
@ -59,18 +55,16 @@ func main() {
|
||||
flag.Var(&langs, "language", "add symbol resolution for language")
|
||||
flag.Parse()
|
||||
|
||||
if resourceDir != "" {
|
||||
*override.ResourceConn = resourceDir
|
||||
override.ResourceConnMode = storage.DBMODE_TEXT
|
||||
if connStr == "" {
|
||||
connStr = config.DbConn()
|
||||
}
|
||||
config.Apply(override)
|
||||
conns, err := config.GetConns()
|
||||
connData, err := storage.ToConnData(connStr)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "connstr err: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
logg.Infof("start command", "conn", conns, "outputsize", size)
|
||||
logg.Infof("start command", "conn", connData, "resourcedir", resourceDir, "outputsize", size)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@ -94,7 +88,7 @@ func main() {
|
||||
cfg.EngineDebug = true
|
||||
}
|
||||
|
||||
menuStorageService := storage.NewMenuStorageService(conns)
|
||||
menuStorageService := storage.NewMenuStorageService(connData, resourceDir)
|
||||
|
||||
rs, err := menuStorageService.GetResource(ctx)
|
||||
if err != nil {
|
||||
@ -107,6 +101,7 @@ func main() {
|
||||
fmt.Fprintf(os.Stderr, err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
defer userdataStore.Close()
|
||||
|
||||
dbResource, ok := rs.(*resource.DbResource)
|
||||
if !ok {
|
||||
@ -121,8 +116,8 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
accountService := services.New(ctx, menuStorageService)
|
||||
|
||||
accountService := services.New(ctx, menuStorageService, connData)
|
||||
|
||||
hl, err := lhs.GetHandler(accountService)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, err.Error())
|
||||
@ -134,6 +129,7 @@ func main() {
|
||||
fmt.Fprintf(os.Stderr, err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
defer stateStore.Close()
|
||||
|
||||
//accountService := services.New(ctx, menuStorageService, connData)
|
||||
|
||||
@ -144,10 +140,7 @@ func main() {
|
||||
Addr: fmt.Sprintf("%s:%s", host, strconv.Itoa(int(port))),
|
||||
Handler: sh,
|
||||
}
|
||||
shutdownFunc := func() {
|
||||
sh.Shutdown(ctx)
|
||||
}
|
||||
s.RegisterOnShutdown(shutdownFunc)
|
||||
s.RegisterOnShutdown(sh.Shutdown)
|
||||
|
||||
cint := make(chan os.Signal)
|
||||
cterm := make(chan os.Signal)
|
||||
|
50
cmd/main.go
50
cmd/main.go
@ -5,19 +5,17 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path"
|
||||
"syscall"
|
||||
|
||||
"git.defalsify.org/vise.git/engine"
|
||||
"git.defalsify.org/vise.git/lang"
|
||||
"git.defalsify.org/vise.git/logging"
|
||||
"git.defalsify.org/vise.git/resource"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
||||
"git.defalsify.org/vise.git/lang"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -29,33 +27,34 @@ var (
|
||||
func main() {
|
||||
config.LoadConfig()
|
||||
|
||||
override := config.NewOverride()
|
||||
var connStr string
|
||||
var size uint
|
||||
var sessionId string
|
||||
var engineDebug bool
|
||||
var resourceDir string
|
||||
var err error
|
||||
var gettextDir string
|
||||
var langs args.LangVar
|
||||
|
||||
flag.StringVar(&resourceDir, "resourcedir", scriptDir, "resource dir")
|
||||
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
|
||||
flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
|
||||
flag.StringVar(override.ResourceConn, "resource", "?", "resource data directory")
|
||||
flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string")
|
||||
flag.StringVar(override.StateConn, "state", "?", "state store connection string")
|
||||
flag.StringVar(&connStr, "c", "", "connection string")
|
||||
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
||||
flag.UintVar(&size, "s", 160, "max size of output")
|
||||
flag.StringVar(&gettextDir, "gettext", "", "use gettext translations from given directory")
|
||||
flag.Var(&langs, "language", "add symbol resolution for language")
|
||||
flag.Parse()
|
||||
|
||||
config.Apply(override)
|
||||
conns, err := config.GetConns()
|
||||
if connStr == "" {
|
||||
connStr = config.DbConn()
|
||||
}
|
||||
connData, err := storage.ToConnData(connStr)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "connstr err: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
logg.Infof("start command", "conn", conns, "outputsize", size)
|
||||
logg.Infof("start command", "conn", connData, "outputsize", size)
|
||||
|
||||
if len(langs.Langs()) == 0 {
|
||||
langs.Set(config.Language())
|
||||
@ -81,12 +80,12 @@ func main() {
|
||||
MenuSeparator: menuSeparator,
|
||||
}
|
||||
|
||||
menuStorageService := storage.NewMenuStorageService(conns)
|
||||
menuStorageService := storage.NewMenuStorageService(connData, resourceDir)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "menu storage service error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
|
||||
if gettextDir != "" {
|
||||
menuStorageService = menuStorageService.WithGettext(gettextDir, langs.Langs())
|
||||
}
|
||||
@ -123,7 +122,7 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
accountService := services.New(ctx, menuStorageService)
|
||||
accountService := services.New(ctx, menuStorageService, connData)
|
||||
hl, err := lhs.GetHandler(accountService)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "get accounts service handler: %v\n", err)
|
||||
@ -136,21 +135,6 @@ func main() {
|
||||
en = en.WithDebug(nil)
|
||||
}
|
||||
|
||||
cint := make(chan os.Signal)
|
||||
cterm := make(chan os.Signal)
|
||||
signal.Notify(cint, os.Interrupt, syscall.SIGINT)
|
||||
signal.Notify(cterm, os.Interrupt, syscall.SIGTERM)
|
||||
go func() {
|
||||
var s os.Signal
|
||||
select {
|
||||
case s = <-cterm:
|
||||
case s = <-cint:
|
||||
}
|
||||
logg.InfoCtxf(ctx, "stopping on signal", "sig", s)
|
||||
en.Finish(ctx)
|
||||
os.Exit(0)
|
||||
}()
|
||||
|
||||
err = engine.Loop(ctx, en, os.Stdin, os.Stdout, nil)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "loop exited with error: %v\n", err)
|
||||
|
@ -31,30 +31,34 @@ var (
|
||||
func main() {
|
||||
config.LoadConfig()
|
||||
|
||||
override := config.NewOverride()
|
||||
var connStr string
|
||||
var authConnStr string
|
||||
var resourceDir string
|
||||
var size uint
|
||||
var engineDebug bool
|
||||
var stateDebug bool
|
||||
var host string
|
||||
var port uint
|
||||
flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
|
||||
flag.StringVar(override.ResourceConn, "resource", "?", "resource connection string")
|
||||
flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string")
|
||||
flag.StringVar(override.StateConn, "state", "?", "state store connection string")
|
||||
flag.StringVar(&connStr, "c", "", "connection string")
|
||||
flag.StringVar(&authConnStr, "authdb", "", "auth connection string")
|
||||
flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir")
|
||||
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
||||
flag.UintVar(&size, "s", 160, "max size of output")
|
||||
flag.StringVar(&host, "h", config.HostSSH(), "socket host")
|
||||
flag.UintVar(&port, "p", config.PortSSH(), "socket port")
|
||||
flag.Parse()
|
||||
|
||||
config.Apply(override)
|
||||
conns, err := config.GetConns()
|
||||
if connStr == "" {
|
||||
connStr = config.DbConn()
|
||||
}
|
||||
if authConnStr == "" {
|
||||
authConnStr = connStr
|
||||
}
|
||||
connData, err := storage.ToConnData(connStr)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "connstr err: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
authConnData, err := storage.ToConnData(authConnStr)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "auth connstr err: %v", err)
|
||||
@ -75,7 +79,7 @@ func main() {
|
||||
logg.WarnCtxf(ctx, "!!!!! Do not expose to internet and only use with tunnel!")
|
||||
logg.WarnCtxf(ctx, "!!!!! (See ssh -L <...>)")
|
||||
|
||||
logg.Infof("start command", "conn", conns, "authconn", authConnData, "outputsize", size, "keyfile", sshKeyFile, "host", host, "port", port)
|
||||
logg.Infof("start command", "conn", connData, "authconn", authConnData, "resourcedir", resourceDir, "outputsize", size, "keyfile", sshKeyFile, "host", host, "port", port)
|
||||
|
||||
pfp := path.Join(scriptDir, "pp.csv")
|
||||
|
||||
@ -98,7 +102,7 @@ func main() {
|
||||
}
|
||||
defer func() {
|
||||
logg.TraceCtxf(ctx, "shutdown auth key store reached")
|
||||
err = authKeyStore.Close(ctx)
|
||||
err = authKeyStore.Close()
|
||||
if err != nil {
|
||||
logg.ErrorCtxf(ctx, "keystore close error", "err", err)
|
||||
}
|
||||
@ -110,13 +114,14 @@ func main() {
|
||||
signal.Notify(cterm, os.Interrupt, syscall.SIGTERM)
|
||||
|
||||
runner := &ssh.SshRunner{
|
||||
Cfg: cfg,
|
||||
Debug: engineDebug,
|
||||
FlagFile: pfp,
|
||||
Conn: conns,
|
||||
SrvKeyFile: sshKeyFile,
|
||||
Host: host,
|
||||
Port: port,
|
||||
Cfg: cfg,
|
||||
Debug: engineDebug,
|
||||
FlagFile: pfp,
|
||||
Conn: connData,
|
||||
ResourceDir: resourceDir,
|
||||
SrvKeyFile: sshKeyFile,
|
||||
Host: host,
|
||||
Port: port,
|
||||
}
|
||||
go func() {
|
||||
select {
|
||||
|
@ -34,7 +34,7 @@ func main() {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
defer store.Close(ctx)
|
||||
defer store.Close()
|
||||
|
||||
err = store.AddFromFile(ctx, sshKeyFile, sessionId)
|
||||
if err != nil {
|
||||
|
@ -1,28 +0,0 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
viseconfig "git.grassecon.net/grassrootseconomics/visedriver/config"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
)
|
||||
|
||||
func NewOverride() *viseconfig.Override {
|
||||
var a string
|
||||
var b string
|
||||
var c string
|
||||
var d string
|
||||
o := &viseconfig.Override{
|
||||
DbConn: &a,
|
||||
StateConn: &b,
|
||||
StateConnMode: storage.DBMODE_TEXT,
|
||||
ResourceConn: &c,
|
||||
ResourceConnMode: storage.DBMODE_TEXT,
|
||||
UserConn: &d,
|
||||
UserConnMode: storage.DBMODE_BINARY,
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func Apply(o *viseconfig.Override) error {
|
||||
viseconfig.ApplyConn(o)
|
||||
return nil
|
||||
}
|
@ -8,29 +8,19 @@ import (
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/env"
|
||||
)
|
||||
|
||||
var (
|
||||
GetConns = viseconfig.GetConns
|
||||
EnvPath string
|
||||
)
|
||||
|
||||
func loadEnv() {
|
||||
if EnvPath == "" {
|
||||
env.LoadEnvVariables()
|
||||
} else {
|
||||
env.LoadEnvVariablesPath(EnvPath)
|
||||
}
|
||||
func init() {
|
||||
env.LoadEnvVariables()
|
||||
}
|
||||
|
||||
const (
|
||||
defaultSSHHost string = "127.0.0.1"
|
||||
defaultSSHPort uint = 7122
|
||||
defaultHTTPHost string = "127.0.0.1"
|
||||
defaultHTTPPort uint = 7123
|
||||
defaultHTTPPort uint = 7123
|
||||
defaultDomain = "sarafu.local"
|
||||
)
|
||||
|
||||
func LoadConfig() error {
|
||||
loadEnv()
|
||||
err := viseconfig.LoadConfig()
|
||||
if err != nil {
|
||||
return err
|
||||
@ -52,6 +42,9 @@ func SearchDomains() []string {
|
||||
return ParsedDomains
|
||||
}
|
||||
|
||||
func DbConn() string {
|
||||
return viseconfig.DbConn
|
||||
}
|
||||
|
||||
func Language() string {
|
||||
return viseconfig.DefaultLanguage
|
||||
|
41
debug/db.go
41
debug/db.go
@ -1,11 +1,11 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"encoding/binary"
|
||||
|
||||
visedb "git.defalsify.org/vise.git/db"
|
||||
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
||||
visedb "git.defalsify.org/vise.git/db"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -13,10 +13,10 @@ var (
|
||||
)
|
||||
|
||||
type KeyInfo struct {
|
||||
SessionId string
|
||||
Typ uint8
|
||||
SubTyp storedb.DataTyp
|
||||
Label string
|
||||
SessionId string
|
||||
Typ uint8
|
||||
SubTyp storedb.DataTyp
|
||||
Label string
|
||||
Description string
|
||||
}
|
||||
|
||||
@ -32,10 +32,18 @@ func (k KeyInfo) String() string {
|
||||
|
||||
func ToKeyInfo(k []byte, sessionId string) (KeyInfo, error) {
|
||||
o := KeyInfo{}
|
||||
b := []byte(sessionId)
|
||||
|
||||
if len(k) <= len(b) {
|
||||
return o, fmt.Errorf("storage key missing")
|
||||
}
|
||||
|
||||
o.SessionId = sessionId
|
||||
|
||||
o.Typ = uint8(k[0])
|
||||
k = k[1:]
|
||||
o.SessionId = string(k[:len(b)])
|
||||
k = k[len(b):]
|
||||
|
||||
if o.Typ == visedb.DATATYPE_USERDATA {
|
||||
if len(k) == 0 {
|
||||
@ -45,19 +53,30 @@ func ToKeyInfo(k []byte, sessionId string) (KeyInfo, error) {
|
||||
o.SubTyp = storedb.DataTyp(v)
|
||||
o.Label = subTypToString(o.SubTyp)
|
||||
k = k[2:]
|
||||
if len(k) != 0 {
|
||||
return o, fmt.Errorf("excess key information: %x", k)
|
||||
}
|
||||
} else {
|
||||
o.Label = typToString(o.Typ)
|
||||
k = k[2:]
|
||||
}
|
||||
|
||||
if len(k) != 0 {
|
||||
return o, fmt.Errorf("excess key information")
|
||||
}
|
||||
|
||||
return o, nil
|
||||
}
|
||||
|
||||
func FromKey(k []byte) (KeyInfo, error) {
|
||||
o := KeyInfo{}
|
||||
|
||||
if len(k) < 4 {
|
||||
return o, fmt.Errorf("insufficient key length")
|
||||
}
|
||||
|
||||
sessionIdBytes := k[1:len(k)-2]
|
||||
return ToKeyInfo(k, string(sessionIdBytes))
|
||||
}
|
||||
|
||||
func subTypToString(v storedb.DataTyp) string {
|
||||
return dbTypStr[v+visedb.DATATYPE_USERDATA+1]
|
||||
return dbTypStr[v + visedb.DATATYPE_USERDATA + 1]
|
||||
}
|
||||
|
||||
func typToString(v uint8) string {
|
||||
|
@ -1,4 +1,3 @@
|
||||
//go:build debugdb
|
||||
// +build debugdb
|
||||
|
||||
package debug
|
||||
@ -12,37 +11,34 @@ import (
|
||||
func init() {
|
||||
DebugCap |= 1
|
||||
dbTypStr[db.DATATYPE_STATE] = "internal state"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TRACKING_ID] = "tracking id"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_PUBLIC_KEY] = "public key"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_ACCOUNT_PIN] = "account pin"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_FIRST_NAME] = "first name"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_FAMILY_NAME] = "family name"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_YOB] = "year of birth"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_LOCATION] = "location"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_GENDER] = "gender"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_OFFERINGS] = "offerings"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_RECIPIENT] = "recipient"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_AMOUNT] = "amount"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TEMPORARY_VALUE] = "temporary value"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_ACTIVE_SYM] = "active sym"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_ACTIVE_BAL] = "active bal"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_BLOCKED_NUMBER] = "blocked number"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_PUBLIC_KEY_REVERSE] = "public_key_reverse"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_ACTIVE_DECIMAL] = "active decimal"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_ACTIVE_ADDRESS] = "active address"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_INCORRECT_PIN_ATTEMPTS] = "incorrect pin attempts"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_SELECTED_LANGUAGE_CODE] = "selected language"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_INITIAL_LANGUAGE_CODE] = "initial language"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_VOUCHER_SYMBOLS] = "voucher symbols"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_VOUCHER_BALANCES] = "voucher balances"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_VOUCHER_DECIMALS] = "voucher decimals"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_VOUCHER_ADDRESSES] = "voucher addresses"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_SENDERS] = "tx senders"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_RECIPIENTS] = "tx recipients"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_VALUES] = "tx values"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_ADDRESSES] = "tx addresses"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_HASHES] = "tx hashes"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_DATES] = "tx dates"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_SYMBOLS] = "tx symbols"
|
||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_DECIMALS] = "tx decimals"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TRACKING_ID] = "tracking id"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_PUBLIC_KEY] = "public key"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_ACCOUNT_PIN] = "account pin"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_FIRST_NAME] = "first name"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_FAMILY_NAME] = "family name"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_YOB] = "year of birth"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_LOCATION] = "location"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_GENDER] = "gender"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_OFFERINGS] = "offerings"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_RECIPIENT] = "recipient"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_AMOUNT] = "amount"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TEMPORARY_VALUE] = "temporary value"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_ACTIVE_SYM] = "active sym"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_ACTIVE_BAL] = "active bal"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_BLOCKED_NUMBER] = "blocked number"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_PUBLIC_KEY_REVERSE] = "public_key_reverse"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_ACTIVE_DECIMAL] = "active decimal"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_ACTIVE_ADDRESS] = "active address"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_VOUCHER_SYMBOLS] = "voucher symbols"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_VOUCHER_BALANCES] = "voucher balances"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_VOUCHER_DECIMALS] = "voucher decimals"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_VOUCHER_ADDRESSES] = "voucher addresses"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_SENDERS] = "tx senders"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_RECIPIENTS] = "tx recipients"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_VALUES] = "tx values"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_ADDRESSES] = "tx addresses"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_HASHES] = "tx hashes"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_DATES] = "tx dates"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_SYMBOLS] = "tx symbols"
|
||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_DECIMALS] = "tx decimals"
|
||||
}
|
||||
|
@ -3,13 +3,14 @@ package debug
|
||||
import (
|
||||
"testing"
|
||||
|
||||
visedb "git.defalsify.org/vise.git/db"
|
||||
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
||||
visedb "git.defalsify.org/vise.git/db"
|
||||
)
|
||||
|
||||
func TestDebugDbSubKeyInfo(t *testing.T) {
|
||||
s := "foo"
|
||||
b := []byte{0x20}
|
||||
b = append(b, []byte(s)...)
|
||||
b = append(b, []byte{0x00, 0x02}...)
|
||||
r, err := ToKeyInfo(b, s)
|
||||
if err != nil {
|
||||
@ -24,7 +25,7 @@ func TestDebugDbSubKeyInfo(t *testing.T) {
|
||||
if r.SubTyp != 2 {
|
||||
t.Fatalf("expected 2, got %d", r.SubTyp)
|
||||
}
|
||||
if DebugCap&1 > 0 {
|
||||
if DebugCap & 1 > 0 {
|
||||
if r.Label != "tracking id" {
|
||||
t.Fatalf("expected 'tracking id', got '%s'", r.Label)
|
||||
}
|
||||
@ -45,7 +46,7 @@ func TestDebugDbKeyInfo(t *testing.T) {
|
||||
if r.Typ != 16 {
|
||||
t.Fatalf("expected 16, got %d", r.Typ)
|
||||
}
|
||||
if DebugCap&1 > 0 {
|
||||
if DebugCap & 1 > 0 {
|
||||
if r.Label != "internal state" {
|
||||
t.Fatalf("expected 'internal_state', got '%s'", r.Label)
|
||||
}
|
||||
@ -55,6 +56,7 @@ func TestDebugDbKeyInfo(t *testing.T) {
|
||||
func TestDebugDbKeyInfoRestore(t *testing.T) {
|
||||
s := "bar"
|
||||
b := []byte{visedb.DATATYPE_USERDATA}
|
||||
b = append(b, []byte(s)...)
|
||||
k := storedb.ToBytes(storedb.DATA_ACTIVE_SYM)
|
||||
b = append(b, k...)
|
||||
|
||||
@ -68,7 +70,7 @@ func TestDebugDbKeyInfoRestore(t *testing.T) {
|
||||
if r.Typ != 32 {
|
||||
t.Fatalf("expected 32, got %d", r.Typ)
|
||||
}
|
||||
if DebugCap&1 > 0 {
|
||||
if DebugCap & 1 > 0 {
|
||||
if r.Label != "active sym" {
|
||||
t.Fatalf("expected 'active sym', got '%s'", r.Label)
|
||||
}
|
||||
|
@ -10,43 +10,35 @@ import (
|
||||
"git.defalsify.org/vise.git/logging"
|
||||
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/application"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/internal/cmd"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/internal/cmd"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/application"
|
||||
)
|
||||
|
||||
var (
|
||||
logg = logging.NewVanilla().WithContextKey("SessionId")
|
||||
scriptDir = path.Join("services", "registration")
|
||||
logg = logging.NewVanilla().WithContextKey("SessionId")
|
||||
scriptDir = path.Join("services", "registration")
|
||||
)
|
||||
|
||||
func main() {
|
||||
config.LoadConfig()
|
||||
|
||||
override := config.NewOverride()
|
||||
var sessionId string
|
||||
var resourceDir string
|
||||
var connStr string
|
||||
|
||||
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
|
||||
flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
|
||||
flag.StringVar(override.ResourceConn, "resource", "?", "resource data directory")
|
||||
flag.StringVar(&resourceDir, "resource-dir", "", "resource data directory. If set, overrides --resource to create a non-binary fsdb for the given path.")
|
||||
|
||||
flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string")
|
||||
flag.StringVar(override.StateConn, "state", "?", "state store connection string")
|
||||
flag.StringVar(&connStr, "c", "", "connection string")
|
||||
flag.Parse()
|
||||
|
||||
if resourceDir != "" {
|
||||
*override.ResourceConn = resourceDir
|
||||
override.ResourceConnMode = storage.DBMODE_TEXT
|
||||
|
||||
if connStr == "" {
|
||||
connStr = config.DbConn()
|
||||
}
|
||||
config.Apply(override)
|
||||
conns, err := config.GetConns()
|
||||
connData, err := storage.ToConnData(connStr)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "connstr err: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
||||
|
||||
@ -57,16 +49,16 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
x := cmd.NewCmd(sessionId, flagParser)
|
||||
x := cmd.NewCmd(connData, sessionId, flagParser)
|
||||
err = x.Parse(flag.Args())
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "cmd parse fail: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
logg.Infof("start command", "conn", conns, "subcmd", x)
|
||||
logg.Infof("start command", "conn", connData, "subcmd", x)
|
||||
|
||||
menuStorageService := storage.NewMenuStorageService(conns)
|
||||
menuStorageService := storage.NewMenuStorageService(connData, "")
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "menu storage service error: %v\n", err)
|
||||
os.Exit(1)
|
||||
|
@ -8,17 +8,18 @@ import (
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"git.defalsify.org/vise.git/lang"
|
||||
"git.defalsify.org/vise.git/logging"
|
||||
"git.defalsify.org/vise.git/lang"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/config"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
changeHeadSrc = `LOAD reset_account_authorized 0
|
||||
LOAD reset_incorrect 0
|
||||
CATCH incorrect_pin flag_incorrect_pin 1
|
||||
CATCH pin_entry flag_account_authorized 0
|
||||
`
|
||||
`
|
||||
|
||||
selectSrc = `LOAD set_language 6
|
||||
RELOAD set_language
|
||||
@ -28,8 +29,8 @@ MOVE language_changed
|
||||
)
|
||||
|
||||
var (
|
||||
logg = logging.NewVanilla()
|
||||
mouts string
|
||||
logg = logging.NewVanilla()
|
||||
mouts string
|
||||
incmps string
|
||||
)
|
||||
|
||||
@ -62,7 +63,7 @@ func main() {
|
||||
}
|
||||
logg.Tracef("using languages", "lang", config.Languages)
|
||||
|
||||
for i, v := range config.Languages {
|
||||
for i, v := range(config.Languages) {
|
||||
ln, err := lang.LanguageFromCode(v)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error parsing language: %s\n", v)
|
||||
@ -75,7 +76,7 @@ func main() {
|
||||
incmps += fmt.Sprintf("INCMP %s %v\n", v, n)
|
||||
|
||||
p := path.Join(srcDir, v)
|
||||
w, err := os.OpenFile(p, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0600)
|
||||
w, err := os.OpenFile(p, os.O_WRONLY | os.O_CREATE | os.O_EXCL, 0600)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "failed open language set template output: %v\n", err)
|
||||
os.Exit(1)
|
||||
@ -92,7 +93,7 @@ func main() {
|
||||
src += "INCMP . *\n"
|
||||
|
||||
p := path.Join(srcDir, "select_language.vis")
|
||||
w, err := os.OpenFile(p, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0600)
|
||||
w, err := os.OpenFile(p, os.O_WRONLY | os.O_CREATE | os.O_EXCL, 0600)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "failed open select language vis output: %v\n", err)
|
||||
os.Exit(1)
|
||||
@ -106,7 +107,7 @@ func main() {
|
||||
|
||||
src = changeHeadSrc + src
|
||||
p = path.Join(srcDir, "change_language.vis")
|
||||
w, err = os.OpenFile(p, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0600)
|
||||
w, err = os.OpenFile(p, os.O_WRONLY | os.O_CREATE | os.O_EXCL, 0600)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "failed open select language vis output: %v\n", err)
|
||||
os.Exit(1)
|
||||
|
@ -7,11 +7,11 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/debug"
|
||||
"git.defalsify.org/vise.git/db"
|
||||
"git.defalsify.org/vise.git/logging"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/debug"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -19,64 +19,55 @@ var (
|
||||
scriptDir = path.Join("services", "registration")
|
||||
)
|
||||
|
||||
func formatItem(k []byte, v []byte, sessionId string) (string, error) {
|
||||
o, err := debug.ToKeyInfo(k, sessionId)
|
||||
func formatItem(k []byte, v []byte) (string, error) {
|
||||
o, err := debug.FromKey(k)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
s := fmt.Sprintf("%v\t%v\n", o.Label, string(v))
|
||||
|
||||
s := fmt.Sprintf("%vValue: %v\n\n", o, string(v))
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
config.LoadConfig()
|
||||
|
||||
override := config.NewOverride()
|
||||
var connStr string
|
||||
var sessionId string
|
||||
var database string
|
||||
var engineDebug bool
|
||||
var err error
|
||||
var first bool
|
||||
var resourceDir string
|
||||
|
||||
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
|
||||
flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
|
||||
flag.StringVar(override.ResourceConn, "resource", "?", "resource data directory")
|
||||
flag.StringVar(&resourceDir, "resource-dir", "", "resource data directory. If set, overrides --resource to create a non-binary fsdb for the given path.")
|
||||
flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string")
|
||||
flag.StringVar(override.StateConn, "state", "?", "state store connection string")
|
||||
flag.StringVar(&connStr, "c", ".state", "connection string")
|
||||
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
||||
flag.Parse()
|
||||
|
||||
if resourceDir != "" {
|
||||
*override.ResourceConn = resourceDir
|
||||
override.ResourceConnMode = storage.DBMODE_TEXT
|
||||
if connStr != "" {
|
||||
connStr = config.DbConn()
|
||||
}
|
||||
config.Apply(override)
|
||||
conns, err := config.GetConns()
|
||||
connData, err := storage.ToConnData(connStr)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "connstr err: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
logg.Infof("start command", "conn", conns)
|
||||
logg.Infof("start command", "conn", connData)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
||||
ctx = context.WithValue(ctx, "Database", database)
|
||||
|
||||
menuStorageService := storage.NewMenuStorageService(conns)
|
||||
resourceDir := scriptDir
|
||||
menuStorageService := storage.NewMenuStorageService(connData, resourceDir)
|
||||
|
||||
store, err := menuStorageService.GetUserdataDb(ctx)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "get userdata db: %v\n", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
store.SetSession(sessionId)
|
||||
store.SetPrefix(db.DATATYPE_USERDATA)
|
||||
|
||||
d, err := store.Dump(ctx, []byte(""))
|
||||
d, err := store.Dump(ctx, []byte(sessionId))
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "store dump fail: %v\n", err.Error())
|
||||
os.Exit(1)
|
||||
@ -87,19 +78,15 @@ func main() {
|
||||
if k == nil {
|
||||
break
|
||||
}
|
||||
if !first {
|
||||
fmt.Printf("Session ID: %s\n---\n", sessionId)
|
||||
first = true
|
||||
}
|
||||
r, err := formatItem(append([]byte{db.DATATYPE_USERDATA}, k...), v, sessionId)
|
||||
r, err := formatItem(k, v)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "format db item error: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "format db item error: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf(r)
|
||||
}
|
||||
|
||||
err = store.Close(ctx)
|
||||
err = store.Close()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, err.Error())
|
||||
os.Exit(1)
|
||||
|
86
devtools/store/generate/main.go
Normal file
86
devtools/store/generate/main.go
Normal file
@ -0,0 +1,86 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha1"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
testdataloader "github.com/peteole/testdata-loader"
|
||||
"git.defalsify.org/vise.git/logging"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
|
||||
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
||||
)
|
||||
|
||||
var (
|
||||
logg = logging.NewVanilla()
|
||||
baseDir = testdataloader.GetBasePath()
|
||||
scriptDir = path.Join("services", "registration")
|
||||
)
|
||||
|
||||
func main() {
|
||||
config.LoadConfig()
|
||||
|
||||
var connStr string
|
||||
var sessionId string
|
||||
var database string
|
||||
var engineDebug bool
|
||||
var err error
|
||||
|
||||
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
|
||||
flag.StringVar(&connStr, "c", "", "connection string")
|
||||
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
||||
flag.Parse()
|
||||
|
||||
if connStr != "" {
|
||||
connStr = config.DbConn()
|
||||
}
|
||||
connData, err := storage.ToConnData(connStr)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "connstr err: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
logg.Infof("start command", "conn", connData)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
||||
ctx = context.WithValue(ctx, "Database", database)
|
||||
|
||||
resourceDir := scriptDir
|
||||
menuStorageService := storage.NewMenuStorageService(connData, resourceDir)
|
||||
|
||||
userDb, err := menuStorageService.GetUserdataDb(ctx)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
userStore := store.UserDataStore{userDb}
|
||||
|
||||
h := sha1.New()
|
||||
h.Write([]byte(sessionId))
|
||||
address := h.Sum(nil)
|
||||
addressString := fmt.Sprintf("%x", address)
|
||||
|
||||
err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_PUBLIC_KEY, []byte(addressString))
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
err = userStore.WriteEntry(ctx, addressString, storedb.DATA_PUBLIC_KEY_REVERSE, []byte(sessionId))
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
err = userDb.Close()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
10
go.mod
10
go.mod
@ -3,11 +3,11 @@ module git.grassecon.net/grassrootseconomics/sarafu-vise
|
||||
go 1.23.4
|
||||
|
||||
require (
|
||||
git.defalsify.org/vise.git v0.2.3-0.20250120121301-10739fb4a8c9
|
||||
git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250121135150-e0b539809805
|
||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250122123424-6749c632b0a2
|
||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250121135340-ca97e23e8c84
|
||||
git.defalsify.org/vise.git v0.2.3-0.20250115000535-e2d329b3f739
|
||||
git.grassecon.net/grassrootseconomics/common v0.0.0-20250113174703-6afccefd1f05
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250115072214-bca7c5de969f
|
||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250115003256-c0534ede1b63
|
||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250113103030-f0b2056fd87d
|
||||
github.com/alecthomas/assert/v2 v2.2.2
|
||||
github.com/gofrs/uuid v4.4.0+incompatible
|
||||
github.com/grassrootseconomics/ussd-data-service v1.2.0-beta
|
||||
|
20
go.sum
20
go.sum
@ -1,13 +1,13 @@
|
||||
git.defalsify.org/vise.git v0.2.3-0.20250120121301-10739fb4a8c9 h1:sPcqXQcywxA8W3W+9qQncLPmsrgqTIlec7vmD4/7vyA=
|
||||
git.defalsify.org/vise.git v0.2.3-0.20250120121301-10739fb4a8c9/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck=
|
||||
git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d h1:5mzLas+jxTUtusOKx4XvU+n2QvrV/mH17MnJRy46siQ=
|
||||
git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250121135150-e0b539809805 h1:deGnqf4YCsbxhXgjFEjYjTUCvciLEmI26T9IysRsQXY=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250121135150-e0b539809805/go.mod h1:9bc3d//Qqm11hz7GYRdQc1Uan+0GJIOpvRBbv8cHMu8=
|
||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250122123424-6749c632b0a2 h1:ON77G5K0JNuwPb5JT/hRfF6G6+xstlBQgEIEzWydnhg=
|
||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250122123424-6749c632b0a2/go.mod h1:pjKp9L/ZsWW3kMB0UoIl1yv9TBIuU33mn9Aghxp7vGk=
|
||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250121135340-ca97e23e8c84 h1:VoBmqsjlRdz+IPbtKsAkc1IrMepjR+QlesZT31Jokrk=
|
||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250121135340-ca97e23e8c84/go.mod h1:DpibtYpnT3nG4Kn556hRAkdu4+CtiI/6MbnQHal51mQ=
|
||||
git.defalsify.org/vise.git v0.2.3-0.20250115000535-e2d329b3f739 h1:w7pj1oh7jXrfajahVYU7m7AfHst4C6jNVzDVoaqJ7e8=
|
||||
git.defalsify.org/vise.git v0.2.3-0.20250115000535-e2d329b3f739/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck=
|
||||
git.grassecon.net/grassrootseconomics/common v0.0.0-20250113174703-6afccefd1f05 h1:BenzGx6aDHKDwE23/mWIFD2InYIXyzHroZWV3MF5WUk=
|
||||
git.grassecon.net/grassrootseconomics/common v0.0.0-20250113174703-6afccefd1f05/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250115072214-bca7c5de969f h1:FgccQi8vipX6dUt+GRiRDYHMR3UqC+plz73vw7y3fyU=
|
||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250115072214-bca7c5de969f/go.mod h1:tbA4whUGMUIDgQVdIW0sxWPuuXOvZRSny5zeku5hX4k=
|
||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250115003256-c0534ede1b63 h1:bX7klKZpX+ZZu1LKbtOXDAhV/KK0YwExehiIi0jusAM=
|
||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250115003256-c0534ede1b63/go.mod h1:Syw9TZyigPAM7t9FvicOm36iUnidt45f0SxzT2JniQ8=
|
||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250113103030-f0b2056fd87d h1:q/NO1rEgK3pia32D/tCq5hXfEuJp84COZRwceFvy/MM=
|
||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250113103030-f0b2056fd87d/go.mod h1:AH15xABcvaJr1TCGlih3oGSuwWC0E5IdbHQwuu+E1KI=
|
||||
github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk=
|
||||
github.com/alecthomas/assert/v2 v2.2.2/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
|
||||
github.com/alecthomas/participle/v2 v2.0.0 h1:Fgrq+MbuSsJwIkw3fEj9h75vDP0Er5JzepJ0/HNHv0g=
|
||||
|
@ -275,7 +275,7 @@ func (h *MenuHandlers) CheckBlockedStatus(ctx context.Context, sym string, input
|
||||
}
|
||||
|
||||
pinAttemptsValue, _ := strconv.ParseUint(string(currentWrongPinAttempts), 0, 64)
|
||||
|
||||
|
||||
if pinAttemptsValue == 0 {
|
||||
res.FlagReset = append(res.FlagReset, flag_account_blocked)
|
||||
return res, nil
|
||||
|
@ -54,7 +54,7 @@ func InitializeTestStore(t *testing.T) (context.Context, *store.UserDataStore) {
|
||||
store := &store.UserDataStore{Db: db}
|
||||
|
||||
t.Cleanup(func() {
|
||||
db.Close(ctx) // Ensure the DB is closed after each test
|
||||
db.Close() // Ensure the DB is closed after each test
|
||||
})
|
||||
|
||||
return ctx, store
|
||||
|
@ -35,6 +35,13 @@ func (eu *EventsUpdater) HandleCustodialRegistration(ctx context.Context, ev *ap
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// err = pe.Load(identity.SessionId)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// st := pe.GetState()
|
||||
// st.SetFlag(accountCreatedFlag)
|
||||
// return pe.Save(identity.SessionId)
|
||||
logg.DebugCtxf(ctx, "received custodial registration event", "identity", identity)
|
||||
return nil
|
||||
}
|
||||
|
@ -4,12 +4,12 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"git.defalsify.org/vise.git/logging"
|
||||
"git.defalsify.org/vise.git/persist"
|
||||
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
|
||||
"git.defalsify.org/vise.git/logging"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
|
||||
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -17,9 +17,9 @@ var (
|
||||
)
|
||||
|
||||
type EventsUpdater struct {
|
||||
api remote.AccountService
|
||||
api remote.AccountService
|
||||
formatFunc func(string, int, any) string
|
||||
store storage.StorageService
|
||||
store storage.StorageService
|
||||
}
|
||||
|
||||
func NewEventsUpdater(api remote.AccountService, store storage.StorageService) *EventsUpdater {
|
||||
|
@ -6,13 +6,13 @@ import (
|
||||
"strings"
|
||||
|
||||
"git.defalsify.org/vise.git/db"
|
||||
"git.grassecon.net/grassrootseconomics/common/identity"
|
||||
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
|
||||
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
||||
"git.grassecon.net/grassrootseconomics/common/identity"
|
||||
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
||||
)
|
||||
|
||||
// execute all
|
||||
// execute all
|
||||
func (eu *EventsUpdater) updateToken(ctx context.Context, identity identity.Identity, userStore *store.UserDataStore, tokenAddress string) error {
|
||||
err := eu.updateTokenList(ctx, identity, userStore)
|
||||
if err != nil {
|
||||
@ -47,6 +47,7 @@ func (eu *EventsUpdater) updateToken(ctx context.Context, identity identity.Iden
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
// set default token to given symbol.
|
||||
func (eu *EventsUpdater) updateDefaultToken(ctx context.Context, identity identity.Identity, userStore *store.UserDataStore, activeSym string) error {
|
||||
pfxDb := toPrefixDb(userStore, identity.SessionId)
|
||||
@ -58,6 +59,7 @@ func (eu *EventsUpdater) updateDefaultToken(ctx context.Context, identity identi
|
||||
return store.UpdateVoucherData(ctx, userStore, identity.SessionId, tokenData)
|
||||
}
|
||||
|
||||
|
||||
// handle token transfer.
|
||||
//
|
||||
// if from and to are NOT the same, handle code will be executed once for each side of the transfer.
|
||||
@ -187,7 +189,7 @@ func (eu *EventsUpdater) updateTokenTransferList(ctx context.Context, identity i
|
||||
return err
|
||||
}
|
||||
|
||||
for i, tx := range txs {
|
||||
for i, tx := range(txs) {
|
||||
r = append(r, eu.formatFunc(apievent.EventTokenTransferTag, i, tx))
|
||||
}
|
||||
|
||||
|
@ -5,8 +5,8 @@ import (
|
||||
"fmt"
|
||||
|
||||
"git.defalsify.org/vise.git/logging"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/application"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/application"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -14,17 +14,18 @@ var (
|
||||
)
|
||||
|
||||
type Cmd struct {
|
||||
sessionId string
|
||||
conn storage.ConnData
|
||||
sessionId string
|
||||
conn storage.ConnData
|
||||
flagParser *application.FlagManager
|
||||
cmd int
|
||||
enable bool
|
||||
exec func(ctx context.Context, ss storage.StorageService) error
|
||||
cmd int
|
||||
enable bool
|
||||
exec func(ctx context.Context, ss storage.StorageService) error
|
||||
}
|
||||
|
||||
func NewCmd(sessionId string, flagParser *application.FlagManager) *Cmd {
|
||||
func NewCmd(conn storage.ConnData, sessionId string, flagParser *application.FlagManager) *Cmd {
|
||||
return &Cmd{
|
||||
sessionId: sessionId,
|
||||
conn: conn,
|
||||
sessionId: sessionId,
|
||||
flagParser: flagParser,
|
||||
}
|
||||
}
|
||||
@ -94,3 +95,5 @@ func (c *Cmd) Parse(args []string) error {
|
||||
|
||||
return fmt.Errorf("unknown subcommand: %s", cmd)
|
||||
}
|
||||
|
||||
|
||||
|
@ -9,14 +9,12 @@ import (
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"git.defalsify.org/vise.git/logging"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/testutil"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/testutil/driver"
|
||||
"github.com/gofrs/uuid"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/testutil/driver"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/testutil"
|
||||
)
|
||||
|
||||
var (
|
||||
logg = logging.NewVanilla().WithDomain("menutraversaltest")
|
||||
testData = driver.ReadData()
|
||||
sessionID string
|
||||
src = rand.NewSource(42)
|
||||
@ -24,6 +22,9 @@ var (
|
||||
)
|
||||
|
||||
var groupTestFile = flag.String("test-file", "group_test.json", "The test file to use for running the group tests")
|
||||
var database = flag.String("db", "gdbm", "Specify the database (gdbm or postgres)")
|
||||
var connStr = flag.String("conn", ".test_state", "connection string")
|
||||
var dbSchema = flag.String("schema", "test", "Specify the database schema (default test)")
|
||||
|
||||
func GenerateSessionId() string {
|
||||
uu := uuid.NewGenWithOptions(uuid.WithRandomReader(g))
|
||||
@ -79,7 +80,12 @@ func extractSendAmount(response []byte) string {
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
// Parse the flags
|
||||
flag.Parse()
|
||||
sessionID = GenerateSessionId()
|
||||
// set the db
|
||||
testutil.SetDatabase(*database, *connStr, *dbSchema)
|
||||
|
||||
// Cleanup the db after tests
|
||||
defer testutil.CleanDatabase()
|
||||
|
||||
@ -94,8 +100,7 @@ func TestAccountCreationSuccessful(t *testing.T) {
|
||||
for _, session := range sessions {
|
||||
groups := driver.FilterGroupsByName(session.Groups, "account_creation_successful")
|
||||
for _, group := range groups {
|
||||
for i, step := range group.Steps {
|
||||
logg.TraceCtxf(ctx, "executing step", "i", i, "step", step)
|
||||
for _, step := range group.Steps {
|
||||
cont, err := en.Exec(ctx, []byte(step.Input))
|
||||
if err != nil {
|
||||
t.Fatalf("Test case '%s' failed at input '%s': %v", group.Name, step.Input, err)
|
||||
@ -137,8 +142,7 @@ func TestAccountRegistrationRejectTerms(t *testing.T) {
|
||||
for _, session := range sessions {
|
||||
groups := driver.FilterGroupsByName(session.Groups, "account_creation_reject_terms")
|
||||
for _, group := range groups {
|
||||
for i, step := range group.Steps {
|
||||
logg.TraceCtxf(ctx, "executing step", "i", i, "step", step)
|
||||
for _, step := range group.Steps {
|
||||
cont, err := en.Exec(ctx, []byte(step.Input))
|
||||
if err != nil {
|
||||
t.Fatalf("Test case '%s' failed at input '%s': %v", group.Name, step.Input, err)
|
||||
@ -173,8 +177,7 @@ func TestMainMenuHelp(t *testing.T) {
|
||||
for _, session := range sessions {
|
||||
groups := driver.FilterGroupsByName(session.Groups, "main_menu_help")
|
||||
for _, group := range groups {
|
||||
for i, step := range group.Steps {
|
||||
logg.TraceCtxf(ctx, "executing step", "i", i, "step", step)
|
||||
for _, step := range group.Steps {
|
||||
cont, err := en.Exec(ctx, []byte(step.Input))
|
||||
if err != nil {
|
||||
t.Fatalf("Test case '%s' failed at input '%s': %v", group.Name, step.Input, err)
|
||||
|
@ -12,7 +12,7 @@ func (p *Profile) InsertOrShift(index int, value string) {
|
||||
for len(p.ProfileItems) < index {
|
||||
p.ProfileItems = append(p.ProfileItems, "0")
|
||||
}
|
||||
p.ProfileItems = append(p.ProfileItems, "0")
|
||||
p.ProfileItems = append(p.ProfileItems, "0")
|
||||
p.ProfileItems[index] = value
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,16 @@
|
||||
//go:build !online
|
||||
// +build !online
|
||||
|
||||
package services
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"context"
|
||||
|
||||
devremote "git.grassecon.net/grassrootseconomics/sarafu-api/dev"
|
||||
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/event"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
devremote "git.grassecon.net/grassrootseconomics/sarafu-api/dev"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
|
||||
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/event"
|
||||
)
|
||||
|
||||
type localEmitter struct {
|
||||
@ -38,7 +37,7 @@ func (d *localEmitter) emit(ctx context.Context, msg apievent.Msg) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func New(ctx context.Context, storageService storage.StorageService) remote.AccountService {
|
||||
func New(ctx context.Context, storageService storage.StorageService, conn storage.ConnData) remote.AccountService {
|
||||
svc := devremote.NewDevAccountService(ctx, storageService)
|
||||
svc = svc.WithAutoVoucher(ctx, "FOO", 42)
|
||||
eu := event.NewEventsUpdater(svc, storageService)
|
||||
|
@ -4,8 +4,8 @@ TXTS = $(wildcard ./*.txt.orig)
|
||||
VISE_PATH := ../../go-vise
|
||||
|
||||
# Rule to build .bin files from .vis files
|
||||
%.vis: buildasm
|
||||
./vise-asm -f pp.csv $(basename $@).vis > $(basename $@).bin
|
||||
%.vis:
|
||||
go run $(VISE_PATH)/dev/asm/main.go -f pp.csv $(basename $@).vis > $(basename $@).bin
|
||||
@echo "Built $(basename $@).bin from $(basename $@).vis"
|
||||
|
||||
# Rule to copy .orig files to .txt
|
||||
@ -19,10 +19,5 @@ all: $(INPUTS) $(TXTS)
|
||||
|
||||
clean:
|
||||
rm -vf *.bin
|
||||
rm -vf ./vise-asm
|
||||
|
||||
buildasm:
|
||||
go build -v -o ./vise-asm $(VISE_PATH)/dev/asm/main.go
|
||||
|
||||
|
||||
.PHONY: clean
|
||||
|
BIN
services/registration/_catch.bin
Normal file
BIN
services/registration/_catch.bin
Normal file
Binary file not shown.
BIN
services/registration/account_creation.bin
Normal file
BIN
services/registration/account_creation.bin
Normal file
Binary file not shown.
BIN
services/registration/account_creation_failed.bin
Normal file
BIN
services/registration/account_creation_failed.bin
Normal file
Binary file not shown.
BIN
services/registration/account_pending.bin
Normal file
BIN
services/registration/account_pending.bin
Normal file
Binary file not shown.
BIN
services/registration/address.bin
Normal file
BIN
services/registration/address.bin
Normal file
Binary file not shown.
BIN
services/registration/amount.bin
Normal file
BIN
services/registration/amount.bin
Normal file
Binary file not shown.
BIN
services/registration/api_failure.bin
Normal file
BIN
services/registration/api_failure.bin
Normal file
Binary file not shown.
BIN
services/registration/balances.bin
Normal file
BIN
services/registration/balances.bin
Normal file
Binary file not shown.
BIN
services/registration/blocked_account.bin
Normal file
BIN
services/registration/blocked_account.bin
Normal file
Binary file not shown.
BIN
services/registration/change_language.bin
Normal file
BIN
services/registration/change_language.bin
Normal file
Binary file not shown.
BIN
services/registration/check_statement.bin
Normal file
BIN
services/registration/check_statement.bin
Normal file
Binary file not shown.
BIN
services/registration/community_balance.bin
Normal file
BIN
services/registration/community_balance.bin
Normal file
Binary file not shown.
BIN
services/registration/confirm_create_pin.bin
Normal file
BIN
services/registration/confirm_create_pin.bin
Normal file
Binary file not shown.
BIN
services/registration/confirm_others_new_pin.bin
Normal file
BIN
services/registration/confirm_others_new_pin.bin
Normal file
Binary file not shown.
BIN
services/registration/confirm_pin_change.bin
Normal file
BIN
services/registration/confirm_pin_change.bin
Normal file
Binary file not shown.
BIN
services/registration/create_pin.bin
Normal file
BIN
services/registration/create_pin.bin
Normal file
Binary file not shown.
BIN
services/registration/create_pin_mismatch.bin
Normal file
BIN
services/registration/create_pin_mismatch.bin
Normal file
Binary file not shown.
BIN
services/registration/display_profile_info.bin
Normal file
BIN
services/registration/display_profile_info.bin
Normal file
Binary file not shown.
BIN
services/registration/edit_family_name.bin
Normal file
BIN
services/registration/edit_family_name.bin
Normal file
Binary file not shown.
BIN
services/registration/edit_first_name.bin
Normal file
BIN
services/registration/edit_first_name.bin
Normal file
Binary file not shown.
BIN
services/registration/edit_location.bin
Normal file
BIN
services/registration/edit_location.bin
Normal file
Binary file not shown.
BIN
services/registration/edit_offerings.bin
Normal file
BIN
services/registration/edit_offerings.bin
Normal file
Binary file not shown.
BIN
services/registration/edit_profile.bin
Normal file
BIN
services/registration/edit_profile.bin
Normal file
Binary file not shown.
BIN
services/registration/edit_yob.bin
Normal file
BIN
services/registration/edit_yob.bin
Normal file
Binary file not shown.
BIN
services/registration/enter_other_number.bin
Normal file
BIN
services/registration/enter_other_number.bin
Normal file
Binary file not shown.
BIN
services/registration/enter_others_new_pin.bin
Normal file
BIN
services/registration/enter_others_new_pin.bin
Normal file
Binary file not shown.
BIN
services/registration/enter_pin.bin
Normal file
BIN
services/registration/enter_pin.bin
Normal file
Binary file not shown.
BIN
services/registration/help.bin
Normal file
BIN
services/registration/help.bin
Normal file
Binary file not shown.
BIN
services/registration/incorrect_date_format.bin
Normal file
BIN
services/registration/incorrect_date_format.bin
Normal file
Binary file not shown.
BIN
services/registration/incorrect_pin.bin
Normal file
BIN
services/registration/incorrect_pin.bin
Normal file
Binary file not shown.
BIN
services/registration/invalid_amount.bin
Normal file
BIN
services/registration/invalid_amount.bin
Normal file
Binary file not shown.
BIN
services/registration/invalid_others_pin.bin
Normal file
BIN
services/registration/invalid_others_pin.bin
Normal file
Binary file not shown.
BIN
services/registration/invalid_pin.bin
Normal file
BIN
services/registration/invalid_pin.bin
Normal file
Binary file not shown.
BIN
services/registration/invalid_recipient.bin
Normal file
BIN
services/registration/invalid_recipient.bin
Normal file
Binary file not shown.
BIN
services/registration/invite_recipient.bin
Normal file
BIN
services/registration/invite_recipient.bin
Normal file
Binary file not shown.
BIN
services/registration/invite_result.bin
Normal file
BIN
services/registration/invite_result.bin
Normal file
Binary file not shown.
BIN
services/registration/language_changed.bin
Normal file
BIN
services/registration/language_changed.bin
Normal file
Binary file not shown.
0
services/registration/list_offering.bin
Normal file
0
services/registration/list_offering.bin
Normal file
BIN
services/registration/main.bin
Normal file
BIN
services/registration/main.bin
Normal file
Binary file not shown.
BIN
services/registration/my_account.bin
Normal file
BIN
services/registration/my_account.bin
Normal file
Binary file not shown.
BIN
services/registration/my_balance.bin
Normal file
BIN
services/registration/my_balance.bin
Normal file
Binary file not shown.
BIN
services/registration/my_vouchers.bin
Normal file
BIN
services/registration/my_vouchers.bin
Normal file
Binary file not shown.
BIN
services/registration/new_pin.bin
Normal file
BIN
services/registration/new_pin.bin
Normal file
Binary file not shown.
BIN
services/registration/no_admin_privilege.bin
Normal file
BIN
services/registration/no_admin_privilege.bin
Normal file
Binary file not shown.
BIN
services/registration/no_transfers.bin
Normal file
BIN
services/registration/no_transfers.bin
Normal file
Binary file not shown.
BIN
services/registration/no_voucher.bin
Normal file
BIN
services/registration/no_voucher.bin
Normal file
Binary file not shown.
BIN
services/registration/old_pin.bin
Normal file
BIN
services/registration/old_pin.bin
Normal file
Binary file not shown.
BIN
services/registration/others_pin_mismatch.bin
Normal file
BIN
services/registration/others_pin_mismatch.bin
Normal file
Binary file not shown.
BIN
services/registration/pin_entry.bin
Normal file
BIN
services/registration/pin_entry.bin
Normal file
Binary file not shown.
BIN
services/registration/pin_management.bin
Normal file
BIN
services/registration/pin_management.bin
Normal file
Binary file not shown.
BIN
services/registration/pin_reset_mismatch.bin
Normal file
BIN
services/registration/pin_reset_mismatch.bin
Normal file
Binary file not shown.
BIN
services/registration/pin_reset_result.bin
Normal file
BIN
services/registration/pin_reset_result.bin
Normal file
Binary file not shown.
BIN
services/registration/pin_reset_success.bin
Normal file
BIN
services/registration/pin_reset_success.bin
Normal file
Binary file not shown.
BIN
services/registration/profile_update_success.bin
Normal file
BIN
services/registration/profile_update_success.bin
Normal file
Binary file not shown.
BIN
services/registration/quit.bin
Normal file
BIN
services/registration/quit.bin
Normal file
Binary file not shown.
BIN
services/registration/root.bin
Normal file
BIN
services/registration/root.bin
Normal file
Binary file not shown.
BIN
services/registration/select_gender.bin
Normal file
BIN
services/registration/select_gender.bin
Normal file
Binary file not shown.
BIN
services/registration/select_language.bin
Normal file
BIN
services/registration/select_language.bin
Normal file
Binary file not shown.
BIN
services/registration/select_voucher.bin
Normal file
BIN
services/registration/select_voucher.bin
Normal file
Binary file not shown.
BIN
services/registration/send.bin
Normal file
BIN
services/registration/send.bin
Normal file
Binary file not shown.
BIN
services/registration/set_default.bin
Normal file
BIN
services/registration/set_default.bin
Normal file
Binary file not shown.
BIN
services/registration/set_eng.bin
Normal file
BIN
services/registration/set_eng.bin
Normal file
Binary file not shown.
BIN
services/registration/set_female.bin
Normal file
BIN
services/registration/set_female.bin
Normal file
Binary file not shown.
BIN
services/registration/set_male.bin
Normal file
BIN
services/registration/set_male.bin
Normal file
Binary file not shown.
BIN
services/registration/set_swa.bin
Normal file
BIN
services/registration/set_swa.bin
Normal file
Binary file not shown.
BIN
services/registration/set_unspecified.bin
Normal file
BIN
services/registration/set_unspecified.bin
Normal file
Binary file not shown.
BIN
services/registration/terms.bin
Normal file
BIN
services/registration/terms.bin
Normal file
Binary file not shown.
BIN
services/registration/transaction_initiated.bin
Normal file
BIN
services/registration/transaction_initiated.bin
Normal file
Binary file not shown.
BIN
services/registration/transaction_pin.bin
Normal file
BIN
services/registration/transaction_pin.bin
Normal file
Binary file not shown.
BIN
services/registration/transactions.bin
Normal file
BIN
services/registration/transactions.bin
Normal file
Binary file not shown.
BIN
services/registration/unregistered_number.bin
Normal file
BIN
services/registration/unregistered_number.bin
Normal file
Binary file not shown.
BIN
services/registration/update_familyname.bin
Normal file
BIN
services/registration/update_familyname.bin
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user