From 3a10b22bac38fd26c2b43033d275e854ee97d901 Mon Sep 17 00:00:00 2001 From: Sky Johnson Date: Sat, 5 Apr 2025 13:55:50 -0500 Subject: [PATCH] runner cleanup 1 --- core/runner/{Cookies.go => CookieModule.go} | 0 core/runner/CoreModules.go | 2 +- core/runner/{Csrf.go => CsrfModule.go} | 6 +----- core/runner/{Modules.go => GoModules.go} | 0 core/runner/{Http.go => HttpModule.go} | 0 core/runner/ModuleLoader.go | 9 --------- core/runner/{Session.go => SessionModule.go} | 0 core/runner/{Go.go => UtilModule.go} | 10 +++++----- 8 files changed, 7 insertions(+), 20 deletions(-) rename core/runner/{Cookies.go => CookieModule.go} (100%) rename core/runner/{Csrf.go => CsrfModule.go} (97%) rename core/runner/{Modules.go => GoModules.go} (100%) rename core/runner/{Http.go => HttpModule.go} (100%) rename core/runner/{Session.go => SessionModule.go} (100%) rename core/runner/{Go.go => UtilModule.go} (79%) diff --git a/core/runner/Cookies.go b/core/runner/CookieModule.go similarity index 100% rename from core/runner/Cookies.go rename to core/runner/CookieModule.go diff --git a/core/runner/CoreModules.go b/core/runner/CoreModules.go index ad5cdc5..9356ce7 100644 --- a/core/runner/CoreModules.go +++ b/core/runner/CoreModules.go @@ -266,7 +266,7 @@ func init() { GlobalRegistry.EnableDebug() // Enable debugging by default logger.Debug("[ModuleRegistry] Registering core modules...") - GlobalRegistry.Register("go", GoModuleInitFunc()) + GlobalRegistry.Register("util", UtilModuleInitFunc()) GlobalRegistry.Register("http", HTTPModuleInitFunc()) GlobalRegistry.RegisterWithDependencies("cookie", CookieModuleInitFunc(), []string{"http"}) GlobalRegistry.RegisterWithDependencies("csrf", CSRFModuleInitFunc(), []string{"go"}) diff --git a/core/runner/Csrf.go b/core/runner/CsrfModule.go similarity index 97% rename from core/runner/Csrf.go rename to core/runner/CsrfModule.go index c73b1f5..f6f882a 100644 --- a/core/runner/Csrf.go +++ b/core/runner/CsrfModule.go @@ -33,12 +33,8 @@ local csrf = { error("CSRF protection requires the session module", 2) end - -- Use Go's secure token generation - local token = go.generate_token(length) - - -- Store in session + local token = util.generate_token(length) session.set(csrf.TOKEN_KEY, token) - return token end, diff --git a/core/runner/Modules.go b/core/runner/GoModules.go similarity index 100% rename from core/runner/Modules.go rename to core/runner/GoModules.go diff --git a/core/runner/Http.go b/core/runner/HttpModule.go similarity index 100% rename from core/runner/Http.go rename to core/runner/HttpModule.go diff --git a/core/runner/ModuleLoader.go b/core/runner/ModuleLoader.go index fa2caac..e4da43d 100644 --- a/core/runner/ModuleLoader.go +++ b/core/runner/ModuleLoader.go @@ -6,8 +6,6 @@ import ( "strings" "sync" - "Moonshark/core/logger" - luajit "git.sharkk.net/Sky/LuaJIT-to-Go" ) @@ -95,13 +93,6 @@ func (l *ModuleLoader) EnableDebug() { l.debug = true } -// debugLog logs a message if debug is enabled -func (l *ModuleLoader) debugLog(format string, args ...interface{}) { - if l.debug { - logger.Debug("[ModuleLoader] "+format, args...) - } -} - // SetScriptDir sets the script directory func (l *ModuleLoader) SetScriptDir(dir string) { l.mu.Lock() diff --git a/core/runner/Session.go b/core/runner/SessionModule.go similarity index 100% rename from core/runner/Session.go rename to core/runner/SessionModule.go diff --git a/core/runner/Go.go b/core/runner/UtilModule.go similarity index 79% rename from core/runner/Go.go rename to core/runner/UtilModule.go index 9b1d312..55e2e57 100644 --- a/core/runner/Go.go +++ b/core/runner/UtilModule.go @@ -43,16 +43,16 @@ func GenerateToken(s *luajit.State) int { return 1 // One return value } -// GoModuleFunctions returns all functions for the go module -func GoModuleFunctions() map[string]luajit.GoFunction { +// UtilModuleFunctions returns all functions for the go module +func UtilModuleFunctions() map[string]luajit.GoFunction { return map[string]luajit.GoFunction{ "generate_token": GenerateToken, } } -// GoModuleInitFunc returns an initializer for the go module -func GoModuleInitFunc() StateInitFunc { +// UtilModuleInitFunc returns an initializer for the go module +func UtilModuleInitFunc() StateInitFunc { return func(state *luajit.State) error { - return RegisterModule(state, "go", GoModuleFunctions()) + return RegisterModule(state, "util", UtilModuleFunctions()) } }