From 5b685c88b4e3f10b727224f92e37f95a7f503051 Mon Sep 17 00:00:00 2001 From: Simon Marsh Date: Mon, 6 Dec 2021 15:02:47 +0000 Subject: [PATCH] add NEONETWORK and PGPKEY support --- go.mod | 3 +++ server.go | 19 ++++++------------- whois/query.go | 2 +- whois/registry.go | 21 ++++++++++++--------- 4 files changed, 22 insertions(+), 23 deletions(-) create mode 100644 go.mod diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..e73e5cd --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module whois42d + +go 1.17 diff --git a/server.go b/server.go index 00bae39..6359505 100644 --- a/server.go +++ b/server.go @@ -28,7 +28,7 @@ type Server struct { } func New(opts options) *Server { - registry := whois.New(opts.Datapath, opts.Header, opts.DNSTopLevel, opts.RegistryTopLevel) + registry := whois.New(opts.Datapath, opts.Header) return &Server{registry, time.Now(), false, 0, sync.WaitGroup{}} } @@ -75,13 +75,11 @@ func (s *Server) handleConn(conn *net.TCPConn) { ////////////////////////////////////////////////////////////////////////// type options struct { - Port uint `json:port` - Address string `json:address` - Registry string `json:registry` - Datapath string - Header string `json:header` - DNSTopLevel string `json:dnstoplevel` - RegistryTopLevel string `json:registrytoplevel` + Port uint `json:port` + Address string `json:address` + Registry string `json:registry` + Datapath string + Header string `json:header` } func parseFlags() options { @@ -96,11 +94,6 @@ func parseFlags() options { "header", "This is the dn42 whois query service.", "announcement header") - flag.StringVar(&o.DNSTopLevel, "dnstoplevel", "dn42", "DNS TLD") - flag.StringVar(&o.RegistryTopLevel, - "registrytoplevel", - "DN42", - "Registry Top Level identifier") flag.Parse() if o.Address == "*" { diff --git a/whois/query.go b/whois/query.go index 7c3d7bf..c930a8a 100644 --- a/whois/query.go +++ b/whois/query.go @@ -83,7 +83,7 @@ func (r *Registry) printServerInfo(conn *net.TCPConn, what string) { case "version": fmt.Fprintf(conn, "%% whois42d v%d\n", VERSION) case "sources": - fmt.Fprintf(conn, r.RegistryTopLevel+":3:N:0-0\n") + fmt.Fprintf(conn, "DN42:3:N:0-0\n") case "types": for _, t := range r.whoisTypes { fmt.Fprintf(conn, "%s\n", t.Name) diff --git a/whois/registry.go b/whois/registry.go index 5623d61..9fe2a79 100644 --- a/whois/registry.go +++ b/whois/registry.go @@ -13,11 +13,9 @@ import ( ) type Registry struct { - DataPath string - Header string - DNSTopLevel string - RegistryTopLevel string - whoisTypes []Type + DataPath string + Header string + whoisTypes []Type } type Type struct { @@ -40,17 +38,22 @@ type Query struct { Flags *Flags } -func New(DataPath string, Header string, DNSTopLevel string, RegistryTopLevel string) Registry { - r := Registry{DataPath: DataPath, Header: Header, DNSTopLevel: DNSTopLevel, RegistryTopLevel: RegistryTopLevel} +func New(DataPath string, Header string) Registry { + r := Registry{ + DataPath: DataPath, + Header: Header, + } r.whoisTypes = []Type{ {"aut-num", regexp.MustCompile(`^AS([0123456789]+)$`), UPPER}, - {"dns", regexp.MustCompile(`.` + r.DNSTopLevel + `$`), LOWER}, - {"person", regexp.MustCompile(`-` + r.RegistryTopLevel + `$`), UPPER}, + {"dns", regexp.MustCompile(`.dn42$`), LOWER}, + {"person", regexp.MustCompile(`-DN42$`), UPPER}, + {"person", regexp.MustCompile(`-NEONETWORK$`), UPPER}, {"mntner", regexp.MustCompile(`-MNT$`), UPPER}, {"schema", regexp.MustCompile(`-SCHEMA$`), UPPER}, {"organisation", regexp.MustCompile(`ORG-`), UPPER}, {"tinc-keyset", regexp.MustCompile(`^SET-.+-TINC$`), UPPER}, {"tinc-key", regexp.MustCompile(`-TINC$`), UPPER}, + {"key-cert", regexp.MustCompile(`^PGPKEY-$`), UPPER}, {"as-set", regexp.MustCompile(`^AS`), UPPER}, {"route-set", regexp.MustCompile(`^RS-`), UPPER}, {"inetnum", nil, ROUTE},