Record encrypted, xor'd IP of survey clients
parent
e7c18cdec6
commit
7fb590d527
|
@ -153,12 +153,15 @@ function register!(survey::Survey)
|
|||
end
|
||||
end
|
||||
|
||||
function register!(response::Response; cache::Bool=true)
|
||||
function register!(response::Response, exip::Integer=0; cache::Bool=true)
|
||||
if response.survey ∉ keys(surveys(;cache))
|
||||
register!(response.survey)
|
||||
end
|
||||
@assert response.id ∉ responseids(response.survey; cache)
|
||||
SearchLight.query("INSERT INTO responses (survey, id, started, page) VALUES ($(response.survey), $(response.id), '$(string(response.started))', $(response.page))")
|
||||
SearchLight.query(
|
||||
"INSERT INTO responses (survey, id, exip, started, page) \
|
||||
VALUES ($(response.survey), $(response.id), $exip, \
|
||||
'$(string(response.started))', $(response.page))")
|
||||
for (qid, ans) in response.answers
|
||||
qid_s = SearchLight.escape_value(string(qid))
|
||||
value_s = SearchLight.escape_value(repr(ans.value))
|
||||
|
|
|
@ -34,10 +34,16 @@ function index()
|
|||
end
|
||||
|
||||
function new()
|
||||
function encrypted_xord_ip()
|
||||
ip_str = get(Dict(payload()[:REQUEST].headers), "X-Forwarded-For", "0.0.0.0")
|
||||
ip = parse.(UInt8, split(ip_str, '.'))
|
||||
@info "client ip: $ip"
|
||||
xor(reinterpret(UInt32, Genie.Encryption.encrypt(rand(UInt8, 4)) |> hex2bytes)...)
|
||||
end
|
||||
r = Surveys.Response(SURVEY, vcat(responseids(SURVEY),
|
||||
Vector{Surveys.ResponseID}(keys(INPROGRESS) |> collect)))
|
||||
INPROGRESS[r.id] = r
|
||||
register!(r)
|
||||
register!(r, encrypted_xord_ip())
|
||||
uid_str = string(r.id, base=UID_ENCBASE)
|
||||
Genie.Renderer.redirect(HTTP.URIs.URI(currenturl()).path * "?uid=$uid_str&page=1")
|
||||
end
|
||||
|
|
|
@ -25,6 +25,7 @@ function up()
|
|||
[
|
||||
column(:survey, :integer, not_null=true),
|
||||
column(:id, :integer, not_null=true),
|
||||
column(:exip, :integer, not_null=true),
|
||||
column(:started, :text, not_null=true),
|
||||
column(:completed, :text),
|
||||
column(:page, :integer, not_null=true),
|
||||
|
|
Loading…
Reference in New Issue