Skip to content

Commit bdd9779

Browse files
fixup! Add javascript challenge sample
1 parent b6ca132 commit bdd9779

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

samples/bpf/checkcookie.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ function checkcookieport(pkt, ip, port)
4545
end
4646

4747
function checkcookie(pkt, ip)
48-
local cookiepkt = tonumber(string.match(tostring(pkt), "Cookie:%s__xdp=(.-)\r\n"))
48+
local pattern = 'Cookie:%s*=__xdp=(%d+)%s*'
49+
local cookiepkt = tonumber(string.match(tostring(pkt), pattern))
50+
51+
if not cookies[ip] then
52+
return true
53+
end
4954

5055
return cookies[ip] == cookiepkt and true or false
5156
end

0 commit comments

Comments
 (0)