add NEONETWORK and PGPKEY support

This commit is contained in:
Simon Marsh 2021-12-06 15:02:47 +00:00
parent d56d19a90b
commit 5b685c88b4
Signed by: burble
GPG Key ID: 0FCCD13AE1CF7ED8
4 changed files with 22 additions and 23 deletions

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module whois42d
go 1.17

View File

@ -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 == "*" {

View File

@ -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)

View File

@ -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},