Reog and implement sqlite
This commit is contained in:
parent
30cdf2c7e7
commit
61aa1be730
9 changed files with 223 additions and 76 deletions
28
main.go
28
main.go
|
@ -12,8 +12,8 @@ import (
|
|||
"os"
|
||||
|
||||
"crispbyte.dev/sig-auth/client"
|
||||
"crispbyte.dev/sig-auth/keydirectory"
|
||||
"crispbyte.dev/sig-auth/server"
|
||||
"crispbyte.dev/sig-auth/sqlite_directory"
|
||||
"github.com/opencontainers/go-digest"
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
@ -31,6 +31,10 @@ func main() {
|
|||
|
||||
simulateCaddy := flag.Bool("caddy", false, "Simulate caddy reverse proxy")
|
||||
|
||||
useTempDb := flag.Bool("temp-db", false, "Use a temporary in-memory database")
|
||||
|
||||
dbPath := flag.String("db", "", "Path to the sqlite database file")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
if *useClient {
|
||||
|
@ -48,7 +52,12 @@ func main() {
|
|||
|
||||
registerKey(*keyPath, *user)
|
||||
} else {
|
||||
runServer(*simulateCaddy)
|
||||
if !*useTempDb && *dbPath == "" {
|
||||
flag.PrintDefaults()
|
||||
return
|
||||
}
|
||||
|
||||
runServer(*simulateCaddy, *useTempDb, *dbPath)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,8 +114,19 @@ func runClient(keyFile string, keyId string, simulateCaddy bool) {
|
|||
fmt.Println(string(out[:]))
|
||||
}
|
||||
|
||||
func runServer(simulateCaddy bool) {
|
||||
keyDir := sqlite_directory.CreateDirectory()
|
||||
func runServer(simulateCaddy bool, useTempDb bool, dbPath string) {
|
||||
var keyDir keydirectory.RegistrationDirectory
|
||||
|
||||
if useTempDb {
|
||||
keyDir = keydirectory.CreateMemoryDirectory()
|
||||
} else {
|
||||
var err error
|
||||
keyDir, err = keydirectory.InitSqlite(dbPath)
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
server.Start(simulateCaddy, keyDir)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue