add postgresql support

This commit is contained in:
yuli
2022-09-23 14:10:00 +03:00
parent bfe14e244d
commit cd1102eb6d
5 changed files with 1122 additions and 4 deletions

View File

@@ -18,6 +18,7 @@ require (
github.com/hashicorp/go-uuid v1.0.3
github.com/julienschmidt/httprouter v1.3.0
github.com/kelseyhightower/envconfig v1.4.0
github.com/lib/pq v1.10.7 // indirect
github.com/mattn/go-sqlite3 v1.14.15 // indirect
github.com/oschwald/geoip2-golang v1.8.0
github.com/pelletier/go-toml v1.7.0 // indirect

View File

@@ -18,10 +18,6 @@ import (
"go.mongodb.org/mongo-driver/bson/primitive"
)
var (
allTables []string
)
// MySQL struct is used to store database object
type MySQLDB struct {
db *sql.DB

1107
src/storage/pgsql-storage.go Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -37,6 +37,10 @@ var TblName = &listTbls{
Processingactivities: 9,
}
var (
allTables []string
)
func GetTable(t Tbl) string {
switch t {
case TblName.Users:
@@ -104,6 +108,11 @@ func getDBObj() BackendDB {
var db BackendDB
if len(host) > 0 {
db = &MySQLDB{}
return db
}
host = os.Getenv("PGSQL_HOST")
if len(host) > 0 {
db = &PGSQLDB{}
} else {
db = &SQLiteDB{}
}

5
start-docker.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/sh
docker-compose down || true
docker build -t securitybunker/databunker:latest .
docker-compose up -d