This commit is contained in:
root
2020-09-14 20:39:56 +00:00
parent 527246392b
commit a3ef3becce
5 changed files with 12 additions and 13 deletions

View File

@@ -29,7 +29,7 @@ import (
)
type dbcon struct {
store storage.DBStorage
store storage.BackendDB
masterKey []byte
hash []byte
}
@@ -135,11 +135,11 @@ func prometheusHandler() http.Handler {
// metrics API call
func (e mainEnv) metrics(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
fmt.Printf("/metrics\n")
log.Printf("/metrics\n")
//w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(200)
//fmt.Fprintf(w, `{"status":"ok","apps":%q}`, result)
//fmt.Fprintf(w, "hello")
//log.Fprintf(w, `{"status":"ok","apps":%q}`, result)
//log.Fprintf(w, "hello")
//promhttp.Handler().ServeHTTP(w, r)
prometheusHandler().ServeHTTP(w, r)
}
@@ -501,7 +501,7 @@ func main() {
}
masterKey, masterKeyErr := masterkeyGet(masterKeyPtr)
if masterKeyErr != nil {
fmt.Printf("Error: %s", masterKeyErr)
log.Printf("Error: %s", masterKeyErr)
os.Exit(0)
}
store, _ := storage.OpenDB(dbPtr)
@@ -510,7 +510,6 @@ func main() {
db := &dbcon{store, masterKey, hash[:]}
e := mainEnv{db, cfg, make(chan struct{})}
e.dbCleanup()
fmt.Printf("host %s\n", cfg.Server.Host+":"+cfg.Server.Port)
router := e.setupRouter()
router = e.setupConfRouter(router)
srv := &http.Server{Addr: cfg.Server.Host + ":" + cfg.Server.Port, Handler: logRequest(router)}
@@ -520,7 +519,7 @@ func main() {
// Waiting for SIGINT (pkill -2)
go func() {
<-stop
fmt.Println("Closing app...")
log.Println("Closing app...")
close(e.stopChan)
time.Sleep(1)
srv.Shutdown(context.TODO())

View File

@@ -40,7 +40,7 @@ func (dbobj dbcon) createSessionRecord(userTOKEN string, expiration string, data
bdoc["endtime"] = endtime
bdoc["when"] = now
bdoc["data"] = encodedStr
_, err = dbobj.store.CreateRecord(storage.TblName.Sessions, bdoc)
_, err = dbobj.store.CreateRecord(storage.TblName.Sessions, &bdoc)
if err != nil {
return "", err
}

View File

@@ -58,7 +58,7 @@ func (dbobj dbcon) saveSharedRecord(userTOKEN string, fields string, expiration
if len(session) > 0 {
bdoc["session"] = session
}
_, err = dbobj.store.CreateRecord(storage.TblName.Sharedrecords, bdoc)
_, err = dbobj.store.CreateRecord(storage.TblName.Sharedrecords, &bdoc)
if err != nil {
return "", err
}

View File

@@ -56,7 +56,7 @@ func (dbobj dbcon) createUserRecord(parsedData userJSON, event *auditEvent) (str
event.Record = userTOKEN
}
//fmt.Println("creating new user")
_, err = dbobj.store.CreateRecord(storage.TblName.Users, bdoc)
_, err = dbobj.store.CreateRecord(storage.TblName.Users, &bdoc)
if err != nil {
fmt.Printf("error in create!\n")
return "", err

View File

@@ -42,7 +42,7 @@ func (dbobj dbcon) createRootXtoken(customRootXtoken string) (string, error) {
bdoc["xtoken"] = hashString(dbobj.hash, rootToken)
bdoc["type"] = "root"
bdoc["token"] = ""
_, err = dbobj.store.CreateRecord(storage.TblName.Xtokens, bdoc)
_, err = dbobj.store.CreateRecord(storage.TblName.Xtokens, &bdoc)
if err != nil {
return rootToken, err
}
@@ -68,7 +68,7 @@ func (dbobj dbcon) generateUserLoginXtoken(userTOKEN string) (string, string, er
bdoc["xtoken"] = hashedToken
bdoc["type"] = "login"
bdoc["endtime"] = expired
_, err = dbobj.store.CreateRecord(storage.TblName.Xtokens, bdoc)
_, err = dbobj.store.CreateRecord(storage.TblName.Xtokens, &bdoc)
return tokenUUID, hashedToken, err
}