mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-11-30 21:58:39 +00:00
Lua: Expose Go slices as read-only
This commit is contained in:
@@ -23,7 +23,7 @@ func RegisterLua(L *lua.LState) {
|
||||
return 0
|
||||
}
|
||||
xlua.PushWithDirectMethods(L, matcher, map[string]xlua.DirectMethod{
|
||||
"Match": newLuaDomainMatch(xlua.NewSlicePusher[uint32](L)),
|
||||
"Match": newLuaDomainMatch(xlua.NewReadOnlySlicePusher[uint32](L)),
|
||||
"MatchAny": luaDomainMatchAny,
|
||||
})
|
||||
return 1
|
||||
|
||||
@@ -104,7 +104,9 @@ for _, value in ipairs({matcher, domain}) do
|
||||
assert(not pcall(function() return value ^ {} end))
|
||||
end
|
||||
assert(domain:matchAny("example.com"))
|
||||
assert(#domain:Match("example.com") == 1)
|
||||
local indices = domain:Match("example.com")
|
||||
assert(#indices == 1)
|
||||
assert(not pcall(function() indices[1] = 7 end))
|
||||
assert(domain:match("example.com")[1] == 0)
|
||||
assert(not pcall(function() matcher:AnyMatch() end))
|
||||
assert(not pcall(function() matcher:AnyMatch(matched, true) end))
|
||||
|
||||
Reference in New Issue
Block a user