[agent/codex:gpt-5.4-mini] Read docs/RFC.md fully. Find ONE feature described in the sp... #49
3 changed files with 13 additions and 5 deletions
|
|
@ -13,6 +13,7 @@ import (
|
|||
//
|
||||
// server, err := service.ServeHTTPHealth("127.0.0.1", 5554)
|
||||
// defer func() { _ = server.Close() }()
|
||||
// fmt.Println("health at", server.Address())
|
||||
type HTTPServer struct {
|
||||
listener net.Listener
|
||||
server *http.Server
|
||||
|
|
@ -50,6 +51,7 @@ func (server *HTTPServer) Close() error {
|
|||
//
|
||||
// server, err := service.ServeHTTPHealth("127.0.0.1", 5554)
|
||||
// defer func() { _ = server.Close() }()
|
||||
// resp, _ := http.Get("http://" + server.Address() + "/health")
|
||||
func (service *Service) ServeHTTPHealth(bind string, port int) (*HTTPServer, error) {
|
||||
if bind == "" {
|
||||
bind = "127.0.0.1"
|
||||
|
|
|
|||
5
serve.go
5
serve.go
|
|
@ -15,6 +15,7 @@ const dnsTTL = 300
|
|||
//
|
||||
// srv, err := service.Serve("127.0.0.1", 53)
|
||||
// defer func() { _ = srv.Close() }()
|
||||
// fmt.Println("dns at", srv.Address())
|
||||
type DNSServer struct {
|
||||
udpListener net.PacketConn
|
||||
tcpListener net.Listener
|
||||
|
|
@ -26,6 +27,7 @@ type DNSServer struct {
|
|||
//
|
||||
// runtime, err := service.ServeAll("127.0.0.1", 53, 5554)
|
||||
// defer func() { _ = runtime.Close() }()
|
||||
// fmt.Println(runtime.DNSAddress(), runtime.HTTPAddress())
|
||||
type ServiceRuntime struct {
|
||||
DNS *DNSServer
|
||||
HTTP *HTTPServer
|
||||
|
|
@ -92,6 +94,8 @@ func (server *DNSServer) Close() error {
|
|||
//
|
||||
// srv, err := service.Serve("0.0.0.0", 53)
|
||||
// defer func() { _ = srv.Close() }()
|
||||
// lookup := new(dnsprotocol.Msg)
|
||||
// lookup.SetQuestion("gateway.charon.lthn.", dnsprotocol.TypeA)
|
||||
func (service *Service) Serve(bind string, port int) (*DNSServer, error) {
|
||||
if bind == "" {
|
||||
bind = "127.0.0.1"
|
||||
|
|
@ -136,6 +140,7 @@ func (service *Service) Serve(bind string, port int) (*DNSServer, error) {
|
|||
//
|
||||
// runtime, err := service.ServeAll("127.0.0.1", 53, 5554)
|
||||
// defer func() { _ = runtime.Close() }()
|
||||
// fmt.Println("dns:", runtime.DNSAddress(), "health:", runtime.HTTPAddress())
|
||||
func (service *Service) ServeAll(bind string, dnsPort int, httpPort int) (*ServiceRuntime, error) {
|
||||
dnsServer, err := service.Serve(bind, dnsPort)
|
||||
if err != nil {
|
||||
|
|
|
|||
11
service.go
11
service.go
|
|
@ -45,6 +45,7 @@ type ReverseLookupResult struct {
|
|||
// HealthResult is the typed payload returned by Health and dns.health.
|
||||
//
|
||||
// health := service.Health()
|
||||
// fmt.Println(health.Status, health.NamesCached, health.TreeRoot)
|
||||
type HealthResult struct {
|
||||
Status string `json:"status"`
|
||||
NamesCached int `json:"names_cached"`
|
||||
|
|
@ -328,11 +329,10 @@ func parseActionAliasRecord(record map[string]any) (string, error) {
|
|||
|
||||
// DiscoverFromMainchainAliases updates records from main-chain aliases resolved through HSD.
|
||||
//
|
||||
// service.DiscoverFromMainchainAliases(context.Background(), dns.NewMainchainAliasClient(dns.MainchainClientOptions{
|
||||
// URL: "http://127.0.0.1:14037",
|
||||
// }), dns.NewHSDClient(dns.HSDClientOptions{
|
||||
// URL: "http://127.0.0.1:14037",
|
||||
// }))
|
||||
// err := service.DiscoverFromMainchainAliases(context.Background(),
|
||||
// dns.NewMainchainAliasClient(dns.MainchainClientOptions{URL: "http://127.0.0.1:14037"}),
|
||||
// dns.NewHSDClient(dns.HSDClientOptions{URL: "http://127.0.0.1:14037"}),
|
||||
// )
|
||||
func (service *Service) DiscoverFromMainchainAliases(ctx context.Context, chainClient *MainchainAliasClient, hsdClient *HSDClient) error {
|
||||
resolvedHSDClient, err := service.resolveHSDClient(hsdClient)
|
||||
if err != nil {
|
||||
|
|
@ -676,6 +676,7 @@ func (service *Service) ResolveAll(name string) (ResolveAllResult, bool) {
|
|||
// Health reports the live cache size and tree root.
|
||||
//
|
||||
// health := service.Health()
|
||||
// fmt.Println(health.TreeRoot)
|
||||
func (service *Service) Health() HealthResult {
|
||||
service.mu.RLock()
|
||||
defer service.mu.RUnlock()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue