runner cleanup 1

This commit is contained in:
Sky Johnson 2025-04-05 13:55:50 -05:00
parent d07673e088
commit 3a10b22bac
8 changed files with 7 additions and 20 deletions

View File

@ -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"})

View File

@ -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,

View File

@ -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()

View File

@ -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())
}
}