mirror of
https://github.com/optim-enterprises-bv/databunker.git
synced 2025-11-03 03:17:45 +00:00
fix code
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user