update types and add plugins submodule
This commit is contained in:
parent
61fe7dbea5
commit
1f9a95897e
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
.env
|
||||
tmp
|
||||
tmp
|
||||
.DS_Store
|
||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "plugins/dictionary"]
|
||||
path = plugins/dictionary
|
||||
url = ../../plugins-dictionary
|
||||
@ -1,4 +1,4 @@
|
||||
package amqp
|
||||
package types
|
||||
|
||||
const (
|
||||
AgentHello uint8 = iota
|
||||
@ -16,33 +16,33 @@ const (
|
||||
|
||||
type AgentMessage struct {
|
||||
Message uint8 `json:"message"`
|
||||
Data *AgentMessageData `json:"data"`
|
||||
Data *agentMessageData `json:"data"`
|
||||
}
|
||||
|
||||
type AgentMessageData struct {
|
||||
AgentHelloData
|
||||
AgentErrorData
|
||||
AgentStatusData
|
||||
type agentMessageData struct {
|
||||
agentHelloData
|
||||
agentErrorData
|
||||
agentStatusData
|
||||
}
|
||||
|
||||
type AgentErrorData struct {
|
||||
type agentErrorData struct {
|
||||
Error string
|
||||
}
|
||||
|
||||
type AgentStatusData struct {
|
||||
type agentStatusData struct {
|
||||
Error string `json:"error"`
|
||||
Status uint8 `json:"status"`
|
||||
TaskID int64 `json:"taskId"`
|
||||
Progress uint8 `json:"progress"` // 0-100, for AgentStatusRunning
|
||||
}
|
||||
|
||||
type AgentHelloData struct {
|
||||
type agentHelloData struct {
|
||||
Hostname string `json:"hostname"`
|
||||
Version string `json:"version"`
|
||||
Interfaces []InterfaceData `json:"interfaces"`
|
||||
Interfaces []interfaceData `json:"interfaces"`
|
||||
}
|
||||
|
||||
type InterfaceData struct {
|
||||
type interfaceData struct {
|
||||
Name string `json:"name"`
|
||||
IP string `json:"ip"`
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package amqp
|
||||
package types
|
||||
|
||||
import "system-trace/core/types"
|
||||
|
||||
@ -14,24 +14,24 @@ const (
|
||||
|
||||
type ControllerMessage struct {
|
||||
Message uint8 `json:"message"`
|
||||
Data *ControllerMessageData `json:"data"`
|
||||
Data *controllerMessageData `json:"data"`
|
||||
}
|
||||
|
||||
type ControllerMessageData struct {
|
||||
TaskStartData
|
||||
TaskPauseData
|
||||
TaskStopData
|
||||
type controllerMessageData struct {
|
||||
taskStartData
|
||||
taskPauseData
|
||||
taskStopData
|
||||
}
|
||||
|
||||
type TaskStopData struct {
|
||||
type taskStopData struct {
|
||||
TaskID int64 `json:"taskId"`
|
||||
}
|
||||
|
||||
type TaskPauseData struct {
|
||||
type taskPauseData struct {
|
||||
TaskID int64
|
||||
}
|
||||
|
||||
type TaskStartData struct {
|
||||
type taskStartData struct {
|
||||
TaskID int64
|
||||
Data *types.TaskVariables `json:"data"`
|
||||
}
|
||||
2
main.go
2
main.go
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"system-trace/core/database"
|
||||
"system-trace/core/environment"
|
||||
"system-trace/core/plugins"
|
||||
"system-trace/core/validators"
|
||||
)
|
||||
|
||||
@ -16,6 +17,7 @@ import (
|
||||
// @externalDocs.description OpenAPI
|
||||
func main() {
|
||||
environment.Load()
|
||||
plugins.LoadPlugins()
|
||||
validators.RegisterValidators()
|
||||
database.Connect()
|
||||
serveApp()
|
||||
|
||||
1
plugins/dictionary
Submodule
1
plugins/dictionary
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 40fcb5dc67bae495bccff549f3373dbbac854909
|
||||
22
plugins/plugins.go
Normal file
22
plugins/plugins.go
Normal file
@ -0,0 +1,22 @@
|
||||
package plugins
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"os"
|
||||
"system-trace/core/types"
|
||||
)
|
||||
|
||||
var plugins *[]types.Plugin
|
||||
|
||||
func LoadPlugins() {
|
||||
dictpath := "plugins/dictionary/dict.json"
|
||||
d, err := os.ReadFile(dictpath)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(d, &plugins); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
@ -10,7 +10,6 @@ import (
|
||||
// @Summary Get list of permissions
|
||||
// @Description Returns key-value map with permissions
|
||||
// @Produce json
|
||||
// @Header 200 {string} Token "accessToken=...;refreshToken=..."
|
||||
// @Success 200 {object} map[string]int8
|
||||
// @Router /permissions [get]
|
||||
func GetPermissions(c *fiber.Ctx) error {
|
||||
|
||||
@ -10,32 +10,36 @@ const (
|
||||
type TaskVariables struct {
|
||||
Mode uint8 `json:"mode" validate:"min=0,max=255"`
|
||||
Time uint32 `json:"time" validate:"min=0,max=4294967295"` // in seconds
|
||||
Plugins []PluginData `json:"plugins" validate:"required"`
|
||||
Performance PerformanceData `json:"performance" validate:"required"`
|
||||
Tweaks PerformanceTweaks `json:"tweaks" validate:"required"` // [[time_in_seconds, value]]: [[10, 6570]]
|
||||
Plugins []pluginData `json:"plugins" validate:"required"`
|
||||
Performance performanceData `json:"performance" validate:"required"`
|
||||
Tweaks performanceTweaks `json:"tweaks" validate:"required"` // [[time_in_seconds, value]]: [[10, 6570]]
|
||||
}
|
||||
|
||||
type PerformanceData struct { // Depends on selected mode
|
||||
// MODE_THROUGHPUT
|
||||
MaxBPS uint64 `json:"maxBps" validate:"min=0,max=18446744073709551615"`
|
||||
MaxPPS uint64 `json:"maxPps" validate:"min=0,max=18446744073709551615"`
|
||||
type performanceData struct { // Depends on selected mode
|
||||
// MODE_THROUGHPUT_BPS
|
||||
MaxBPS uint64 `json:"maxBps" validate:"min=0,max=18446744073709551615"`
|
||||
// MODE_THROUGHPUT_PPS
|
||||
MaxPPS uint64 `json:"maxPps" validate:"min=0,max=18446744073709551615"`
|
||||
// MODE_TCP_CONNECTIONS
|
||||
MaxTCPConnections uint32 `json:"maxTcpConn" validate:"min=0,max=4294967295"`
|
||||
// MODE_USERS
|
||||
MaxUsers uint32 `json:"maxUsers" validate:"min=0,max=4294967295"`
|
||||
}
|
||||
|
||||
type PerformanceTweaks struct {
|
||||
// MODE_THROUGHPUT
|
||||
BPS TweaksData `json:"bps"`
|
||||
PPS TweaksData `json:"pps"`
|
||||
TCPConnections TweaksData `json:"tcpConn"`
|
||||
type performanceTweaks struct {
|
||||
// MODE_THROUGHPUT_BPS
|
||||
BPS tweaksData `json:"bps"`
|
||||
// MODE_THROUGHPUT_PPS
|
||||
PPS tweaksData `json:"pps"`
|
||||
// MODE_TCP_CONNECTIONS
|
||||
TCPConnections tweaksData `json:"tcpConn"`
|
||||
// MODE_USERS
|
||||
Users TweaksData `json:"users"`
|
||||
Users tweaksData `json:"users"`
|
||||
}
|
||||
|
||||
type TweaksData [][]uint8
|
||||
type tweaksData [][]uint8
|
||||
|
||||
type PluginData struct {
|
||||
type pluginData struct {
|
||||
Plugin uint32 `json:"plugin" validate:"min=0,max=4294967295"`
|
||||
Weight uint8 `json:"weight" validate:"min=0,max=100"` // 0-100
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user