Updated directory structure
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import prologue, nanoid, json
|
import prologue, nanoid, json
|
||||||
import sequtils, strutils, times
|
import sequtils, strutils, times
|
||||||
|
|
||||||
import ./agentApi
|
import ./handlers
|
||||||
import ../../types
|
import ../../types
|
||||||
|
|
||||||
proc error404*(ctx: Context) {.async.} =
|
proc error404*(ctx: Context) {.async.} =
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import terminal, strformat, strutils, sequtils, tables, json, times, base64, system, osproc, streams
|
import terminal, strformat, strutils, sequtils, tables, json, times, base64, system, osproc, streams
|
||||||
|
|
||||||
import ./taskDispatcher
|
|
||||||
import ../utils
|
import ../utils
|
||||||
|
import ../task/dispatcher
|
||||||
import ../db/database
|
import ../db/database
|
||||||
import ../../types
|
import ../../types
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import strformat, strutils, sequtils, nanoid, terminal
|
import strformat, strutils, sequtils, nanoid, terminal
|
||||||
import prologue
|
import prologue
|
||||||
|
|
||||||
import ./endpoints
|
|
||||||
import ../utils
|
import ../utils
|
||||||
|
import ../api/routes
|
||||||
import ../db/database
|
import ../db/database
|
||||||
import ../../types
|
import ../../types
|
||||||
|
|
||||||
@@ -47,10 +47,10 @@ proc listenerStart*(cq: Conquest, host: string, portStr: string) =
|
|||||||
var listener = newApp(settings = listenerSettings)
|
var listener = newApp(settings = listenerSettings)
|
||||||
|
|
||||||
# Define API endpoints
|
# Define API endpoints
|
||||||
listener.post("{listener}/register", endpoints.register)
|
listener.post("{listener}/register", routes.register)
|
||||||
listener.get("{listener}/{agent}/tasks", endpoints.getTasks)
|
listener.get("{listener}/{agent}/tasks", routes.getTasks)
|
||||||
listener.post("{listener}/{agent}/{task}/results", endpoints.postResults)
|
listener.post("{listener}/{agent}/{task}/results", routes.postResults)
|
||||||
listener.registerErrorHandler(Http404, endpoints.error404)
|
listener.registerErrorHandler(Http404, routes.error404)
|
||||||
|
|
||||||
# Store listener in database
|
# Store listener in database
|
||||||
var listenerInstance = newListener(name, host, port)
|
var listenerInstance = newListener(name, host, port)
|
||||||
@@ -80,10 +80,10 @@ proc restartListeners*(cq: Conquest) =
|
|||||||
listener = newApp(settings = settings)
|
listener = newApp(settings = settings)
|
||||||
|
|
||||||
# Define API endpoints
|
# Define API endpoints
|
||||||
listener.post("{listener}/register", endpoints.register)
|
listener.post("{listener}/register", routes.register)
|
||||||
listener.get("{listener}/{agent}/tasks", endpoints.getTasks)
|
listener.get("{listener}/{agent}/tasks", routes.getTasks)
|
||||||
listener.post("{listener}/{agent}/{task}/results", endpoints.postResults)
|
listener.post("{listener}/{agent}/{task}/results", routes.postResults)
|
||||||
listener.registerErrorHandler(Http404, endpoints.error404)
|
listener.registerErrorHandler(Http404, routes.error404)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
discard listener.runAsync()
|
discard listener.runAsync()
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import prompt, terminal, argparse
|
import prompt, terminal, argparse
|
||||||
import strutils, strformat, times, system, tables
|
import strutils, strformat, times, system, tables
|
||||||
|
|
||||||
import ./globals
|
import ./[agent, listener]
|
||||||
import core/agent, core/listener, db/database
|
import ../db/database
|
||||||
import ../types
|
import ../globals
|
||||||
|
import ../../types
|
||||||
|
|
||||||
#[
|
#[
|
||||||
Argument parsing
|
Argument parsing
|
||||||
@@ -61,7 +62,7 @@ var parser = newParser:
|
|||||||
command("exit"):
|
command("exit"):
|
||||||
nohelpflag()
|
nohelpflag()
|
||||||
|
|
||||||
proc handleConsoleCommand*(cq: Conquest, args: string) =
|
proc handleConsoleCommand(cq: Conquest, args: string) =
|
||||||
|
|
||||||
# Return if no command (or just whitespace) is entered
|
# Return if no command (or just whitespace) is entered
|
||||||
if args.replace(" ", "").len == 0: return
|
if args.replace(" ", "").len == 0: return
|
||||||
@@ -125,11 +126,8 @@ proc header(cq: Conquest) =
|
|||||||
cq.writeLine(" ┗ @jakobfriedl")
|
cq.writeLine(" ┗ @jakobfriedl")
|
||||||
cq.writeLine("─".repeat(21))
|
cq.writeLine("─".repeat(21))
|
||||||
cq.writeLine("")
|
cq.writeLine("")
|
||||||
|
|
||||||
#[
|
proc startServer*() =
|
||||||
Conquest framework entry point
|
|
||||||
]#
|
|
||||||
proc main() =
|
|
||||||
# Handle CTRL+C,
|
# Handle CTRL+C,
|
||||||
proc exit() {.noconv.} =
|
proc exit() {.noconv.} =
|
||||||
echo "Received CTRL+C. Type \"exit\" to close the application.\n"
|
echo "Received CTRL+C. Type \"exit\" to close the application.\n"
|
||||||
@@ -137,7 +135,7 @@ proc main() =
|
|||||||
setControlCHook(exit)
|
setControlCHook(exit)
|
||||||
|
|
||||||
# Initialize framework
|
# Initialize framework
|
||||||
let dbPath: string = "../src/server/db/conquest.db"
|
let dbPath: string = "../data/conquest.db"
|
||||||
cq = initConquest(dbPath)
|
cq = initConquest(dbPath)
|
||||||
|
|
||||||
# Print header
|
# Print header
|
||||||
@@ -156,6 +154,3 @@ proc main() =
|
|||||||
|
|
||||||
var command: string = cq.readLine()
|
var command: string = cq.readLine()
|
||||||
cq.withOutput(handleConsoleCommand, command)
|
cq.withOutput(handleConsoleCommand, command)
|
||||||
|
|
||||||
when isMainModule:
|
|
||||||
main()
|
|
||||||
@@ -1,9 +1,4 @@
|
|||||||
import ../types
|
import ../types
|
||||||
|
|
||||||
# Global variable for handling listeners, agents and console output
|
# Global variable for handling listeners, agents and console output
|
||||||
var cq*: Conquest
|
var cq*: Conquest
|
||||||
|
|
||||||
# Colors
|
|
||||||
# https://colors.sh/
|
|
||||||
const red* = "\e[210;66;79m"
|
|
||||||
const resetColor* = "\e[0m"
|
|
||||||
8
src/server/main.nim
Normal file
8
src/server/main.nim
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import prompt, terminal, argparse
|
||||||
|
import strutils, strformat, times, system, tables
|
||||||
|
|
||||||
|
import core/server
|
||||||
|
|
||||||
|
# Conquest framework entry point
|
||||||
|
when isMainModule:
|
||||||
|
startServer()
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
# Compiler flags
|
# Compiler flags
|
||||||
--threads:on
|
--threads:on
|
||||||
-d:httpxServerName="nginx"
|
-d:httpxServerName="nginx"
|
||||||
--outdir:"../bin"
|
--outdir:"../bin"
|
||||||
|
--out:"server"
|
||||||
0
src/server/task/packer.nim
Normal file
0
src/server/task/packer.nim
Normal file
0
src/server/task/parser.nim
Normal file
0
src/server/task/parser.nim
Normal file
Reference in New Issue
Block a user