diff --git a/machinery/README.md b/machinery/README.md
index a1e8534..33bea05 100644
--- a/machinery/README.md
+++ b/machinery/README.md
@@ -1,22 +1,25 @@
# Kerberos Open Source - Machinery
-
-
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+[](
+https://brianmacdonald.github.io/Ethonate/address#0xf4a759C9436E2280Ea9cdd23d3144D95538fF4bE)
-[](https://kerberos.io)
+[**Docker Hub**](https://hub.docker.com/r/kerberos/agent) | [**Documentation**](https://doc.kerberos.io) | [**Website**](https://kerberos.io)
-[**Docker Hub**](https://hub.docker.com/r/kerberos/opensource) | [**Documentation**](https://doc.kerberos.io) | [**Website**](https://kerberos.io)
-
-Kerberos Open source (v3) is a cutting edge video surveillance management system made available as Open Source under the MIT License. This means that all the source code is available for you or your company, and you can use, transform and distribute the source code; as long you keep a reference of the original license. Kerberos Open Source (v3) can be used for commercial usage (which was not the case for v2). Read more [about the license here](LICENSE).
-
-## Machinery
+Kerberos Open source (v3) is a cutting edge video surveillance management system made available as Open Source under the MIT License. This means that all the source code is available for you or your company, and you can use, transform and distribute the source code; as long you keep a reference of the original license. Kerberos Open Source (v3) can be used for commercial usage (which was not the case for v2). Read more [about the license here](LICENSE).
\ No newline at end of file
diff --git a/machinery/doc.go b/machinery/doc.go
new file mode 100644
index 0000000..c157312
--- /dev/null
+++ b/machinery/doc.go
@@ -0,0 +1,4 @@
+// Package machinery is an open source video surveillance agent that allows you to connect
+// to an arbitrary video camera, process a stream of images and uploaded videos of interest
+// to a cloud provider.
+package main
diff --git a/machinery/docs/docs.go b/machinery/docs/docs.go
index 71f8052..cdc2101 100644
--- a/machinery/docs/docs.go
+++ b/machinery/docs/docs.go
@@ -1,27 +1,19 @@
-// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
+// Package docs GENERATED BY SWAG; DO NOT EDIT
// This file was generated by swaggo/swag
-
package docs
-import (
- "bytes"
- "encoding/json"
- "strings"
+import "github.com/swaggo/swag"
- "github.com/alecthomas/template"
- "github.com/swaggo/swag"
-)
-
-var doc = `{
+const docTemplate = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
- "description": "{{.Description}}",
+ "description": "{{escape .Description}}",
"title": "{{.Title}}",
"termsOfService": "https://kerberos.io",
"contact": {
"name": "API Support",
- "url": "https://www.kerberos.io/support",
+ "url": "https://www.kerberos.io",
"email": "support@kerberos.io"
},
"license": {
@@ -32,52 +24,7 @@ var doc = `{
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
- "paths": {
- "/api/install": {
- "get": {
- "description": "Get to know if the system was installed before or not.",
- "produces": [
- "application/json"
- ],
- "summary": "Get to know if the system was installed before or not.",
- "operationId": "web.getinstallation",
- "responses": {
- "200": {
- "description": "OK",
- "schema": {
- "$ref": "#/definitions/models.APIResponse"
- }
- }
- }
- },
- "post": {
- "description": "If not yet installed, initiate the user configuration.",
- "produces": [
- "application/json"
- ],
- "summary": "If not yet installed, initiate the user configuration.",
- "operationId": "web.updateinstallation",
- "responses": {
- "200": {
- "description": "OK",
- "schema": {
- "$ref": "#/definitions/models.APIResponse"
- }
- }
- }
- }
- }
- },
- "definitions": {
- "models.APIResponse": {
- "type": "object",
- "properties": {
- "data": {
- "type": "object"
- }
- }
- }
- },
+ "paths": {},
"securityDefinitions": {
"Bearer": {
"type": "apiKey",
@@ -87,49 +34,18 @@ var doc = `{
}
}`
-type swaggerInfo struct {
- Version string
- Host string
- BasePath string
- Schemes []string
- Title string
- Description string
-}
-
// SwaggerInfo holds exported Swagger Info so clients can modify it
-var SwaggerInfo = swaggerInfo{
- Version: "1.0",
- Host: "",
- BasePath: "/",
- Schemes: []string{},
- Title: "Swagger Kerberos Open Source API",
- Description: "This is the API for using and configure Kerberos Open source.",
-}
-
-type s struct{}
-
-func (s *s) ReadDoc() string {
- sInfo := SwaggerInfo
- sInfo.Description = strings.Replace(sInfo.Description, "\n", "\\n", -1)
-
- t, err := template.New("swagger_info").Funcs(template.FuncMap{
- "marshal": func(v interface{}) string {
- a, _ := json.Marshal(v)
- return string(a)
- },
- }).Parse(doc)
- if err != nil {
- return doc
- }
-
- var tpl bytes.Buffer
- if err := t.Execute(&tpl, sInfo); err != nil {
- return doc
- }
-
- return tpl.String()
+var SwaggerInfo = &swag.Spec{
+ Version: "1.0",
+ Host: "",
+ BasePath: "/",
+ Schemes: []string{},
+ Title: "Swagger Kerberos Agent API",
+ Description: "This is the API for using and configure Kerberos Agent.",
+ InfoInstanceName: "swagger",
+ SwaggerTemplate: docTemplate,
}
func init() {
- swag.Register(swag.Name, &s{})
+ swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}
diff --git a/machinery/docs/swagger.json b/machinery/docs/swagger.json
index 60b8f39..19b514c 100644
--- a/machinery/docs/swagger.json
+++ b/machinery/docs/swagger.json
@@ -1,12 +1,12 @@
{
"swagger": "2.0",
"info": {
- "description": "This is the API for using and configure Kerberos Open source.",
- "title": "Swagger Kerberos Open Source API",
+ "description": "This is the API for using and configure Kerberos Agent.",
+ "title": "Swagger Kerberos Agent API",
"termsOfService": "https://kerberos.io",
"contact": {
"name": "API Support",
- "url": "https://www.kerberos.io/support",
+ "url": "https://www.kerberos.io",
"email": "support@kerberos.io"
},
"license": {
@@ -16,52 +16,7 @@
"version": "1.0"
},
"basePath": "/",
- "paths": {
- "/api/install": {
- "get": {
- "description": "Get to know if the system was installed before or not.",
- "produces": [
- "application/json"
- ],
- "summary": "Get to know if the system was installed before or not.",
- "operationId": "web.getinstallation",
- "responses": {
- "200": {
- "description": "OK",
- "schema": {
- "$ref": "#/definitions/models.APIResponse"
- }
- }
- }
- },
- "post": {
- "description": "If not yet installed, initiate the user configuration.",
- "produces": [
- "application/json"
- ],
- "summary": "If not yet installed, initiate the user configuration.",
- "operationId": "web.updateinstallation",
- "responses": {
- "200": {
- "description": "OK",
- "schema": {
- "$ref": "#/definitions/models.APIResponse"
- }
- }
- }
- }
- }
- },
- "definitions": {
- "models.APIResponse": {
- "type": "object",
- "properties": {
- "data": {
- "type": "object"
- }
- }
- }
- },
+ "paths": {},
"securityDefinitions": {
"Bearer": {
"type": "apiKey",
diff --git a/machinery/docs/swagger.yaml b/machinery/docs/swagger.yaml
index 772ae22..fc119f8 100644
--- a/machinery/docs/swagger.yaml
+++ b/machinery/docs/swagger.yaml
@@ -1,46 +1,17 @@
basePath: /
-definitions:
- models.APIResponse:
- properties:
- data:
- type: object
- type: object
info:
contact:
email: support@kerberos.io
name: API Support
- url: https://www.kerberos.io/support
- description: This is the API for using and configure Kerberos Open source.
+ url: https://www.kerberos.io
+ description: This is the API for using and configure Kerberos Agent.
license:
name: Apache 2.0 - Commons Clause
url: http://www.apache.org/licenses/LICENSE-2.0.html
termsOfService: https://kerberos.io
- title: Swagger Kerberos Open Source API
+ title: Swagger Kerberos Agent API
version: "1.0"
-paths:
- /api/install:
- get:
- description: Get to know if the system was installed before or not.
- operationId: web.getinstallation
- produces:
- - application/json
- responses:
- "200":
- description: OK
- schema:
- $ref: '#/definitions/models.APIResponse'
- summary: Get to know if the system was installed before or not.
- post:
- description: If not yet installed, initiate the user configuration.
- operationId: web.updateinstallation
- produces:
- - application/json
- responses:
- "200":
- description: OK
- schema:
- $ref: '#/definitions/models.APIResponse'
- summary: If not yet installed, initiate the user configuration.
+paths: {}
securityDefinitions:
Bearer:
in: header
diff --git a/machinery/go.mod b/machinery/go.mod
index 0a1f44d..57e750e 100644
--- a/machinery/go.mod
+++ b/machinery/go.mod
@@ -85,14 +85,16 @@ require (
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.4.0 // indirect
github.com/ugorji/go/codec v1.2.7 // indirect
+ github.com/yuin/goldmark v1.4.1 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
github.com/ziutek/mymysql v1.5.4 // indirect
golang.org/x/crypto v0.0.0-20220516162934-403b01795ae8 // indirect
+ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 // indirect
golang.org/x/text v0.3.7 // indirect
- golang.org/x/tools v0.1.10 // indirect
+ golang.org/x/tools v0.1.11 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/ini.v1 v1.42.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
diff --git a/machinery/go.sum b/machinery/go.sum
index 1682478..8fb06e1 100644
--- a/machinery/go.sum
+++ b/machinery/go.sum
@@ -311,6 +311,8 @@ github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
+github.com/yuin/goldmark v1.4.1 h1:/vn0k+RBvwlxEmP5E7SZMqNxPhfMVFEJiykr15/0XKM=
+github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs=
@@ -332,6 +334,8 @@ golang.org/x/crypto v0.0.0-20220516162934-403b01795ae8/go.mod h1:IxCIyHEi3zRg3s0
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=
+golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
+golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@@ -403,6 +407,8 @@ golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4f
golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
golang.org/x/tools v0.1.10 h1:QjFRCZxdOhBJ/UNgnBZLbNV13DlbnK0quyivTnXJM20=
golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
+golang.org/x/tools v0.1.11 h1:loJ25fNOEhSXfHrpoGj91eCUThwdNX6u24rO1xnNteY=
+golang.org/x/tools v0.1.11/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
diff --git a/machinery/src/capture/main.go b/machinery/src/capture/main.go
index 557b404..8079617 100644
--- a/machinery/src/capture/main.go
+++ b/machinery/src/capture/main.go
@@ -1,3 +1,4 @@
+// Connecting to different camera sources and make it recording to disk.
package capture
import (
diff --git a/machinery/src/components/Kerberos.go b/machinery/src/components/Kerberos.go
index 4ab6fdd..ca231c4 100644
--- a/machinery/src/components/Kerberos.go
+++ b/machinery/src/components/Kerberos.go
@@ -42,6 +42,7 @@ func Bootstrap(configuration *models.Configuration, communication *models.Commun
// goroutines which do image capture, motion detection, onvif, etc.
for {
+ // This will blocking until receiving a signal to be restarted, reconfigured, stopped, etc.
status := RunAgent(configuration, communication)
if status == "stop" {
break
@@ -113,7 +114,7 @@ func RunAgent(configuration *models.Configuration, communication *models.Communi
// Handle ONVIF actions
go onvif.HandleONVIFActions(configuration, communication)
- //-------------------------------------------------------------------
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// This will go into a blocking state, once this channel is triggered
// the agent will cleanup and restart.
status = <-communication.HandleBootstrap
@@ -128,6 +129,10 @@ func RunAgent(configuration *models.Configuration, communication *models.Communi
close(communication.HandleLiveHDHandshake)
routers.DisconnectMQTT(mqttClient)
+ // Waiting for some seconds to make sure everything is properly closed.
+ time.Sleep(time.Second * 5)
+ log.Log.Info("RunAgent: waiting 5 seconds to make sure everything is properly closed.")
+
} else {
time.Sleep(time.Second * 2)
log.Log.Error("Something went wrong while opening RTSP: " + err.Error())
diff --git a/machinery/src/routers/http/Routes.go b/machinery/src/routers/http/Routes.go
index fddba5a..f558a34 100644
--- a/machinery/src/routers/http/Routes.go
+++ b/machinery/src/routers/http/Routes.go
@@ -101,35 +101,3 @@ func AddRoutes(r *gin.Engine, authMiddleware *jwt.GinJWTMiddleware, configuratio
}
return api
}
-
-// GetInstallation example
-// @Summary Get to know if the system was installed before or not.
-// @Description Get to know if the system was installed before or not.
-// @ID web.getinstallation
-// @Produce json
-// @Success 200 {object} models.APIResponse
-// @Router /api/install [get]
-func GetInstallation(c *gin.Context) {
- // Get the user configuration
- userConfig := components.ReadUserConfig()
-
- c.JSON(200, models.APIResponse{
- Data: userConfig.Installed,
- })
-}
-
-// UpdateInstallation example
-// @Summary If not yet installed, initiate the user configuration.
-// @Description If not yet installed, initiate the user configuration.
-// @ID web.updateinstallation
-// @Produce json
-// @Success 200 {object} models.APIResponse
-// @Router /api/install [post]
-func UpdateInstallation(c *gin.Context) {
- // TODO update user config and update global object.
- // userConfig = ...
- userConfig := components.ReadUserConfig()
- c.JSON(200, models.APIResponse{
- Data: userConfig,
- })
-}
diff --git a/machinery/src/routers/http/Server.go b/machinery/src/routers/http/Server.go
index 4eb436b..ed9c42e 100644
--- a/machinery/src/routers/http/Server.go
+++ b/machinery/src/routers/http/Server.go
@@ -15,13 +15,13 @@ import (
ginSwagger "github.com/swaggo/gin-swagger"
)
-// @title Swagger Kerberos Open Source API
+// @title Swagger Kerberos Agent API
// @version 1.0
-// @description This is the API for using and configure Kerberos Open source.
+// @description This is the API for using and configure Kerberos Agent.
// @termsOfService https://kerberos.io
// @contact.name API Support
-// @contact.url https://www.kerberos.io/support
+// @contact.url https://www.kerberos.io
// @contact.email support@kerberos.io
// @license.name Apache 2.0 - Commons Clause
diff --git a/machinery/src/routers/mqtt/main.go b/machinery/src/routers/mqtt/main.go
index 323156c..fe3abde 100644
--- a/machinery/src/routers/mqtt/main.go
+++ b/machinery/src/routers/mqtt/main.go
@@ -40,6 +40,7 @@ func ConfigureMQTT(configuration *models.Configuration, communication *models.Co
// properly. More information here: github.com/eclipse/paho.mqtt.golang.
opts.SetCleanSession(true)
opts.SetConnectRetry(true)
+ opts.SetAutoReconnect(true)
opts.SetConnectTimeout(30 * time.Second)
hubKey := ""
@@ -55,6 +56,7 @@ func ConfigureMQTT(configuration *models.Configuration, communication *models.Co
}
if hubKey != "" {
+
rand.Seed(time.Now().UnixNano())
random := rand.Intn(100)
mqttClientID := config.Key + strconv.Itoa(random) // this random int is to avoid conflicts.