[agent/codex:gpt-5.4-mini] Read docs/RFC.md fully. Find ONE feature described in the sp... #28

Merged
Virgil merged 1 commit from main into dev 2026-04-03 20:48:26 +00:00
6 changed files with 29 additions and 9 deletions

View file

@ -35,7 +35,7 @@ type ActionRegistrar interface {
// ActionDefinitions returns the complete DNS action surface in registration order.
//
// service.ActionDefinitions()
// definitions := service.ActionDefinitions()
func (service *Service) ActionDefinitions() []ActionDefinition {
return []ActionDefinition{
{
@ -129,7 +129,7 @@ func (service *Service) ActionDefinitions() []ActionDefinition {
// ActionNames returns the names of the registered DNS actions.
//
// service.ActionNames()
// names := service.ActionNames()
func (service *Service) ActionNames() []string {
definitions := service.ActionDefinitions()
names := make([]string, 0, len(definitions))
@ -153,7 +153,7 @@ func (service *Service) RegisterActions(registrar ActionRegistrar) {
// HandleAction executes a DNS action by name.
//
// service.HandleAction("dns.resolve", map[string]any{"name": "gateway.charon.lthn"})
// payload, ok, err := service.HandleAction("dns.resolve", map[string]any{"name": "gateway.charon.lthn"})
func (service *Service) HandleAction(name string, values map[string]any) (any, bool, error) {
for _, definition := range service.ActionDefinitions() {
if definition.Name == name {

7
hsd.go
View file

@ -60,6 +60,13 @@ func (err *HSDRPCError) Error() string {
return fmt.Sprintf("hsd rpc error (%d): %s", err.Code, err.Message)
}
// NewHSDClient builds a client for HSD JSON-RPC.
//
// client := dns.NewHSDClient(dns.HSDClientOptions{
// URL: "http://127.0.0.1:14037",
// Username: "user",
// Password: "pass",
// })
func NewHSDClient(options HSDClientOptions) *HSDClient {
client := options.HTTPClient
if client == nil {

View file

@ -45,7 +45,7 @@ func (server *HTTPServer) Close() error {
// ServeHTTPHealth starts a minimal HTTP server exposing GET /health.
//
// service.ServeHTTPHealth("127.0.0.1", 5554)
// server, err := service.ServeHTTPHealth("127.0.0.1", 5554)
func (service *Service) ServeHTTPHealth(bind string, port int) (*HTTPServer, error) {
if bind == "" {
bind = "127.0.0.1"

View file

@ -37,6 +37,13 @@ type MainchainRPCResponse struct {
Error *HSDRPCError `json:"error"`
}
// NewMainchainAliasClient builds a client for alias discovery on the main chain.
//
// client := dns.NewMainchainAliasClient(dns.MainchainClientOptions{
// URL: "http://127.0.0.1:14037",
// Username: "user",
// Password: "pass",
// })
func NewMainchainAliasClient(options MainchainClientOptions) *MainchainAliasClient {
client := options.HTTPClient
if client == nil {

View file

@ -44,9 +44,8 @@ func (server *DNSServer) Close() error {
}
// Serve starts DNS over UDP and TCP at bind:port and returns a running server handle.
// Example:
//
// srv, err := service.Serve("127.0.0.1", 0)
// srv, err := service.Serve("127.0.0.1", 53)
func (service *Service) Serve(bind string, port int) (*DNSServer, error) {
if bind == "" {
bind = "127.0.0.1"

View file

@ -68,6 +68,13 @@ type ServiceOptions struct {
TreeRootCheckInterval time.Duration
}
// NewService builds a DNS service from cached records and optional discovery hooks.
//
// service := dns.NewService(dns.ServiceOptions{
// Records: map[string]dns.NameRecords{
// "gateway.charon.lthn": {A: []string{"10.10.10.10"}},
// },
// })
func NewService(options ServiceOptions) *Service {
checkInterval := options.TreeRootCheckInterval
if checkInterval <= 0 {
@ -334,8 +341,9 @@ func (service *Service) Discover() error {
return nil
}
// DiscoverAliases refreshes DNS records by scanning chain aliases through HSD RPC calls.
// This matches the RFC `dns.discover` behavior by reusing the configured chain alias discoverers and fallback clients.
// DiscoverAliases refreshes DNS records from chain aliases.
//
// err := service.DiscoverAliases(context.Background())
func (service *Service) DiscoverAliases(ctx context.Context) error {
return service.DiscoverFromChainAliases(ctx, service.hsdClient)
}
@ -406,7 +414,6 @@ func (service *Service) ResolveTXTRecords(name string) (ResolveTXTResult, bool)
}
// DiscoverWithHSD refreshes DNS records for each alias by calling HSD.
// Example:
//
// err := service.DiscoverWithHSD(context.Background(), []string{"gateway.lthn"}, dns.NewHSDClient(dns.HSDClientOptions{
// URL: "http://127.0.0.1:14037",