runner cleanup 1
This commit is contained in:
parent
d07673e088
commit
3a10b22bac
|
@ -266,7 +266,7 @@ func init() {
|
||||||
GlobalRegistry.EnableDebug() // Enable debugging by default
|
GlobalRegistry.EnableDebug() // Enable debugging by default
|
||||||
logger.Debug("[ModuleRegistry] Registering core modules...")
|
logger.Debug("[ModuleRegistry] Registering core modules...")
|
||||||
|
|
||||||
GlobalRegistry.Register("go", GoModuleInitFunc())
|
GlobalRegistry.Register("util", UtilModuleInitFunc())
|
||||||
GlobalRegistry.Register("http", HTTPModuleInitFunc())
|
GlobalRegistry.Register("http", HTTPModuleInitFunc())
|
||||||
GlobalRegistry.RegisterWithDependencies("cookie", CookieModuleInitFunc(), []string{"http"})
|
GlobalRegistry.RegisterWithDependencies("cookie", CookieModuleInitFunc(), []string{"http"})
|
||||||
GlobalRegistry.RegisterWithDependencies("csrf", CSRFModuleInitFunc(), []string{"go"})
|
GlobalRegistry.RegisterWithDependencies("csrf", CSRFModuleInitFunc(), []string{"go"})
|
||||||
|
|
|
@ -33,12 +33,8 @@ local csrf = {
|
||||||
error("CSRF protection requires the session module", 2)
|
error("CSRF protection requires the session module", 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Use Go's secure token generation
|
local token = util.generate_token(length)
|
||||||
local token = go.generate_token(length)
|
|
||||||
|
|
||||||
-- Store in session
|
|
||||||
session.set(csrf.TOKEN_KEY, token)
|
session.set(csrf.TOKEN_KEY, token)
|
||||||
|
|
||||||
return token
|
return token
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -6,8 +6,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"Moonshark/core/logger"
|
|
||||||
|
|
||||||
luajit "git.sharkk.net/Sky/LuaJIT-to-Go"
|
luajit "git.sharkk.net/Sky/LuaJIT-to-Go"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -95,13 +93,6 @@ func (l *ModuleLoader) EnableDebug() {
|
||||||
l.debug = true
|
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
|
// SetScriptDir sets the script directory
|
||||||
func (l *ModuleLoader) SetScriptDir(dir string) {
|
func (l *ModuleLoader) SetScriptDir(dir string) {
|
||||||
l.mu.Lock()
|
l.mu.Lock()
|
||||||
|
|
|
@ -43,16 +43,16 @@ func GenerateToken(s *luajit.State) int {
|
||||||
return 1 // One return value
|
return 1 // One return value
|
||||||
}
|
}
|
||||||
|
|
||||||
// GoModuleFunctions returns all functions for the go module
|
// UtilModuleFunctions returns all functions for the go module
|
||||||
func GoModuleFunctions() map[string]luajit.GoFunction {
|
func UtilModuleFunctions() map[string]luajit.GoFunction {
|
||||||
return map[string]luajit.GoFunction{
|
return map[string]luajit.GoFunction{
|
||||||
"generate_token": GenerateToken,
|
"generate_token": GenerateToken,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GoModuleInitFunc returns an initializer for the go module
|
// UtilModuleInitFunc returns an initializer for the go module
|
||||||
func GoModuleInitFunc() StateInitFunc {
|
func UtilModuleInitFunc() StateInitFunc {
|
||||||
return func(state *luajit.State) error {
|
return func(state *luajit.State) error {
|
||||||
return RegisterModule(state, "go", GoModuleFunctions())
|
return RegisterModule(state, "util", UtilModuleFunctions())
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user