[agent/codex:gpt-5.3-codex-spark] Read docs/RFC.md fully. Find ONE feature described in the sp... #86
4 changed files with 28 additions and 2 deletions
|
|
@ -64,6 +64,9 @@ func (service *Service) ServeHTTPHealth(bind string, port int) (*HealthServer, e
|
|||
if bind == "" {
|
||||
bind = "127.0.0.1"
|
||||
}
|
||||
if port <= 0 {
|
||||
port = service.resolveHTTPPort()
|
||||
}
|
||||
|
||||
address := net.JoinHostPort(bind, strconv.Itoa(port))
|
||||
listener, err := net.Listen("tcp", address)
|
||||
|
|
|
|||
11
serve.go
11
serve.go
|
|
@ -113,6 +113,13 @@ func (server *DNSServer) Close() error {
|
|||
return err
|
||||
}
|
||||
|
||||
func (service *Service) resolveHTTPPort() int {
|
||||
if service == nil || service.httpPort <= 0 {
|
||||
return DefaultHTTPPort
|
||||
}
|
||||
return service.httpPort
|
||||
}
|
||||
|
||||
// Serve starts DNS over UDP and TCP.
|
||||
//
|
||||
// srv, err := service.Serve("0.0.0.0", 53)
|
||||
|
|
@ -168,8 +175,8 @@ func (service *Service) ServeAll(bind string, dnsPort int, httpPort int) (*Servi
|
|||
if dnsPort == 0 {
|
||||
dnsPort = service.dnsPort
|
||||
}
|
||||
if httpPort == 0 {
|
||||
httpPort = service.httpPort
|
||||
if httpPort <= 0 {
|
||||
httpPort = service.resolveHTTPPort()
|
||||
}
|
||||
|
||||
dnsServer, err := service.Serve(bind, dnsPort)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import (
|
|||
// fmt.Println(dns.DefaultTreeRootCheckInterval)
|
||||
const DefaultTreeRootCheckInterval = 15 * time.Second
|
||||
const DefaultDNSPort = 53
|
||||
const DefaultHTTPPort = 5554
|
||||
|
||||
// NameRecords stores the cached DNS records for one name.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -2250,6 +2250,21 @@ func TestServiceResolveServePortDefaultsToStandardDNSPort(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestServiceResolveHTTPPortDefaultsToStandardHTTPPort(t *testing.T) {
|
||||
service := NewService(ServiceOptions{})
|
||||
if service.resolveHTTPPort() != DefaultHTTPPort {
|
||||
t.Fatalf("expected resolve HTTP port to default to %d, got %d", DefaultHTTPPort, service.resolveHTTPPort())
|
||||
}
|
||||
|
||||
customPort := 5555
|
||||
customService := NewService(ServiceOptions{
|
||||
HTTPPort: customPort,
|
||||
})
|
||||
if customService.resolveHTTPPort() != customPort {
|
||||
t.Fatalf("expected resolveHTTPPort to honor configured HTTPPort, got %d", customService.resolveHTTPPort())
|
||||
}
|
||||
}
|
||||
|
||||
func TestServiceActionNamesExposeAllRFCActions(t *testing.T) {
|
||||
service := NewService(ServiceOptions{})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue