add NEONETWORK and PGPKEY support
This commit is contained in:
parent
d56d19a90b
commit
5b685c88b4
19
server.go
19
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 == "*" {
|
||||
|
@ -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)
|
||||
|
@ -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},
|
||||
|
Loading…
x
Reference in New Issue
Block a user