Skip to content

Commit

Permalink
fixup! Add javascript challenge sample
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorNogueiraRio committed Aug 11, 2020
1 parent b6ca132 commit bdd9779
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion samples/bpf/checkcookie.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ function checkcookieport(pkt, ip, port)
end

function checkcookie(pkt, ip)
local cookiepkt = tonumber(string.match(tostring(pkt), "Cookie:%s__xdp=(.-)\r\n"))
local pattern = 'Cookie:%s*=__xdp=(%d+)%s*'
local cookiepkt = tonumber(string.match(tostring(pkt), pattern))

if not cookies[ip] then
return true
end

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

0 comments on commit bdd9779

Please sign in to comment.