working poc

This commit is contained in:
nicksherron 2020-02-11 03:15:13 -05:00
parent 88d920cd35
commit e01de338d8
3 changed files with 7 additions and 2 deletions

View file

@ -102,10 +102,14 @@ func init() {
func sysRegister(mac string, site string, user string, pass string) {
host, err := os.Hostname()
if err != nil {
log.Fatal(err)
}
sys := map[string]interface{}{
"clientVersion": "1.2.0",
"name": "migration",
"hostname": os.Hostname(),
"hostname": host,
"mac": mac,
}
payloadBytes, err := json.Marshal(sys)

View file

@ -95,7 +95,7 @@ func dbInit() {
gormdb.AutoMigrate(&Command{})
gormdb.AutoMigrate(&System{})
//TODO: ensure these are the most efficient indexes
gormdb.Model(&User{}).AddIndex("idx_user", "username")
gormdb.Model(&User{}).AddUniqueIndex("idx_user", "username")
gormdb.Model(&System{}).AddIndex("idx_mac", "mac")
gormdb.Model(&Command{}).AddIndex("idx_exit_command_created", "exit_status, created, command")
gormdb.Model(&Command{}).AddIndex("idx_user_exit_command_created", "user_id, exit_status, created, command")

View file

@ -111,6 +111,7 @@ func loggerWithFormatterWriter(f gin.LogFormatter) gin.HandlerFunc {
})
}
// Run starts server
func Run() {
// Initialize backend