Software /
code /
prosody
Annotate
tools/dnsregistry.lua @ 13126:d043834f15d2
mod_http: Use RFC 7239 Forwarded header to find original client IP
Prefer over X-Forwarded-* since it has an actual specification.
Main practical difference is that Forwarded may carry more properties
than only the IP address since it is a structured header.
Since we parse it into an array, it is easier to do the logical thing
and iterate backwards trough proxies until an untrusted one is
encountered. Compare the handling of X-Forwarded-For.
The 'secure' field now accounts for the full chain of proxies, which
must be secure all the way to be considered secure.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 03 Jun 2023 17:10:04 +0200 |
parent | 12855:3306807c0619 |
child | 13142:879a6a33c21b |
rev | line source |
---|---|
12237
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 -- Generate util/dnsregistry.lua from IANA HTTP status code registry |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 local xml = require "util.xml"; |
12271
f31bb79f51d7
tools: Allow processing instructions in some XML parsing tools
Kim Alvefur <zash@zash.se>
parents:
12237
diff
changeset
|
3 local registries = xml.parse(io.read("*a"), { allow_processing_instructions = true }); |
12237
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 print("-- Source: https://www.iana.org/assignments/dns-parameters/dns-parameters.xml"); |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 print(os.date("-- Generated on %Y-%m-%d")) |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 local registry_mapping = { |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 ["dns-parameters-2"] = "classes"; |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 ["dns-parameters-4"] = "types"; |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 ["dns-parameters-6"] = "errors"; |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 }; |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 print("return {"); |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 for registry in registries:childtags("registry") do |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 local registry_name = registry_mapping[registry.attr.id]; |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 if registry_name then |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 print("\t" .. registry_name .. " = {"); |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 for record in registry:childtags("record") do |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 local record_name = record:get_child_text("name"); |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 local record_type = record:get_child_text("type"); |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 local record_desc = record:get_child_text("description"); |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 local record_code = tonumber(record:get_child_text("value")); |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 |
12855
3306807c0619
tools/dnsregistry: Fix to ignore unassigned entries
Kim Alvefur <zash@zash.se>
parents:
12271
diff
changeset
|
25 if tostring(record):lower():match("reserved") or tostring(record):lower():match("unassigned") then |
12237
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
26 record_code = nil; |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
27 end |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
28 |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
29 if registry_name == "classes" and record_code then |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
30 record_type = record_desc and record_desc:match("%((%w+)%)$") |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
31 if record_type then |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
32 print(("\t\t[%q] = %d; [%d] = %q;"):format(record_type, record_code, record_code, record_type)) |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
33 end |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
34 elseif registry_name == "types" and record_type and record_code then |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
35 print(("\t\t[%q] = %d; [%d] = %q;"):format(record_type, record_code, record_code, record_type)) |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
36 elseif registry_name == "errors" and record_code and record_name then |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
37 print(("\t\t[%d] = %q; [%q] = %q;"):format(record_code, record_name, record_name, record_desc or record_name)); |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
38 end |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
39 end |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
40 print("\t};"); |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
41 end |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
42 end |
b35714c57442
tools.dnsregistry: For converting IANA DNS registry data to Lua table
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
43 print("};"); |