2020-05-13 06:57:57 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-05-19 10:12:18 +00:00
|
|
|
"log"
|
2020-05-13 06:57:57 +00:00
|
|
|
)
|
|
|
|
|
2020-05-19 10:12:18 +00:00
|
|
|
type LastName struct {
|
|
|
|
Name []byte
|
2020-05-13 06:57:57 +00:00
|
|
|
}
|
|
|
|
|
2020-05-19 10:12:18 +00:00
|
|
|
type FirstName struct {
|
|
|
|
Name []byte
|
2020-05-13 06:57:57 +00:00
|
|
|
}
|
|
|
|
|
2020-05-19 10:12:18 +00:00
|
|
|
var fnl *KeyList = &KeyList{}
|
|
|
|
var lnl *KeyList = &KeyList{}
|
2020-05-13 06:57:57 +00:00
|
|
|
|
|
|
|
type nameserver struct {
|
|
|
|
}
|
|
|
|
|
2020-05-19 10:12:18 +00:00
|
|
|
func (s *nameserver) FirstName(cxt context.Context, request *Request) (*Reply, error) {
|
2020-05-13 06:57:57 +00:00
|
|
|
|
2020-05-19 10:12:18 +00:00
|
|
|
reply := &Reply{}
|
|
|
|
reply.Message = string(GetRandomKey(fnl).(FirstName).Name)
|
2020-05-13 06:57:57 +00:00
|
|
|
return reply, nil
|
2020-06-02 07:26:53 +00:00
|
|
|
|
2020-05-13 06:57:57 +00:00
|
|
|
}
|
|
|
|
|
2020-05-19 10:12:18 +00:00
|
|
|
func (s *nameserver) LastName(cxt context.Context, request *Request) (*Reply, error) {
|
|
|
|
reply := &Reply{}
|
|
|
|
log.Println(len(lnl.Keys))
|
|
|
|
reply.Message = string(GetRandomKey(lnl).(LastName).Name)
|
2020-05-13 06:57:57 +00:00
|
|
|
return reply, nil
|
|
|
|
}
|
|
|
|
|
2020-05-19 10:12:18 +00:00
|
|
|
func (s *nameserver) FullName(cxt context.Context, request *Request) (*Reply, error) {
|
|
|
|
reply := &Reply{}
|
2020-05-13 06:57:57 +00:00
|
|
|
var fullname []byte
|
2020-05-19 10:12:18 +00:00
|
|
|
fullname = append(fullname, GetRandomKey(fnl).(FirstName).Name...)
|
|
|
|
fullname = append(fullname, GetRandomKey(lnl).(LastName).Name...)
|
2020-05-13 06:57:57 +00:00
|
|
|
reply.Message = string(fullname)
|
|
|
|
return reply, nil
|
|
|
|
}
|