Merge branch 'master' of github.com:bortzmeyer/dns-lg

master
Stephane Bortzmeyer 4 years ago
commit 726230774f
  1. 30
      DNSLG/Formatter.py
  2. 2
      sample-wsgi-dnslg-with-config-file.py
  3. 21
      usages/get-ip.go
  4. 3
      usages/get-ip.pl

@ -115,6 +115,8 @@ class TextFormatter(Formatter):
(rdata.longitude[0], rdata.longitude[1], rdata.longitude[2],
rdata.latitude[0], rdata.latitude[1], rdata.latitude[2],
rdata.altitude)
elif rdata.rdtype == dns.rdatatype.URI:
self.output += "URI: %s\n" % (rdata.target) # TODO display priority and weight?
elif rdata.rdtype == dns.rdatatype.SRV:
self.output += "Service location: server %s, port %i, priority %i, weight %i\n" % \
(rdata.target, rdata.port, rdata.priority, rdata.weight)
@ -215,6 +217,8 @@ class ZoneFormatter(Formatter):
self.output += "CNAME\t%s\n" % rdata.to_text()
elif rdata.rdtype == dns.rdatatype.LOC:
self.output += "LOC\t%s\n" % rdata.to_text()
elif rdata.rdtype == dns.rdatatype.URI:
self.output += "URI\t%s\n" % rdata.to_text().encode(querier.encoding)
elif rdata.rdtype == dns.rdatatype.DNSKEY:
self.output += "DNSKEY\t%s" % rdata.to_text()
try:
@ -286,6 +290,11 @@ class JsonFormatter(Formatter):
'Longitude': '%f' % rdata.float_longitude,
'Latitude': '%f' % rdata.float_latitude,
'Altitude': '%f' % rdata.altitude})
elif rdata.rdtype == dns.rdatatype.URI:
self.object['AnswerSection'].append({'Type': 'URI',
'Target': '%s' % rdata.target,
'Priority': '%i' % rdata.priority,
'Weight': '%i' % rdata.weight})
elif rdata.rdtype == dns.rdatatype.PTR:
self.object['AnswerSection'].append({'Type': 'PTR',
'Target': str(rdata.target)})
@ -425,6 +434,9 @@ spf_xml_template = """
loc_xml_template = """
<LOC tal:attributes="longitude longitude; latitude latitude; altitude altitude"/>
"""
uri_xml_template = """
<URI tal:attributes="target target; priority priority; weight weight"/>
"""
ptr_xml_template = """
<PTR tal:attributes="ptrdname name"/>
"""
@ -646,6 +658,13 @@ class XmlFormatter(Formatter):
self.loc_template.expand (icontext, iresult,
suppressXMLDeclaration=True,
outputEncoding=querier.encoding)
elif rdata.rdtype == dns.rdatatype.URI:
icontext.addGlobal ("target", rdata.target)
icontext.addGlobal ("weight", rdata.weight)
icontext.addGlobal ("priority", rdata.priority)
self.loc_template.expand (icontext, iresult,
suppressXMLDeclaration=True,
outputEncoding=querier.encoding)
elif rdata.rdtype == dns.rdatatype.NS:
icontext.addGlobal ("name", rdata.target)
# TODO: translate Punycode domain names back to Unicode?
@ -786,6 +805,9 @@ naptr_html_template = """
loc_html_template = """
<span>Location: <span tal:replace="longitude"/> / <span tal:replace="latitude"/> (altitude <span tal:replace="altitude"/>)</span>
"""
uri_html_template = """
<span>Priority: <span tal:replace="priority"/>, <span tal:replace="weight"/>, <a class="hostname" tal:attributes="href target" tal:content="target"/></span>
"""
unknown_html_template = """
<span>Unknown record type (<span tal:replace="rrtype"/>)</span>
"""
@ -869,6 +891,7 @@ class HtmlFormatter(Formatter):
self.txt_template = simpleTAL.compileXMLTemplate (txt_html_template)
self.spf_template = simpleTAL.compileXMLTemplate (spf_html_template)
self.loc_template = simpleTAL.compileXMLTemplate (loc_html_template)
self.uri_template = simpleTAL.compileXMLTemplate (uri_html_template)
self.nsec3param_template = simpleTAL.compileXMLTemplate (nsec3param_html_template)
self.ds_template = simpleTAL.compileXMLTemplate (ds_html_template)
self.dlv_template = simpleTAL.compileXMLTemplate (dlv_html_template)
@ -997,6 +1020,13 @@ class HtmlFormatter(Formatter):
self.loc_template.expand (icontext, iresult,
suppressXMLDeclaration=True,
outputEncoding=querier.encoding)
elif rdata.rdtype == dns.rdatatype.URI:
icontext.addGlobal ("target", rdata.target)
icontext.addGlobal ("weight", rdata.weight)
icontext.addGlobal ("priority", rdata.priority)
self.uri_template.expand (icontext, iresult,
suppressXMLDeclaration=True,
outputEncoding=querier.encoding)
elif rdata.rdtype == dns.rdatatype.NSEC3PARAM:
icontext.addGlobal ("algorithm", rdata.algorithm)
icontext.addGlobal ("iterations", rdata.iterations)

@ -12,7 +12,7 @@ default_values = {'email_administrator': None,
'url_documentation': None,
'url_css': None,
'url_opensearch': None,
'file_favicon': None,
'favicon': None,
'url_base_service': DNSLG.default_base_url,
'encoding': DNSLG.default_encoding,
'size_edns': '2048',

@ -5,14 +5,14 @@ censorship, etc. */
package main
import (
"fmt"
"os"
"time"
"io/ioutil"
"net/http"
"encoding/json"
"fmt"
"github.com/miekg/dns"
"github.com/mreiferson/go-httpclient" // To have HTTP timeouts
"io/ioutil"
"net/http"
"os"
"time"
)
const (
@ -40,9 +40,14 @@ func queryOne(comm chan instanceQuery, url string, name string) {
var (
object dnslgResponse
)
client := httpclient.New()
client.ConnectTimeout = 5 * time.Second
client.ReadWriteTimeout = 5 * time.Second
transport := &httpclient.Transport{
ConnectTimeout: 5 * time.Second,
ResponseHeaderTimeout: 5 * time.Second,
RequestTimeout: 10 * time.Second,
}
defer transport.Close()
client := &http.Client{Transport: transport}
// TODO: the format=json is redundant with the Accept header but, as of 2013-02-14, some instances still run the old code, without content negotiation
request, err := http.NewRequest("GET", fmt.Sprintf("%s/%s/ADDR?format=json", url, name), nil)
if err != nil {

@ -46,6 +46,9 @@ foreach my $URL (@DNS_LG_SERVERS) {
my $datos = decode_json $response->{content};
foreach my $rr (@{$datos->{AnswerSection}}) {
# TODO a (spurious?) warning "Use of uninitialized value in
# print at get-ip.pl" if the name is an alias, and only the
# canonical name has an address
print $rr->{Address}, ' ';
}
print "\n";

Loading…
Cancel
Save