Hello,

thanks for hints. I got it working and I’m successfully counting what I need.


function count_chrome_doh()
    return function (state, query)
        if query.request.qsource.flags.http then
            
            for i = 1, tonumber(query.request.qsource.headers.len) do
                local k = ffi.string(query.request.qsource.headers.at[i - 1].name)
                local v = ffi.string(query.request.qsource.headers.at[i - 1].value)

                if k == 'user-agent' and v == 'Chrome' then
                    stats['request.agent.chrome'] = stats.get('request.agent.chrome') + 1

                    return nil
                end

            end

        end

        return nil
    end
end

stats['request.agent.chrome'] = 0
net.doh_headers({'user-agent'})

policy.add(count_chrome_doh())



Dňa 15. 9. 2023 o 13:23, Vladimír Čunát <vladimir.cunat@nic.cz> napísal:

On 15/09/2023 13.04, Vladimír Čunát wrote:
(I don't recall if all http headers get always pulled into this structure, but you should see that practically soon.)

After remembering a bit more and looking into source, you need to configure in advance the header names that would get pulled into that place.  In your case that should be simply adding one line into your config (outside the callbacks)

net.doh_headers({ 'user-agent' })

--