mirror of
https://github.com/bol-van/zapret2.git
synced 2026-03-19 07:45:49 +00:00
move basic desync functions to zapret-lib.lua
This commit is contained in:
@@ -70,35 +70,6 @@ standard ipfrag :
|
||||
]]
|
||||
|
||||
|
||||
-- execute given lua code. "desync" is temporary set as global var to be accessible to the code
|
||||
-- useful for simple fast actions without writing a func
|
||||
-- arg: code=<lua_code>
|
||||
function luaexec(ctx, desync)
|
||||
if not desync.arg.code then
|
||||
error("luaexec: no 'code' parameter")
|
||||
end
|
||||
local fname = desync.func_instance.."_luaexec_code"
|
||||
if not _G[fname] then
|
||||
_G[fname] = load(desync.arg.code, fname)
|
||||
end
|
||||
-- allow dynamic code to access desync
|
||||
_G.desync = desync
|
||||
_G[fname]()
|
||||
_G.desync = nil
|
||||
end
|
||||
|
||||
-- dummy test function. does nothing.
|
||||
-- no args
|
||||
function pass(ctx, desync)
|
||||
DLOG("pass")
|
||||
end
|
||||
|
||||
-- prints desync to DLOG
|
||||
function pktdebug(ctx, desync)
|
||||
DLOG("desync:")
|
||||
var_debug(desync)
|
||||
end
|
||||
|
||||
-- drop packet
|
||||
-- standard args : direction, payload
|
||||
function drop(ctx, desync)
|
||||
|
||||
@@ -3,6 +3,41 @@ NOT3=bitnot(3)
|
||||
NOT7=bitnot(7)
|
||||
math.randomseed(os.time())
|
||||
|
||||
|
||||
-- basic desync function
|
||||
-- execute given lua code. "desync" is temporary set as global var to be accessible to the code
|
||||
-- useful for simple fast actions without writing a func
|
||||
-- arg: code=<lua_code>
|
||||
function luaexec(ctx, desync)
|
||||
if not desync.arg.code then
|
||||
error("luaexec: no 'code' parameter")
|
||||
end
|
||||
local fname = desync.func_instance.."_luaexec_code"
|
||||
if not _G[fname] then
|
||||
_G[fname] = load(desync.arg.code, fname)
|
||||
end
|
||||
-- allow dynamic code to access desync
|
||||
_G.desync = desync
|
||||
_G[fname]()
|
||||
_G.desync = nil
|
||||
end
|
||||
|
||||
-- basic desync function
|
||||
-- does nothing just acknowledges when it's called
|
||||
-- no args
|
||||
function pass(ctx, desync)
|
||||
DLOG("pass")
|
||||
end
|
||||
|
||||
-- basic desync function
|
||||
-- prints desync to DLOG
|
||||
function pktdebug(ctx, desync)
|
||||
DLOG("desync:")
|
||||
var_debug(desync)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- prepare standard rawsend options from desync
|
||||
-- repeats - how many time send the packet
|
||||
-- ifout - override outbound interface (if --bind_fix4, --bind-fix6 enabled)
|
||||
|
||||
@@ -1403,7 +1403,7 @@ static void exithelp(void)
|
||||
" --nlm-list[=all]\t\t\t\t\t; list Network List Manager (NLM) networks. connected only or all.\n"
|
||||
#endif
|
||||
"\nDESYNC ENGINE INIT:\n"
|
||||
" --writeable[=<dir_name>]\t\t\t\t; create writeable dir for LUA engine and pass it in WRITEABLE env variable (only one dir possible)\n"
|
||||
" --writeable[=<dir_name>]\t\t\t\t; create writeable dir for LUA scripts and pass it in WRITEABLE env variable (only one dir possible)\n"
|
||||
" --blob=<item_name>:[+ofs]@<filename>|0xHEX\t\t; load blob to LUA var <item_name>\n"
|
||||
" --lua-init=@<filename>|<lua_text>\t\t\t; load LUA program from a file or string. if multiple parameters present order of execution is preserved.\n"
|
||||
" --lua-gc=<int>\t\t\t\t\t\t; forced garbage collection every N sec. default %u sec. triggers only when a packet arrives. 0 = disable.\n"
|
||||
|
||||
Reference in New Issue
Block a user